others cannot be indicated at all, but they could still occur in the\r
initial setup (where you specify them by number, not letter).\r
\r
+Pieces with negative values are considered royal. If one side has more than\r
+one royal piece of the same type, he loses if the _last_ one is captured,\r
+with the special rule that he is not allowed to leave more than one of\r
+them under attack. This means the 'spare' royal pieces can be sacrificed,\r
+and the exchange value assumed for them will be the absolute value of what\r
+you define for them.\r
+\r
NOTE: piece value 181 for piece 7 is reserved for Makruk, and enables\r
promotion on the 6th rank. Do not use it in other variants.\r
\r
D(k,q,l,e,E,z,n) /* recursive minimax search, k=moving side, n=depth*/\r
int k,q,l,e,E,z,n; /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/\r
{ /* e=score, z=prev.dest; J,Z=hashkeys; return score*/\r
- int j,r,m,v,d,h,i,F,G,P,V,f=J,g=Z,C,s,flag,FF,*ps=sp;\r
+ int j,r,m,v,d,h,i,F,G,P,V,f=J,g=Z,C,s,flag,FF,*ps=sp,kk=S;\r
signed char t,p,u,x,y,X,Y,H,B;\r
struct _*a=A+(J+(k+S)*E&U-1); /* lookup pos. in hash table*/\r
*sp++=0;\r
if(flag&1+!t) /* mode (capt/nonc) allowed?*/\r
{if(t&&(t&16)==k)break; /* capture own */\r
i=w[t&15]+((t&192)>>sh); /* value of capt. piece t */\r
- if(i<0)m=I,d=98; /* K capture */\r
+ if(i<0&&(pl[t&31]<2||kk!=H&kk!=S||(kk=H,i=-i,0)))m=I,d=98;/* K capture, duple check */\r
if(m>=l&d>1)goto C; /* abort on fail high */\r
v=d-1?e:i-p; /*** MVV/LVA scoring if d=1**/\r
if(d-!t>1) /*** all captures if d=2 ***/\r
if(w[p]<0) { // Royal piece on original square: virgin
if(color==BLACK && m<0x10 && p==oo[m+16] ||\r
color==WHITE && m>0x6F && p==oo[m-0x70]) b[m] -= 32;
+ Q-=w[p]; // assume value was flipped to indicate royalty
+ if(pl[p+color])R-=w[p]/FAC; // capturable King, add to material
} else { Q+=w[p]; R+=w[p]/FAC; }
if((m==0x00 || m==BW-1 ) && color==BLACK && p==oo[m+16] ||\r
(m==0x70 || m==0x6F+BW) && color==WHITE && p==oo[m-0x70])\r