Let make dist also create file with md5 sums
[fairymax.git] / fairymax.c
index c166ee1..b5086d5 100644 (file)
@@ -92,6 +92,7 @@ int GameNr;
 int Resign;\r
 int Threshold = 800;\r
 int Score;\r
+int makruk;\r
 char piecename[32], piecetype[32], blacktype[32];\r
 char *inifile = INI_FILE;\r
 \r
@@ -192,6 +193,7 @@ int k,q,l,e,E,z,n;      /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/
               +(w[b[x^16]&15]<0))              /*** cling to magnetic K ***/\r
               +(R-76>>2);                      /* end-game Pawn-push bonus */\r
          b[y]+=V=y+r+1&S?647-p:2*(u&y+16&32);  /* upgrade P or convert to Q*/\r
+         if(V&makruk)b[y]=u|7,V=480;           /* Makruk promotion on 6th  */\r
          V>>=sh;                               /* for Shatranj promo to F  */\r
          i+=V;                                 /* promotion / passer bonus */\r
         } if(z&S && GamePtr<6) v+=(rand()>>10&31)-16;\r
@@ -226,7 +228,7 @@ int k,q,l,e,E,z,n;      /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/
         SHAMAX( pl[k]+=!!t; )\r
         b[G]=k+6;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&&Post&v>V&v<l){int *p=ps;char X,Y;\r
+       if(z&S&&Post&K==I&d>2&v>V&v<l){int *p=ps;char X,Y;\r
         printf("%2d ",d-2);\r
         printf("%6d ",v);\r
         printf("%8d %10d",(GetTickCount()-Ticks)/10,N);\r
@@ -240,7 +242,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
@@ -469,6 +471,7 @@ int LoadGame(char *name)
 \r
         fclose(f);\r
        sh = w[7] < 250 ? 3 : 0;\r
+       makruk = w[7]==181 ? 64 : 0; // w[7] is used as kludge to enable makruk promotions\r
 }\r
 \r
 int main(int argc, char **argv)\r
@@ -776,23 +779,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