Moderator: Andres Valverde
{v=gt=0;G: /* retry move with gating */
v+=centr[p]?b[x+257]-b[y+257]:0; /* center positional pts. */
if(pl[16-k]==1)v*=5; /* drive bare king to corner **********************/
if(!(G&S))b[FF]=b[G],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|R<EG?0:20; /*** freeze K in mid-game ***/
if(p<3) /* pawns: */
{v-=9*((x-2&M||b[x-2]-u)+ /* structure, undefended */
(x+2&M||b[x+2]-u) /* squares plus bias */
+(w[b[x^16]&15]<0)) /*** cling to magnetic K ***/
+(R-76>>2); /* end-game Pawn-push bonus */
b[y]+=V=y+r+1&S?647-p|pm:2*(u&y+16&32);/*upgrade P or convert to Q*/
if(V&makruk)b[y]=u|7,V=480; /* Makruk promotion on 6th */
V>>=sh; /* for Shatranj promo to F */
i+=V; /* promotion / passer bonus */
} if(z&S && GamePtr<6) v+=(rand()>>10&31)-16;
J+=J(0);Z+=J(4)+G-S;
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=R<EG|P-I|d<3||t&&w[p]>0?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;
W(s>q&++C<d); v=s; /* no fail:re-srch unreduced*/
if(v>V&v<l){int *p=sp;
sp=ps+1;
W(*sp++=*p++);
*ps=256*x+y;
}
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: */
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;
sp=ps;
return l;} /* & not in check, signal */
v=m; /* (prevent fail-lows on */
} /* K-capt. replies) */
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 */
} /* if non-castling */
L=8;W(L--)b[16*L+K+257]=(K-BW/2)*(K-BW/2)+(L-3.5)*(L-3.5)-1.3*(L-3.5)*(K-BW/2); /* center-pts table */
pst=k+16&bare?513:257;
v+=centr[p]?b[x+pst]-b[y+pst]:0; /* center positional pts. */
void Mating()
{
char p,w,S,x,y;
w=N=0;
K=BW;W(K--)
{L=8;W(L--)p=b[16*L+K],N+=!!p,w+=p&16;} /* count total and white pieces */
if(w==16)bare=32;if(16*N-w==16)bare=16; /* order multiplying center score of bare King */
if(bare&&N==5){ /* can be KNFFK */
N=S=0,w=-1;
K=BW;W(K--)
{L=8;W(L--){p=b[16*L+K];if(p&&p==bare+19)x=K,y=L;p&=15,N+=p==11,S+=p==7,w+=(p==7)&(L^K);}} /* count Knights and Ferzes */
w=(N&S==2)*w; /* if exactly 1 N and 2 F, set w = +1 or -1 depending on color of F, 0 otherwise */
K=BW;W(K--)
{L=8;W(L--)b[16*L+K+257]=(K-BW/2)*(K-BW/2)+(L-3.5)*(L-3.5)+(x-K)*(x-K)+(y-L)*(y-L), /* center-pts table */
b[16*L+K+513]=(4-2*w*w)*((K-BW/2)*(K-BW/2)+(L-3.5)*(L-3.5)-2*w*(L-3.5)*(K-BW/2)); /* bare-king table */
}}
}
Mating();
N=0;K=I;
if (D(Side,-I,I,Q,O,LL|S,3)==I) {
Return to Winboard and related Topics
Users browsing this forum: No registered users and 31 guests