From 7668593a029282d0657102158ecbfdd7d50d1471 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Thu, 14 Jan 2010 23:18:36 +0100 Subject: [PATCH] Keep PV in triangular array, and add multi-PV --- fairymax.c | 32 ++++++++++++++++++++++++-------- 1 files changed, 24 insertions(+), 8 deletions(-) diff --git a/fairymax.c b/fairymax.c index 8b7b45a..02e3a09 100644 --- a/fairymax.c +++ b/fairymax.c @@ -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,7 +226,14 @@ 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&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*/ } @@ -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+=mK = 0; + if(sscanf(line+7, "MultiVariation Margin=%d", &margin) == 1) continue; continue; } if (!strcmp(command, "go")) { -- 1.7.0.4