X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=fairymax.c;h=aa845dcc33f26ac0f55ad27b019ef586d65bbcde;hb=dcb0657b9bf755387c949ae37ca12402ac08eb13;hp=8b7b45a55d6a059d2917a346be4f6ced32dab83f;hpb=01c98981a223a4534f0fc1e7fceefd522a3b74db;p=fairymax.git diff --git a/fairymax.c b/fairymax.c index 8b7b45a..aa845dc 100644 --- a/fairymax.c +++ b/fairymax.c @@ -18,7 +18,7 @@ /*****************************************************************/ #define MULTIPATH -#define VERSION "4.8M" +#define VERSION "4.8N" #include #include @@ -92,7 +92,7 @@ int GameNr; int Resign; int Threshold = 800; int Score; -char piecename[32], piecetype[32]; +char piecename[32], piecetype[32], blacktype[32]; char *inifile = INI_FILE; int Ticks, tlim, Setup, SetupQ; @@ -122,6 +122,9 @@ T[4104], /* hash translation table */ centr[32], n[]=".*XKNBRQEWFMACHG?x+knbrqewfmachg"; /* piece symbols on printout*/ +int pv[10000],*sp=pv; // triangular array +int margin; + pboard() {int i; i=-1;W(++i<128)printf(" %c",(i&15)==BW&&(i+=15-BW)?10:n[b[i]&31]); @@ -131,9 +134,10 @@ pboard() 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; + int j,r,m,v,d,h,i,F,G,P,V,f=J,g=Z,C,s,flag,FF,*ps=sp; signed char t,p,u,x,y,X,Y,H,B; struct _*a=A+(J+(k+S)*E&U-1); /* lookup pos. in hash table*/ + *sp++=0; q-=qD;m=a->V;X=a->F;Y=a->Y; /* resume at stored depth */ if(a->K-Z|z&S | /* miss: other pos. or empty*/ @@ -194,12 +198,18 @@ int k,q,l,e,E,z,n; /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/ J+=J(0);Z+=J(4)+G-S; SHAMAX( pl[k]-=!!t; ) /* count pieces per side */ v+=e+i;V=m>q?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=R2|v>V?-D(16-k,-l,-V,-v,/*** futility, recursive eval. of reply */ F,y&255,C):v; W(s>q&++CV&vD=99;a->V=0; /* lock game in hash as draw*/ R-=i/FAC; /*** total captd material ***/ Fifty = t|p<3?0:Fifty+1; + sp=ps; return l;} /* & not in check, signal */ v=m; /* (prevent fail-lows on */ } /* K-capt. replies) */ @@ -215,14 +226,21 @@ int k,q,l,e,E,z,n; /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/ SHAMAX( pl[k]+=!!t; ) b[G]=k+6;b[FF]=b[y]=0;b[x]=u;b[H]=t; /* undo move,G can be dummy */ } /* if non-castling */ - if(v>m) /* new best, update max,best*/ + if(z&S&&Post&K==I&d>2&v>V&v>8;Y=*p++; + printf(" %c%c%c%c",'a'+(X&15),'8'-(X>>4),'a'+(Y&15),'8'-(Y>>4&7));} + printf("\n");fflush(stdout); + } if(v>m) /* new best, update max,best*/ m=v,X=x,Y=y|S&F; /* mark non-double with S */ if(h){h=0;goto A;} /* redo after doing old best*/ } s=t; if(flag&15^4|u&32|| /* no double or moved before*/ p>2&& /* no P & no lateral K move,*/ - (b[G=r<0?x&~15:BW-1|x&112]-k-6 /* no virgin R in corner G, */ + ((b[G=r<0?x&~15:BW-1|x&112]^32)<33 /* no virgin R in corner G, */ ||b[G^1]|b[G^2]|b[FF=r<0?G+3:G-2]) /* no 2 empty sq. next to R */ )t+=flag&4; /* fake capt. for nonsliding*/ else F=y; /* enable e.p. */ @@ -237,13 +255,9 @@ C:FMAX( m=m+I|P==I?m:(X=Y=0); ) /* if stalemate, draw-score */ if(a->D<99) /* protect game history */ a->K=Z,a->V=m,a->D=d,a->X=X, /* always store in hash tab */ a->F=8*(m>q)|S*(mY=Y; /* move, type (bound/exact),*/ - if(z&S&&Post){ - printf("%2d ",d-2); - printf("%6d ",m); - printf("%8d %10d %c%c%c%c\n",(GetTickCount()-Ticks)/10,N, - 'a'+(X&15),'8'-(X>>4),'a'+(Y&15),'8'-(Y>>4&7)),fflush(stdout); - }} /* encoded in X S,8 bits */ + } /* encoded in X S,8 bits */ if(z&4*S)K=X,L=Y&~S; + sp=ps; return m+=m='a'; - piecetype[c&31]=i; piecename[i]=c&31; + blacktype[c&31]=i; piecename[i]=c&31; + if(piecetype[c&31]==0) piecetype[c&31]=i; // only first } j++; o[j]=0; /* printf("# c='%c' i=%d od[i]=%d j=%d (%3d,%8x)\n",c?c:' ',i,od[i],j,o[j-1],of[j-1]); /**/ @@ -667,6 +683,7 @@ int main(int argc, char **argv) inifile = filename; continue; } if(sscanf(line+7, "Clear Hash") == 1) for(i=0; iK = 0; + if(sscanf(line+7, "MultiVariation Margin=%d", &margin) == 1) continue; continue; } if (!strcmp(command, "go")) { @@ -749,7 +766,7 @@ int main(int argc, char **argv) && line[1] >= 'a' && line[1] <= 'a'+BW-1 && line[2] >= '1' && line[2] <= '0'+BH) { m = line[1]-16*line[2]+799; - switch(p = piecetype[line[0]&31]) + switch(p = (color == WHITE ? piecetype : blacktype)[line[0]&31]) { case 1: case 2: @@ -759,23 +776,16 @@ int main(int argc, char **argv) else b[m]=(m&0x70)==0x10?18:50, Q+=w[2]; break; - case 3: // can castle, normally King - b[m]=3+color+32; - if(m==BW>>1 && color==BLACK || - m==0x70+(BW>>1) && color==WHITE) - b[m] -= 32; - break; - case 6: // can castle, normally Rook - b[m]=6+color+32; - if((m==0x00 || m==BW-1 ) && color==BLACK || - (m==0x70 || m==0x6F+BW) && color==WHITE) - b[m] -= 32; - Q+=w[6]; R+=w[6]/FAC; - break; default: - b[m]=p+color; - Q+=w[p]; R+=w[p]/FAC; - case 0: // undefined piece, ignore + b[m]=p+color+32; // assume non-virgin + if(w[p]<0) { // Royal piece on original square: virgin + if(color==BLACK && m<0x10 && p==oo[m+16] || + color==WHITE && m>0x6F && p==oo[m-0x70]) b[m] -= 32; + } else { Q+=w[p]; R+=w[p]/FAC; } + if((m==0x00 || m==BW-1 ) && color==BLACK && p==oo[m+16] || + (m==0x70 || m==0x6F+BW) && color==WHITE && p==oo[m-0x70]) + b[m] &= ~32; // corner piece as in original setup: virgin + case 0: // undefined piece, ignore break; } pl[BLACK+WHITE-color]++; @@ -794,7 +804,7 @@ int main(int argc, char **argv) m = line[0]<'a' | line[0]>='a'+BW | line[1]<'1' | line[1]>='1'+BH | line[2]<'a' | line[2]>='a'+BW | line[3]<'1' | line[3]>='1'+BH; if(line[4] == '\n') line[4] = piecename[7]; - PromPiece = 7 - piecetype[line[4]&31]; + PromPiece = 7 - (Side == WHITE ? piecetype : blacktype)[line[4]&31]; if(PromPiece == 7) PromPiece = 0; {char *c=line; K=c[0]-16*c[1]+799;L=c[2]-16*c[3]+799; } if (m)