X-Git-Url: http://winboard.nl/cgi-bin?p=fairymax.git;a=blobdiff_plain;f=fairymax.c;h=f20bb1f536678ae6f55f3af2efedbc859105a161;hp=15a5ce542683134c30c6d6acc40f3c8fe21f0013;hb=d0e4774e9509e069ef252a071be2bdd497c810dd;hpb=804ec8ebc971e4e92c96e7209df3f0743a36a70b diff --git a/fairymax.c b/fairymax.c index 15a5ce5..f20bb1f 100644 --- a/fairymax.c +++ b/fairymax.c @@ -18,7 +18,7 @@ /*****************************************************************/ #define MULTIPATH -#define VERSION "4.8S" +#define VERSION "4.8T" #include #include @@ -100,7 +100,7 @@ int Post; int Fifty; int GameNr; int Resign; -int Cambodian; +char Cambodian[80] = "makruk"; int Threshold = 800; int Score; int makruk; @@ -149,7 +149,7 @@ D(k,q,l,e,E,z,n) /* recursive minimax search, k=moving side, n=depth*/ int k,q,l,e,E,z,n; /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/ { /* e=score, z=prev.dest; J,Z=hashkeys; return score*/ int j,r,m,v,d,h,i,F,G,P,V,f=J,g=Z,C,s,flag,FF,*ps=sp,kk=S; - signed char t,p,u,x,y,X,Y,H,B,gt; + signed char t,p,u,x,y,X,Y,H,B,gt,rg,rk; struct _*a=A+(J+(k+S)*E&U); /* lookup pos. in hash table*/ *sp++=0; q-=q>10&3; /* (x,y)=move, (F,G)=castl.R*/ do{ /* y traverses ray, or: */ H=y=h?Y^h:y+r; /* sneak in prev. best move */ if(flag&1<<8)H=y=(y&15)>13?y+BW:(y&15)>=BW?y-BW:y; /* cylinder board */ @@ -199,7 +199,7 @@ int k,q,l,e,E,z,n; /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/ if(d-!t>1) /*** all captures if d=2 ***/ {v=gt=0;G: /* retry move with gating */ v+=centr[p]?b[x+257]-b[y+257]:0; /* center positional pts. */ - if(!(G&S))b[FF]=b[G],v+=50; /* castling: put R & score */ + if(G-S)b[FF]=(rk=b[G])|32,v+=50; /* castling: put R & score */ b[G]=b[H]=0;b[x]=gt;b[y]=u|32; /* do move, set non-virgin */ pl[t&31]-=!!t; /* updat victim piece count */ v-=w[p]>0|Rq?m:q; /*** new eval & alpha ****/ if(z&S)V=m-margin>q?m-margin:q; /* multiPV */ C=d-1-(d>5&p>2&!t&!h); /* nw depth, reduce non-cpt.*/ - C=R0?C:d; /* extend 1 ply if in-check */ do s=C>2|v>V?-D(16-k,-l,-V,-v,/*** futility, recursive eval. of reply */ F,y&255,C):v; @@ -231,8 +231,9 @@ int k,q,l,e,E,z,n; /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/ if(z&S&&K-I) /* move pending: check legal*/ {if(v+I&&x==K&y==L>==GT) /* if move found */ {Q=-e-i;O=F;LL=L;prom=gt; - if(b[y]-u&15)prom=b[y]-=PromPiece, /* under-promotion, correct */ - Z+=PromPiece; /* piece & invalidate hash */ + if(b[y]-u&15)prom=b[y]-=PromPiece, /* (under-)promotion: */ + Q-=abs(w[prom&=15])-w[p]-(6*S>>sh), /* correct piece & score & */ + Z+=PromPiece; /* invalidate hash */ a->D=99;a->V=0; /* lock game in hash as draw*/ R-=i/FAC; /*** total captd material ***/ Fifty = t|p<3?0:Fifty+1; @@ -241,7 +242,7 @@ int k,q,l,e,E,z,n; /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/ v=m; /* (prevent fail-lows on */ } /* K-capt. replies) */ SHAMAX( pl[k]+=!!t; ) pl[t&31]+=!!t; - b[G]=b[FF];b[FF]=b[y]=0;b[x]=u;b[H]=t; /* undo move,G can be dummy */ + b[G]=rk;b[FF]=b[y]=0;b[x]=u;b[H]=t; /* undo move,G can be dummy */ } /* if non-castling */ if(z&S&&K==I&d>2&v>V&v>4&15; /* hoppers go to next phase */ - if(!(flag&S)) /* zig-zag piece? */ + if(--rg<0&!(flag&S)) /* zig-zag piece? (w. delay)*/ r=v,flag^=flag>>4&15; /* alternate vector & mode */ }W(!t); /* if not capt. continue ray*/ }} @@ -341,6 +342,11 @@ int PrintResult(int s) } differs: ; } + + + + + K=I; cnt = D(s,-I,I,Q,O,LL|4*S,3); #ifdef SHATRANJ @@ -437,7 +443,7 @@ void PrintVariants(int combo) while((c = fgetc(f)) != EOF && c != '\n'); if(c == EOF) break; total++; - if(combo == (strstr(buf, "fairy/") != buf)) continue; + if(*buf < 'a' || combo == (strstr(buf, "fairy/") != buf)) continue; if(combo && count == 0) strcpy(selectedFairy, buf); if(count++) printf(combo ? " /// " : ","); printf("%s", combo ? buf+6 : buf); @@ -454,7 +460,7 @@ void PrintOptions() printf("feature option=\"Ini File -file %s\"\n", inifile); printf("feature option=\"Multi-PV Margin -spin %d 0 1000\"\n", margin); printf("feature option=\"Variant fairy selects -combo "); PrintVariants(1); printf("\"\n"); - printf("feature option=\"Cambodian Makruk rules -check %d\"\n", Cambodian); + printf("feature option=\"Makruk rules -combo makruk /// Cambodian /// Ai-wok\"\n"); printf("feature option=\"Dummy Slider Example -slider 20 0 100\"\n"); printf("feature option=\"Dummy String Example -string happy birthday!\"\n"); printf("feature option=\"Dummy Path Example -path .\"\n"); @@ -464,7 +470,7 @@ void PrintOptions() void LoadGame(char *name) { - int i, j, ptc, count=0; char c, buf[80], pieceToChar[80]; + int i, j, ptc=0, count=0; char c, buf[80], pieceToChar[80], parent[80]; static int currentVariant; FILE *f; @@ -479,10 +485,10 @@ void LoadGame(char *name) gating = succession = 0; if(name != NULL) { /* search for game name in definition file */ - if(!strcmp(name, "makruk") && Cambodian) name = "cambodian"; else + if(!strcmp(name, "makruk")) name = Cambodian; else if(!strcmp(name, "fairy")) name = selectedFairy; gating = !strcmp(name, "seirawan"); - while((ptc=fscanf(f, "Game: %s # %s", buf, pieceToChar))==0 || strcmp(name, buf) ) { + while((ptc=fscanf(f, "Game: %s # %s # %s", buf, pieceToChar, parent))==0 || strcmp(name, buf) ) { while((c = fgetc(f)) != EOF && c != '\n'); count++; if(c == EOF) { @@ -497,6 +503,7 @@ void LoadGame(char *name) /* We have found variant, or if none specified, are at beginning of file */ if(fscanf(f, "%dx%d", &BW, &BH)!=2 || BW>12 || BH!=8) { printf("telluser unsupported board size %dx%d\n",BW,BH); exit(0); } + makruk = 0; if(fscanf(f, "=%d", &i)) makruk=64; // new method to indicate deviant zone depth (for now assumes 3) for(i=0; i 1) { // setup board in GUI, by sending it pieceToCharTable and FEN + if(ptc == 2) printf("setup (%s) ", pieceToChar); + else printf("setup (%s) %dx%d+0_%s ", pieceToChar, BW, BH, parent); for(i=0; i>4), 'a'+(L&15),'0'+BH-(L>>4)); - if(prom)printf("%c",piecename[prom&15]+'a'-1); + if(prom)printf("%c",piecename[prom]+'a'-1); printf("\n"); /* time-control accounting */ @@ -745,7 +754,7 @@ int main(int argc, char **argv) if(sscanf(line+7, "Clear Hash%c", &c) == 1) for(i=0; i<=U; i++) A->K = 0; if(sscanf(line+7, "MultiVariation Margin=%d", &margin) == 1) continue; if(sscanf(line+7, "Variant fairy selects=%s", selectedFairy+6) == 1) continue; - if(sscanf(line+7, "Cambodian Makruk rules=%d", &Cambodian) == 1) continue; + if(sscanf(line+7, "Makruk rules=%s", Cambodian) == 1) continue; continue; } if (!strcmp(command, "go")) { @@ -898,6 +907,8 @@ int main(int argc, char **argv) CopyBoard(HistPtr=HistPtr+1&1023); if(PrintResult(Side)) Computer = EMPTY; } + } } + return 0; }