Allow castling with any original corner piece
authorH.G. Muller <h.g.muller@hccnet.nl>
Fri, 15 Jan 2010 10:05:25 +0000 (11:05 +0100)
committerH.G. Muller <h.g.muller@hccnet.nl>
Fri, 15 Jan 2010 10:05:25 +0000 (11:05 +0100)
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
fairymax.c

index 4c75448..1eeb76a 100644 (file)
@@ -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.\r
+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.\r
 
 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
index c166ee1..6ccbc9c 100644 (file)
@@ -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;\r
       if(flag&15^4|u&32||                      /* no double or moved before*/\r
          p>2&&                                 /* no P & no lateral K move,*/\r
-         (b[G=r<0?x&~15:BW-1|x&112]-k-6        /* no virgin R in corner G, */\r
+         ((b[G=r<0?x&~15:BW-1|x&112]^32)<33    /* no virgin R in corner G, */\r
          ||b[G^1]|b[G^2]|b[FF=r<0?G+3:G-2])    /* no 2 empty sq. next to R */\r
         )t+=flag&4;                            /* fake capt. for nonsliding*/\r
       else F=y;                                /* enable e.p.              */\r
@@ -776,23 +776,16 @@ int main(int argc, char **argv)
                                             else b[m]=(m&0x70)==0x10?18:50,\r
                                                  Q+=w[2];\r
                                             break;\r
-                                        case 3: // can castle, normally King\r
-                                            b[m]=3+color+32;\r
-                                            if(m==BW>>1        && color==BLACK ||\r
-                                               m==0x70+(BW>>1) && color==WHITE)\r
-                                                b[m] -= 32;\r
-                                            break;\r
-                                        case 6: // can castle, normally Rook\r
-                                            b[m]=6+color+32;\r
-                                            if((m==0x00 || m==BW-1   ) && color==BLACK ||\r
-                                               (m==0x70 || m==0x6F+BW) && color==WHITE)\r
-                                                b[m] -= 32;\r
-                                            Q+=w[6]; R+=w[6]/FAC;\r
-                                            break;\r
                                         default:\r
-                                            b[m]=p+color;\r
-                                            Q+=w[p]; R+=w[p]/FAC;\r
-                                                   case 0: // undefined piece, ignore\r
+                                            b[m]=p+color+32; // assume non-virgin\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;
+                                           } 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
+                                                b[m] &= ~32; // corner piece as in original setup: virgin\r
+                                       case 0: // undefined piece, ignore\r
                                             break;\r
                                         }\r
                                         pl[BLACK+WHITE-color]++;\r