From 518211a4310898171d8bb4e0a865f97e9cbda28a Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Fri, 15 Jan 2010 22:01:58 +0100 Subject: [PATCH] Bugfix on new castling method Copying the Rook square in stead of growing a Rook was done after the Rook square had already been cleared. In addition the Rook ended up on d1 for e1b1 castling. To fix that, the alternated step vector had to be calculated in advance, before being sure it would be applied, to be available in the castling code. The variable v is now used as a temporary for that, as it was available after the score is minimaxed. --- fairymax.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diff --git a/fairymax.c b/fairymax.c index a367ca3..92bf8a9 100644 --- a/fairymax.c +++ b/fairymax.c @@ -184,8 +184,8 @@ int k,q,l,e,E,z,n; /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/ v=d-1?e:i-p; /*** MVV/LVA scoring if d=1**/ if(d-!t>1) /*** all captures if d=2 ***/ {v=centr[p]?b[x+257]-b[y+257]:0; /* center positional pts. */ + if(!(G&S))b[FF]=b[G],v+=50; /* castling: put R & score */ b[G]=b[H]=b[x]=0;b[y]=u|32; /* do move, set non-virgin */ - if(!(G&S))b[FF]=k+6,v+=50; /* castling: put R & score */ v-=w[p]>0|R2&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*/ + } + 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; + s=t;v=r^flag>>12; /* calc. alternated vector */ 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]^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 */ + ||b[G^1]|b[G^2]|b[FF=y+v-r]) /* no 2 empty sq. next to R */ )t+=flag&4; /* fake capt. for nonsliding*/ else F=y; /* enable e.p. */ if(s&&flag&8)t=0,flag^=flag>>4&15; /* hoppers go to next phase */ if(!(flag&S)) /* zig-zag piece? */ - r^=flag>>12,flag^=flag>>4&15; /* alternate vector & mode */ + r=v,flag^=flag>>4&15; /* alternate vector & mode */ }W(!t); /* if not capt. continue ray*/ }} if((++x&15)>=BW)x=x+16&112; /* next sqr. of board, wrap */ -- 1.7.0.4