Allow different default promo piece for black and white
authorH.G. Muller <h.g.muller@hccnet.nl>
Mon, 1 Nov 2010 21:19:05 +0000 (22:19 +0100)
committerH.G. Muller <h.g.muller@hccnet.nl>
Mon, 1 Nov 2010 22:20:56 +0000 (23:20 +0100)
If black lacks the 'Queen' (piece #7) that white has, but has a piece #9
in the initial setup, it will promote to that in stead.

data/fmax.ini
fairymax.c

index d4e5cef..af03e29 100644 (file)
@@ -140,6 +140,10 @@ Numbers 1 and 2 are considered Pawns for white and black, respectively,
 and the 2nd and 7th rank of the opening setup will be filled with them.\r
 These pieces will automatically promote to piece number 7 when they \r
 reach last rank. So in normal Chess, piece 7 should be programmed as Queen.\r
+There is one exception to this: if the initial setup does have a white\r
+piece 7, but not a black one, and black has a piece number 9, then\r
+black will always promote to the latter. (This can be useful in variants\r
+with different armies for black and white).\r
 \r
 Castling can be done only with the original corner piece as specified\r
 by line 2 and 3. Any royal piece can in principle castle. (Subject to \r
@@ -239,7 +243,16 @@ black Pawn, respectively, or promotions will have undefined effects. Also
 note that uMax does do primitive evaluation of Pawn structure, which might\r
 become counter-productive if the Pawn move is changed.\r
 \r
-\r
+A low digit equal to 4 gets special treatment, as the normal interpretation as\r
+the last and only step of a move which can neither capture nor move is useles.\r
+It will in stead be used as if it was 0 (i.e. there is a follow-up step),\r
+but only if the piece has not moved before. If the 1 or 2 bit of the preceding\r
+toggle digit are set, they then determine what the move can do after this second\r
+step, in the normal way. (For pawn double-push and castling this would normally\r
+be a non-capture.) The 4 and 8 bits of this toggle digit are not used for\r
+toggling the leaper and hopper bits, though, but indicate if e.p. capture\r
+on the reply should be suppressed, and if the move should be allowed to continue\r
+even if the first step hits an occupied square.\r
 \r
 For the truly lazy, a few complete game descriptions can be found below:\r
 \r
@@ -402,7 +415,7 @@ d:625 1,7 16,7 -1,7 -16,7 15,3 17,3 -15,3 -17,3
 Game: fairy/FIDE-Clobberers\r
 8x8\r
 6 4 5 7 3 5 4 6\r
-11 9 10 12 8 10 9 11\r
+12 10 11 9 8 11 10 12\r
 p:100 -16,24 -16,6 -15,5 -17,5 \r
 p:100 16,24 16,6 15,5 17,5\r
 k:-1  1,34 -1,34 1,7 -1,7 16,7 15,7 17,7 -16,7 -15,7 -17,7\r
@@ -411,10 +424,10 @@ b:350 15,3 17,3 -15,3 -17,3
 R:500 16,3 -16,3 -1,3 1,3\r
 Q:950 1,3 16,3 15,3 17,3 -1,3 -16,3 -15,3 -17,3\r
 k:-1  1,34 -1,1034 1,7 -1,7 16,7 15,7 17,7 -16,7 -15,7 -17,7\r
+A:875 15,3 17,3 -15,3 -17,3 14,7 31,7 33,7 18,7 -14,7 -31,7 -33,7 -18,7\r
 e:320 30,7 34,7 -30,7 -34,7 16,7 -16,7 1,7 -1,7\r
 c:480 15,7 17,7 -15,7 -17,7 32,7 -32,7 2,7 -2,7 30,7 34,7 -30,7 -34,7\r
 l:530 15,3 17,3 -15,3 -17,3 32,7 -32,7 2,7 -2,7\r
-A:875 15,3 17,3 -15,3 -17,3 14,7 31,7 33,7 18,7 -14,7 -31,7 -33,7 -18,7\r
 m:275 1,7 16,7 15,7 17,7 -1,7 -16,7 -15,7 -17,7\r
 H:560 14,3 31,3 33,3 18,3 -14,3 -31,3 -33,3 -18,3\r
 \r
index 2c16397..5b2e98a 100644 (file)
@@ -93,7 +93,7 @@ int Resign;
 int Threshold = 800;\r
 int Score;\r
 int makruk;\r
-int prom;\r
+int prom, pm;\r
 char piecename[32], piecetype[32], blacktype[32];\r
 char selectedFairy[80];\r
 char *inifile = INI_FILE;\r
@@ -195,7 +195,7 @@ int k,q,l,e,E,z,n;      /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/
                (x+2&M||b[x+2]-u)               /*        squares plus bias */\r
               +(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
+         b[y]+=V=y+r+1&S?647-p|pm: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
@@ -378,6 +378,7 @@ InitGame()
  Fifty = 0; R = 0;\r
  for(i=0; i<BW; i++) if(i!=3) R += (w[oo[i]]/FAC) + (w[oo[i+16]]/FAC);\r
  UnderProm = -1; pl[WHITE] = pl[BLACK] = 2*BW;\r
+ pm = !pl[BLACK+7] && pl[BLACK+9] && pl[WHITE+7] ? 2 : 0; // Unlike white, black has no 'Q', so promote to 9, which he does have.\r
 }\r
 \r
 void CopyBoard(int s)\r
@@ -825,9 +826,9 @@ int main(int argc, char **argv)
                 /* command not recognized, assume input move */\r
                 m = line[0]<'a' | line[0]>='a'+BW | line[1]<'1' | line[1]>='1'+BH |\r
                     line[2]<'a' | line[2]>='a'+BW | line[3]<'1' | line[3]>='1'+BH;\r
-                if(line[4] == '\n') line[4] = piecename[7];\r
-                PromPiece = 7 - (Side == WHITE ? piecetype : blacktype)[line[4]&31];\r
-                   if(PromPiece == 7) PromPiece = 0;\r
+                if(line[4] == '\n') line[4] = 0;\r
+                PromPiece = (Side == WHITE ? piecetype : blacktype)[line[4]&31];\r
+                if(PromPiece) PromPiece = (Side == WHITE ? 7 : 7+pm) - PromPiece;\r
                 {char *c=line; K=c[0]-16*c[1]+799;L=c[2]-16*c[3]+799; }\r
                 if (m)\r
                         /* doesn't have move syntax */\r