From 53a644a2c385aa2476f0d171ce997c818dfb7639 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Fri, 15 Jan 2010 11:05:25 +0100 Subject: [PATCH] Allow castling with any original corner piece Before, castling was only possible with piece type 6, but this restrction is now lifted, and castling is accepted if the type of the piece in the corner corresponds to that specified in the initial setup. For setup positions the rules for the WB-prtocol edit command are applied with respect to this setup: a royal piece or a corner piece that starts in the opening position is assumed to not have moved. --- data/fmax.ini | 12 ++++++------ fairymax.c | 27 ++++++++++----------------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/data/fmax.ini b/data/fmax.ini index 4c75448..1eeb76a 100644 --- a/data/fmax.ini +++ b/data/fmax.ini @@ -141,12 +141,12 @@ and the 2nd and 7th rank of the opening setup will be filled with them. These pieces will automatically promote to piece number 7 when they reach last rank. So in normal Chess, piece 7 should be programmed as Queen. -Castling currently can be done only with a piece number 6 in the corner, -so in normal Chess you should program piece 6 as Rook. Any royal piece -can in principle castle. (Subject to the normal restrictions on castling, -i.e. not passing through check etc.) If you don't want that, remove the -castling moves from the King desription. If the castling initiator does -not start in a central file, the results are currently undefined. +Castling can be done only with the original corner piece as specified +by line 2 and 3. Any royal piece can in principle castle. (Subject to +the normal restrictions on castling, i.e. not passing through check etc.) +If you don't want that, remove the castling moves from the King description. +If the castling initiator does not start in a central file, the results are +currently undefined. Most variant definitions can be seen at the end of this file. Other lines in this file (i.e. those not recognized as belonging to a diff --git a/fairymax.c b/fairymax.c index c166ee1..6ccbc9c 100644 --- a/fairymax.c +++ b/fairymax.c @@ -240,7 +240,7 @@ int k,q,l,e,E,z,n; /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/ s=t; 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]-k-6 /* no virgin R in corner G, */ + ((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 */ )t+=flag&4; /* fake capt. for nonsliding*/ else F=y; /* enable e.p. */ @@ -776,23 +776,16 @@ int main(int argc, char **argv) else b[m]=(m&0x70)==0x10?18:50, Q+=w[2]; break; - case 3: // can castle, normally King - b[m]=3+color+32; - if(m==BW>>1 && color==BLACK || - m==0x70+(BW>>1) && color==WHITE) - b[m] -= 32; - break; - case 6: // can castle, normally Rook - b[m]=6+color+32; - if((m==0x00 || m==BW-1 ) && color==BLACK || - (m==0x70 || m==0x6F+BW) && color==WHITE) - b[m] -= 32; - Q+=w[6]; R+=w[6]/FAC; - break; default: - b[m]=p+color; - Q+=w[p]; R+=w[p]/FAC; - case 0: // undefined piece, ignore + b[m]=p+color+32; // assume non-virgin + if(w[p]<0) { // Royal piece on original square: virgin + if(color==BLACK && m<0x10 && p==oo[m+16] || + color==WHITE && m>0x6F && p==oo[m-0x70]) b[m] -= 32; + } else { Q+=w[p]; R+=w[p]/FAC; } + if((m==0x00 || m==BW-1 ) && color==BLACK && p==oo[m+16] || + (m==0x70 || m==0x6F+BW) && color==WHITE && p==oo[m-0x70]) + b[m] &= ~32; // corner piece as in original setup: virgin + case 0: // undefined piece, ignore break; } pl[BLACK+WHITE-color]++; -- 1.7.0.4