Check in Pair-o-Max web page
[fairymax.git] / fairymax.c
index bdb76e4..b5f0545 100644 (file)
@@ -219,7 +219,7 @@ int k,q,l,e,ev,E,z,n;    /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/
         re=v>>Fac(v>>15&16^k);  /* Reduce eval if drawish for leading side */\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|re>V?-D(16-k,-l,-V,/*** futility, recursive eval. of reply */\r
                                   -v,-re,F,y&255,C):re;\r
@@ -232,8 +232,9 @@ int k,q,l,e,ev,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
-           pl[u&31]--,pl[prom&31]++,Z+=PromPiece;/*piece & invalidate hash */\r
+          if(b[y]-u&15)prom=b[y]-=PromPiece,   /* (under-)promotion:       */\r
+           Q-=abs(w[prom&=31])-w[p]-6*S,       /*  correct piece & score & */\r
+           pl[u&31]--,pl[prom]++,Z+=PromPiece; /*  count & 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
@@ -299,7 +300,7 @@ Fac(int k)
    h=pl[k]-pl[17-k]-pl[18-k];                  /* his pieces (incl. King)  */\r
    if(h<2)r=0;                                 /* bare K easy even w.o. P  */\r
    j=h-n;                                      /* defenders after sac for P*/\r
-   if(j<3&&j--){                               /* can sac, <= 1 piece left */\r
+   if(j<3&&j-->0){                             /* can sac, <= 1 piece left */\r
     i=18-k;W(!pl[++i]);                        /* get lowest piece         */\r
     e=abs(w[i--])*n;                           /* sac for Pawn (if any)    */\r
     W(h>1)h-=pl[++i],e-=pl[i]*w[i];            /* total value his remaining*/\r