Mark castling Rook as non-virgin
authorH.G. Muller <h.g.muller@hccnet.nl>
Thu, 16 May 2013 17:14:47 +0000 (19:14 +0200)
committerH.G. Muller <h.g.muller@hccnet.nl>
Mon, 20 May 2013 09:41:26 +0000 (11:41 +0200)
The Rook was left virgin when castling. This could cause erroneous gating
in variant seirawan. Now the original piece is remembered in a variable rk,
from which it can be restored, while the on-board (moved) Rook wil get the
virginity bit set. Separate storage was preferred over clearing the bit
on take-back, because it allows the same code to also handle other removal
of pieces a a side effect of a move, by setting G to the piece to be removed.

fairymax.c

index 3bd0c69..560f64d 100644 (file)
@@ -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.*/\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,kk=S;\r
- signed char t,p,u,x,y,X,Y,H,B,gt,rg;\r
+ signed char t,p,u,x,y,X,Y,H,B,gt,rg,rk;\r
  struct _*a=A+(J+(k+S)*E&U);                   /* lookup pos. in hash table*/\r
  *sp++=0;\r
  q-=q<e;l-=l<=e;                               /* adj. window: delay bonus */\r
@@ -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  ***/\r
        {v=gt=0;G:                              /* retry move with gating   */\r
         v+=centr[p]?b[x+257]-b[y+257]:0;       /* center positional pts.   */\r
-        if(!(G&S))b[FF]=b[G],v+=50;            /* castling: put R & score  */\r
+        if(G-S)b[FF]=(rk=b[G])|32,v+=50;       /* castling: put R & score  */\r
         b[G]=b[H]=0;b[x]=gt;b[y]=u|32;         /* do move, set non-virgin  */\r
         pl[t&31]-=!!t;                         /* updat victim piece count */\r
         v-=w[p]>0|R<EG?0:20;                   /*** freeze K in mid-game ***/\r
@@ -242,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    */\r
         }                                      /*   K-capt. replies)       */\r
         SHAMAX( pl[k]+=!!t; ) pl[t&31]+=!!t;\r
-        b[G]=b[FF];b[FF]=b[y]=0;b[x]=u;b[H]=t; /* undo move,G can be dummy */\r
+        b[G]=rk;b[FF]=b[y]=0;b[x]=u;b[H]=t;    /* undo move,G can be dummy */\r
        }                                       /*          if non-castling */\r
        if(z&S&&K==I&d>2&v>V&v<l){int *p=ps;char X,Y;\r
         if(Post){\r