Keep count of all on-board piece types
authorH.G. Muller <h.g.muller@hccnet.nl>
Mon, 1 Nov 2010 12:27:17 +0000 (13:27 +0100)
committerH.G. Muller <h.g.muller@hccnet.nl>
Mon, 1 Nov 2010 12:27:17 +0000 (13:27 +0100)
The array pl[] is used to keep track of the number of pieces of each
type. It is updated when the piece is captured. For now, it ignores
promotions.

fairymax.c

index 35d785b..2bf32d1 100644 (file)
@@ -188,6 +188,7 @@ int k,q,l,e,E,z,n;      /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/
        {v=centr[p]?b[x+257]-b[y+257]:0;        /* center positional pts.   */\r
         if(!(G&S))b[FF]=b[G],v+=50;            /* castling: put R & score  */\r
         b[G]=b[H]=b[x]=0;b[y]=u|32;            /* do move, set non-virgin  */\r
+        pl[t&31]-=!!t;                         /* updat victim piece count */\r
         v-=w[p]>0|R<EG?0:20;                   /*** freeze K in mid-game ***/\r
         if(p<3)                                /* pawns:                   */\r
         {v-=9*((x-2&M||b[x-2]-u)+              /* structure, undefended    */\r
@@ -227,7 +228,7 @@ int k,q,l,e,E,z,n;      /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/
          v=m;                                  /* (prevent fail-lows on    */\r
         }                                      /*   K-capt. replies)       */\r
         J=f;Z=g;\r
-        SHAMAX( pl[k]+=!!t; )\r
+        SHAMAX( pl[k]+=!!t; ) pl[t&31]+=!!t;\r
         b[G]=b[FF];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&K==I&d>2&v>V&v<l){int *p=ps;char X,Y;\r
@@ -367,8 +368,10 @@ InitGame()
  int i,j;\r
 \r
  for(i=0;i<16*BH;i++)b[i]=0;\r
+ for(i=0;i<32;i++)pl[i]=0;\r
  K=BW;W(K--)\r
  {b[K]=oo[K+16]+16;b[K+112]=oo[K];b[K+16]=18;b[K+96]=1; /* initial board setup*/\r
+  pl[oo[K+16]+16]++;pl[oo[K]]++;pl[18]++;pl[1]++;\r
   L=8;W(L--)b[16*L+K+257]=(K-BW/2)*(K-BW/2)+(L-3.5)*(L-3.5); /* center-pts table   */\r
  }                                                   /*(in unused half b[])*/\r
  Side = WHITE; Q=0; O=S;\r
@@ -769,6 +772,7 @@ int main(int argc, char **argv)
                                 if(m=='.') break;\r
                                 if(m=='#') {\r
                                         for(i=0; i<128; i++) b[i]=0;\r
+                                        for(i=0; i<32; i++) pl[i]=0;\r
                                         Q=0; R=0; O=S;\r
                                         pl[WHITE]=pl[BLACK]=0;\r
                                         continue;\r
@@ -804,7 +808,7 @@ int main(int argc, char **argv)
                                        case 0: // undefined piece, ignore\r
                                             break;\r
                                         }\r
-                                        pl[BLACK+WHITE-color]++;\r
+                                        pl[BLACK+WHITE-color]++;pl[p+color]++;\r
                                         continue;\r
                                 }\r
                         }\r