Fix check extension
[fairymax.git] / fairymax.c
index 15a5ce5..769da7f 100644 (file)
@@ -218,7 +218,7 @@ int k,q,l,e,E,z,n;      /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/
         v+=e+i;V=m>q?m:q;                      /*** new eval & alpha    ****/\r
         if(z&S)V=m-margin>q?m-margin:q;        /* multiPV                  */\r
         C=d-1-(d>5&p>2&!t&!h);                 /* nw depth, reduce non-cpt.*/\r
-        C=R<EG|P-I|d<3||t&&p-3?C:d;            /* extend 1 ply if in-check */\r
+        C=R<EG|P-I|d<3||t&&w[p]>0?C:d;         /* extend 1 ply if in-check */\r
         do\r
          s=C>2|v>V?-D(16-k,-l,-V,-v,/*** futility, recursive eval. of reply */\r
                                      F,y&255,C):v;\r
@@ -231,8 +231,9 @@ int k,q,l,e,E,z,n;      /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/
         if(z&S&&K-I)                           /* move pending: check legal*/\r
         {if(v+I&&x==K&y==L&gt==GT)             /*   if move found          */\r
          {Q=-e-i;O=F;LL=L;prom=gt;\r
-          if(b[y]-u&15)prom=b[y]-=PromPiece,   /* under-promotion, correct */\r
-                       Z+=PromPiece;           /*  piece & invalidate hash */\r
+          if(b[y]-u&15)prom=b[y]-=PromPiece,   /* (under-)promotion:       */\r
+           Q-=abs(w[prom&=15])-w[p]-6*S,       /*  correct piece & score & */\r
+                       Z+=PromPiece;           /*  invalidate hash         */\r
           a->D=99;a->V=0;                      /* lock game in hash as draw*/\r
           R-=i/FAC;                            /*** total captd material ***/\r
           Fifty = t|p<3?0:Fifty+1;\r
@@ -582,7 +583,7 @@ int main(int argc, char **argv)
                             printf("move ");\r
                             printf("%c%c%c%c",'a'+(K&15),'0'+BH-(K>>4),\r
                                           'a'+(L&15),'0'+BH-(L>>4));\r
-                           if(prom)printf("%c",piecename[prom&15]+'a'-1);\r
+                           if(prom)printf("%c",piecename[prom]+'a'-1);\r
                             printf("\n");\r
 \r
                             /* time-control accounting */\r