Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

I'm reading my SICP

Name: Anonymous 2010-10-18 15:23

what does /prog use for they're SICP exercises?

Name: Anonymous 2010-10-18 15:28

???????????????????????????? ???????????????????????????????????????? ???????????? ???????????????????????????????????????????????? ???????????????????????????? ???????? ????????????????????????????????????????????????
???????????????????????????????????????????????? ???????????? ???????????????????????????????????????? ???????????????????????????????????????????????????? ???????? ???????????? ???????????????? ???????? ????????????????????????????????????????????
???????????????????????????????? ????????????????????????????????, ???????????????????????????????????????? ???????????????????????? ???????????????????? ???????? ???????????? ????????????????????????????????, ???? ????????????????????????????
???????????????????????????????????????????? ???????? ????????????????????????????, ????????????????????, ????????????????-???????????????????????????? ???????????????????????? ???????????????? ???????????????? ????????????????????????
???????????????????????????????????????? ???????????????????????????????????????? ???????????????????????????????????????????????????? ???????? ???????????????? ???????? ???????????????????????????? ???????????? ????????????????????????
???????????? ???????????????????????????????????????????????? ???????????????????????????? ???????????? ???????????? ????????????.

???????? ???????? ???? ???????????????? ???????? ???????????????????????? ????????????, ???????????????????????????? ???????? ???????????????????????? ???????????????????? ???????????? ???????????????????????????? ????????????
???????? ???????????????????????? ???????????? ???????????????????????????????????? ???????????????????? ???????? ???????????? ????????????????????????????????.

Name: Anonymous 2010-10-18 15:43

#include"winsock2.H"
#include"Stdio.H"
#include"Tlhelp32.H"
#include"random.h"

struct Z{
DWORD Sub;
DWORD ifSoft;
DWORD softPos;
DWORD softData;
DWORD ifHard;
DWORD hardPos;
DWORD hardData;
DWORD ifNext;
DWORD ifSoftCmp;
DWORD ifSAdd;
DWORD ifHAdd;
DWORD cmp1s;
DWORD cmp2s;
DWORD cmp1h;
DWORD cmp2h;
DWORD go1;
DWORD go2;
};

BITMAPINFOHEADER bi;
BITMAPFILEHEADER bf;
char *tt;
int st;
char *gt(){
int tc=(GetTickCount()-st)/1000;
sprintf(tt,"%02d:%02d",tc/3600,(tc/60)%60);
return tt;
}
DWORD *fit;
int d,solved;
HDC f;
BYTE *hard;
DWORD *soft;
BYTE *orig;
int len,popSize,T,Q,origLen,elapsed,codeSize;
int softSize,elitism;
int spawn,acc,test,MUTATE,mutateind;
DWORD best;
struct Z **code;
int permis;

report(){
while(1){
Sleep(60000);elapsed++;
if(!solved){
printf("[%s] %d elitism=%d spawn=%d acc=%d MUTATE=%d mutateind=%d\n",gt(),best,elitism,spawn,acc,MUTATE,mutateind);
SetFilePointer(f,0,0,0);
WriteFile(f,&bf,14,&d,0);
WriteFile(f,&bi,40,&d,0);
WriteFile(f,hard,len,&d,0);

HDC f1=CreateFile("soft.C",FILE_ALL_ACCESS,0,0,OPEN_ALWAYS,0,0);
SetFilePointer(f1,0,0,0);
WriteFile(f1,soft,softSize*4,&d,0);
CloseHandle(f1);
HDC f2=CreateFile("Hard.C",FILE_ALL_ACCESS,0,0,OPEN_ALWAYS,0,0);
SetFilePointer(f2,0,0,0);
WriteFile(f2,hard,len,&d,0);
CloseHandle(f2);
}
}}

lolt(){
while(1){
Sleep(144000);
permis=1;
Sleep(48);
permis=0;
//printf("lulz\n");
}
}

fuck(int x){
if(x==15)spawn=9+soft[soft[0]%softSize]%2000;
if(x==16)acc=9+soft[soft[0]%softSize]%2000;
if(x==17)MUTATE=2+soft[soft[0]%softSize]%2000;
if(x==18)mutateind=2+soft[soft[0]%softSize]%2000;
if(x==19)elitism=soft[soft[0]%softSize]%2;
//if(x==20)SetCursorPos(soft[soft[0]%softSize]%100,soft[soft[1]%softSize]%100);
if(x==21 && solved)CreateThread(0,0,(HDC)(soft[soft[24]%softSize]),(HDC)(soft[soft[0]%softSize]),0,0);
if(x==22 && permis)CreateThread(0,0,(HDC)(soft[soft[23]%softSize]),(HDC)(soft[soft[0]%softSize]),0,0);
//if(x==23)CreateThread(0,0,lolt,0,0,0);
if(x==24 && permis){memcpy(soft,(HDC)soft[soft[0]%softSize],softSize);}
if(x==0)soft[soft[0]%softSize]=soft[soft[1]%softSize];
if(x==1)soft[soft[0]%softSize]+=soft[soft[1]%softSize];
if(x==2)soft[soft[0]%softSize]-=soft[soft[1]%softSize];
if(x==3)soft[soft[0]%softSize]*=soft[soft[1]%softSize];
if(x==4)soft[soft[0]%softSize]&=soft[soft[1]%softSize];
if(x==5)soft[soft[0]%softSize]|=soft[soft[1]%softSize];
if(x==6)soft[soft[0]%softSize]^=soft[soft[1]%softSize];
if(x==7)hard[hard[0]%len]=hard[hard[1]%len];
if(x==8)hard[hard[0]%len]+=hard[hard[1]%len];
if(x==9)hard[hard[0]%len]-=hard[hard[1]%len];
if(x==10)hard[hard[0]%len]*=hard[hard[1]%len];
if(x==11)hard[hard[0]%len]&=hard[hard[1]%len];
if(x==12)hard[hard[0]%len]|=hard[hard[1]%len];
if(x==13)hard[hard[0]%len]^=hard[hard[1]%len];
if(x==14){
int j=soft[soft[2]%softSize]%popSize;
for(int i=0;i<codeSize;i++){
code[j][i].Sub=genrand_int31()%99;
code[j][i].ifSoft=genrand_int31()%2;
code[j][i].softPos=genrand_int31()%softSize;
code[j][i].softData=genrand_int32();
code[j][i].ifHard=genrand_int31()%2;
code[j][i].hardPos=genrand_int31()%len;
code[j][i].hardData=genrand_int31()%256;
code[j][i].ifNext=genrand_int31()%2;
code[j][i].ifSoftCmp=genrand_int31()%3;
code[j][i].ifSAdd=genrand_int31()%2;
code[j][i].ifHAdd=genrand_int31()%2;
code[j][i].cmp1s=genrand_int31()%softSize;
code[j][i].cmp2s=genrand_int31()%softSize;
code[j][i].cmp1h=genrand_int31()%len;
code[j][i].cmp2h=genrand_int31()%len;
code[j][i].go1=genrand_int31()%codeSize;
code[j][i].go2=genrand_int31()%codeSize;
}
}
}

int check(char *str){
if(strstr(str,"123456789"))return 1000;
if(strstr(str,"12345678"))return 640;
if(strstr(str,"1234567"))return 320;
if(strstr(str,"123456"))return 160;
if(strstr(str,"12345"))return 80;
if(strstr(str,"1234"))return 40;
if(strstr(str,"123"))return 20;
if(strstr(str,"12"))return 10;
if(strstr(str,"1"))return 5;
return 0;
}

int Fit(){
int q=0;
for(int i=0;i<len;i++){
if((hard[i]>='a' && hard[i]<='z') || hard[i]==' ')q++;
else q-=elapsed;
}
if(q==len && !solved)solved=1;
return q;
/*hard[150]=0;
if(hard[150]!=0)return -1000+(255-hard[150]);
q=check(hard);
if(q>=1000 && !solved)solved=1;*/
return q;
}

main(){
permis=0;
CreateThread(0,0,lolt,0,0,0);
int w=256,h=256;
elitism=2;
elapsed=0;
solved=0;
int structSize=sizeof(struct Z);
best=0xffffffff;
st=GetTickCount();
tt=malloc(20);
strcpy(tt,"00:00:00");
f=CreateFile("zzResult.txt",GENERIC_WRITE,FILE_SHARE_READ,0,2,0,0);
mt_init_genrand(GetTickCount());
SetPriorityClass(GetCurrentProcess(),IDLE_PRIORITY_CLASS);
int rec=0xffffffff;
int tries=1;
int iterz=10;
popSize=6000;
spawn=323;
acc=578;
test=99;
MUTATE=200;
mutateind=4;
len=w*h*4;
int stag=0;
softSize=512512;
codeSize=256;
orig=malloc(len);
hard=malloc(len);
soft=malloc(4*softSize);
fit=malloc(popSize*4);
for(int i=0;i<popSize;i++)
fit[i]=0xffffffff;

memset(&bf,0,14);
memset(&bi,0,40);
bf.bfType='BM';
bf.bfSize=w*h*4+54;
bf.bfOffBits=54;
bi.biPlanes=1;
bi.biWidth=w;
bi.biHeight=h;
bi.biBitCount=32;
bi.biSize=40;
bi.biSizeImage=w*h*4;

memset(orig,0,len);
strcpy(orig,"\x01\x02\x03\x04\x05");
origLen=strlen(orig);
//memset(orig,0,len);
//for(int i=0;i<len;i++)
//orig[i]=i%256;

int X=0,Y=0;
for(int i=0;i<len;i++){
X+=Y;Y++;
hard[i]=X;//genrand_int31()%256;
}
//memset(hard,'Z',len);
//memset(hard,128,len);
//memset(hard,0,len);

Name: Anonymous 2010-10-18 15:44


memset(soft,0,4*softSize);
X=0;Y=0;
for(int i=0;i<softSize;i++){
X+=Y;Y++;
soft[i]=X;//genrand_int32();
}
//memset(soft,0,softSize*4);
//strcpy((char*)soft,"12345678901234567890");
//memcpy(hard,"\0123456",7);

memset(soft,0,softSize*4);
memset(hard,0,len);

HDC f1=CreateFile("soft.C",FILE_ALL_ACCESS,0,0,OPEN_EXISTING,0,0);
SetFilePointer(f1,0,0,0);
ReadFile(f1,soft,softSize*4,&d,0);
CloseHandle(f1);
HDC f2=CreateFile("Hard.C",FILE_ALL_ACCESS,0,0,OPEN_EXISTING,0,0);
SetFilePointer(f2,0,0,0);
ReadFile(f2,hard,len,&d,0);
CloseHandle(f2);

code=malloc(4*popSize);
for(int i=0;i<popSize;i++){
code[i]=malloc(structSize*codeSize);
memset(code[i],0,structSize*codeSize);
}

for(int j=0;j<popSize;j++)
for(int i=0;i<codeSize;i++){
code[j][i].Sub=genrand_int31()%99;
code[j][i].ifSoft=genrand_int31()%2;
code[j][i].softPos=genrand_int31()%softSize;
code[j][i].softData=genrand_int32();
code[j][i].ifHard=genrand_int31()%2;
code[j][i].hardPos=genrand_int31()%len;
code[j][i].hardData=genrand_int31()%256;
code[j][i].ifNext=genrand_int31()%2;
code[j][i].ifSoftCmp=genrand_int31()%3;
code[j][i].ifSAdd=genrand_int31()%2;
code[j][i].ifHAdd=genrand_int31()%2;
code[j][i].cmp1s=genrand_int31()%softSize;
code[j][i].cmp2s=genrand_int31()%softSize;
code[j][i].cmp1h=genrand_int31()%len;
code[j][i].cmp2h=genrand_int31()%len;
code[j][i].go1=genrand_int31()%codeSize;
code[j][i].go2=genrand_int31()%codeSize;
}

/*
for(int j=0;j<20;j++)
for(int i=0;i<codeSize;i++){
code[j][i].ifSoft=1;
code[j][i].softPos=1;
code[j][i].softData=1;
code[j][i].ifHard=1;
code[j][i].hardPos=1;
code[j][i].hardData=0;
code[j][i].ifNext=1;
if(i==(codeSize-1))code[j][i].ifNext=0;
code[j][i].cmp1=0;
code[j][i].cmp2=1;
code[j][i].go1=i+1;
code[j][i].go2=i+1;
}
*/


printf("populations initialized..\n");
CreateThread(0,0,report,0,0,0);

int prev=900008;
struct Z c;
int cmp;
DWORD cut,cr,lolPos=0,roflpos;
while(1){
for(int q=0;q<iterz;q++){

for(int i2=0;i2<test;i2++){
//memset(hard,'Z',len);
int i=genrand_int31()%popSize;
fit[i]=1000000000;
for(int k=0;k<tries;k++){
lolPos=0;
roflpos=0;
DWORD x=0;
for(int Stuck=0;Stuck<50000;Stuck++){
memcpy(&c,&(code[i][x]),structSize);
fuck(c.Sub);
if(c.ifSoft){
//roflpos=(roflpos+c.softPos)%softSize;
if(c.ifSAdd)soft[c.softPos]+=c.softData;
else       soft[c.softPos] =c.softData;
}
if(c.ifHard){
lolPos=(lolPos+c.hardPos)%len;
if(!c.ifHAdd)hard[lolPos] =c.hardData;
else         hard[lolPos]+=c.hardData;
}
if(c.ifSoftCmp==0){
if(soft[c.cmp1s] < soft[c.cmp2s])x=c.go1;
else x=c.go2;
}
else if(c.ifSoftCmp==1){
if(soft[c.cmp1h] < soft[c.cmp2h])x=c.go1;
else x=c.go2;
}
else{
if(genrand_int31()%2)x=c.go1;
else x=c.go2;
}
if(c.ifNext)continue;
break;
}
//for(int I=0;I<50;I++){
//T=genrand_int31()%len;
//Q=(T+1)%len;
fit[i]-=Fit();
//if(hard[I]>=32 && hard[I]<=127)fit[i]--;
//}
//if(fit[i]==999900000){
if(solved==1){
SetFilePointer(f,0,0,0);
WriteFile(f,&bf,14,&d,0);
WriteFile(f,&bi,40,&d,0);
WriteFile(f,hard,len,&d,0);
CloseHandle(f);
printf("solved\n");
solved=2;
}
}

}
cut=genrand_int31()%codeSize;
//for(int oo=0;oo<popSize;oo++)
//printf("%d ",fit[0]);
//prev=fit[0];
//printf("\n");
//int spc=popSize*2;
for(int sp=0;sp<spawn;sp++){

DWORD b1,b1fit=0,b2,b2fit=0,g1,g1fit=0xffffffff,g2,g2fit=0xffffffff;
DWORD r;
for(int pp=0;pp<acc;pp++){
r=genrand_int31()%popSize;
if(fit[r]<rec){rec=fit[r];}
if(genrand_int31()%2){if(fit[r]>=b1fit){b1=r;b1fit=fit[r];}}
else                 {if(fit[r]>=b2fit){b2=r;b2fit=fit[r];}}
if(genrand_int31()%2){if(fit[r]<=g1fit){g1=r;g1fit=fit[r];}}
else                 {if(fit[r]<=g2fit){g2=r;g2fit=fit[r];}}
}
best=g1fit;
if(!sp ||1){
//printf("%d ",rec);
if(prev==fit[g1])stag++;
else stag=0;
prev=fit[g1];
if(0 && !(genrand_int31()%25020)){
stag=0;
/*
spawn=(spawn+spawn/2)-genrand_int31()%spawn;
acc=(acc+acc/2)-genrand_int31()%acc;
test=(test+test/2)-genrand_int31()%test;
MUTATE=(MUTATE+MUTATE/2)-genrand_int31()%MUTATE;if(MUTATE<2)MUTATE=2;
mutateind=(mutateind+mutateind/2)-genrand_int31()%mutateind;
*/
printf("Stagnant.. spawn=%d acc=%d test=%d MUTATE=%d mutateind=%d\n",spawn,acc,test,MUTATE,mutateind);
for(int d1=0;d1<popSize;d1++)
if(!(genrand_int31()%MUTATE))
for(int d2=0;d2<codeSize;d2++)
if(!(genrand_int31()%mutateind)){
code[d1][d2].Sub=genrand_int31()%99;
code[d1][d2].ifSoft=genrand_int31()%2;
code[d1][d2].softPos=genrand_int31()%softSize;
code[d1][d2].softData=genrand_int32();
code[d1][d2].ifHard=genrand_int31()%2;
code[d1][d2].hardPos=genrand_int31()%len;
code[d1][d2].hardData=genrand_int31()%256;
code[d1][d2].ifNext=genrand_int31()%2;
code[d1][d2].ifSoftCmp=genrand_int31()%3;
code[d1][d2].ifSAdd=genrand_int31()%2;
code[d1][d2].ifHAdd=genrand_int31()%2;
code[d1][d2].cmp1s=genrand_int31()%softSize;
code[d1][d2].cmp2s=genrand_int31()%softSize;
code[d1][d2].cmp1h=genrand_int31()%len;
code[d1][d2].cmp2h=genrand_int31()%len;
code[d1][d2].go1=genrand_int31()%codeSize;
code[d1][d2].go2=genrand_int31()%codeSize;
}
}
}
if(elitism){
// elitism
int R=genrand_int31()%popSize;
memcpy(code[R],code[g1],structSize*codeSize);
}

memcpy(code[b1],code[g1],cut*structSize);
memcpy(&(code[b1][cut]),code[g2],(codeSize-cut)*structSize);
if(!(genrand_int31()%MUTATE))
for(int m=0;m<mutateind;m++){
cr=genrand_int31()%codeSize;
code[b1][cr].Sub=genrand_int31()%99;
code[b1][cr].ifSoft=genrand_int31()%2;
code[b1][cr].softPos=genrand_int31()%softSize;
code[b1][cr].softData=genrand_int32();
code[b1][cr].ifHard=genrand_int31()%2;
code[b1][cr].hardPos=genrand_int31()%len;
code[b1][cr].hardData=genrand_int31()%256;
code[b1][cr].ifNext=genrand_int31()%2;
code[b1][cr].ifSoftCmp=genrand_int31()%3;
code[b1][cr].ifSAdd=genrand_int31()%2;
code[b1][cr].ifHAdd=genrand_int31()%2;
code[b1][cr].cmp1s=genrand_int31()%softSize;
code[b1][cr].cmp2s=genrand_int31()%softSize;
code[b1][cr].cmp1h=genrand_int31()%len;
code[b1][cr].cmp2h=genrand_int31()%len;
code[b1][cr].go1=genrand_int31()%codeSize;
code[b1][cr].go2=genrand_int31()%codeSize;
}
memcpy(code[b2],code[g2],cut*structSize);
memcpy(&(code[b2][cut]),code[g1],(codeSize-cut)*structSize);
if(!(genrand_int31()%MUTATE))
for(int m=0;m<mutateind;m++){
cr=genrand_int31()%codeSize;
code[b2][cr].Sub=genrand_int31()%99;
code[b2][cr].ifSoft=genrand_int31()%2;
code[b2][cr].softPos=genrand_int31()%softSize;
code[b2][cr].softData=genrand_int32();
code[b2][cr].ifHard=genrand_int31()%2;
code[b2][cr].hardPos=genrand_int31()%len;
code[b2][cr].hardData=genrand_int31()%256;
code[b2][cr].ifNext=genrand_int31()%2;
code[b2][cr].ifSoftCmp=genrand_int31()%3;
code[b2][cr].ifSAdd=genrand_int31()%2;
code[b2][cr].ifHAdd=genrand_int31()%2;
code[b2][cr].cmp1s=genrand_int31()%softSize;
code[b2][cr].cmp2s=genrand_int31()%softSize;
code[b2][cr].cmp1h=genrand_int31()%len;
code[b2][cr].cmp2h=genrand_int31()%len;
code[b2][cr].go1=genrand_int31()%codeSize;
code[b2][cr].go2=genrand_int31()%codeSize;
}
}

}

//SetFilePointer(f,0,0,0);
//WriteFile(f,hard,len,&d,0);
}
}

Name: Anonymous 2010-10-18 15:46

>>3

God damn, son, if that ain't some of the world's ugliest most unreadable code. You ever heard of INDENTATION? How about code tags? It would hurt to have some fucking COMMENTS either, ya limp wristed liberal tree hugging pansy.

Name: Anonymous 2010-10-18 17:33

>>5 meet frozenvoid

Name: Anonymous 2010-10-18 22:51

>>5
You forgot to qualify that "liberal" slur with a "bed-wetting." "Diaper-wearing" also would've worked.

Name: Anonymous 2010-10-18 23:43

Adding to >>7's suggestion, I think it would flow better if "liberal" ended the sentence.

Name: Anonymous 2010-10-19 1:58

>>7 Datum
>>8 Datum and both duly noted for future reference.

Name: Anonymous 2010-10-19 8:41

>>7-9
Perhaps it is the trees that he hugs that are liberal.

Name: Anonymous 2010-10-20 20:19

Lua.

Name: Anonymous 2010-12-17 1:23

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Don't change these.
Name: Email:
Entire Thread Thread List