From 04eb98f3784572e63e23a5da336bae69bb05615c Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Mon, 1 Nov 2010 22:19:05 +0100 Subject: [PATCH] Allow different default promo piece for black and white 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 | 19 ++++++++++++++++--- fairymax.c | 11 ++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/data/fmax.ini b/data/fmax.ini index d4e5cef..af03e29 100644 --- a/data/fmax.ini +++ b/data/fmax.ini @@ -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. These pieces will automatically promote to piece number 7 when they reach last rank. So in normal Chess, piece 7 should be programmed as Queen. +There is one exception to this: if the initial setup does have a white +piece 7, but not a black one, and black has a piece number 9, then +black will always promote to the latter. (This can be useful in variants +with different armies for black and white). Castling can be done only with the original corner piece as specified by line 2 and 3. Any royal piece can in principle castle. (Subject to @@ -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 become counter-productive if the Pawn move is changed. - +A low digit equal to 4 gets special treatment, as the normal interpretation as +the last and only step of a move which can neither capture nor move is useles. +It will in stead be used as if it was 0 (i.e. there is a follow-up step), +but only if the piece has not moved before. If the 1 or 2 bit of the preceding +toggle digit are set, they then determine what the move can do after this second +step, in the normal way. (For pawn double-push and castling this would normally +be a non-capture.) The 4 and 8 bits of this toggle digit are not used for +toggling the leaper and hopper bits, though, but indicate if e.p. capture +on the reply should be suppressed, and if the move should be allowed to continue +even if the first step hits an occupied square. For the truly lazy, a few complete game descriptions can be found below: @@ -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 8x8 6 4 5 7 3 5 4 6 -11 9 10 12 8 10 9 11 +12 10 11 9 8 11 10 12 p:100 -16,24 -16,6 -15,5 -17,5 p:100 16,24 16,6 15,5 17,5 k:-1 1,34 -1,34 1,7 -1,7 16,7 15,7 17,7 -16,7 -15,7 -17,7 @@ -411,10 +424,10 @@ b:350 15,3 17,3 -15,3 -17,3 R:500 16,3 -16,3 -1,3 1,3 Q:950 1,3 16,3 15,3 17,3 -1,3 -16,3 -15,3 -17,3 k:-1 1,34 -1,1034 1,7 -1,7 16,7 15,7 17,7 -16,7 -15,7 -17,7 +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 e:320 30,7 34,7 -30,7 -34,7 16,7 -16,7 1,7 -1,7 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 l:530 15,3 17,3 -15,3 -17,3 32,7 -32,7 2,7 -2,7 -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 m:275 1,7 16,7 15,7 17,7 -1,7 -16,7 -15,7 -17,7 H:560 14,3 31,3 33,3 18,3 -14,3 -31,3 -33,3 -18,3 diff --git a/fairymax.c b/fairymax.c index 2c16397..5b2e98a 100644 --- a/fairymax.c +++ b/fairymax.c @@ -93,7 +93,7 @@ int Resign; int Threshold = 800; int Score; int makruk; -int prom; +int prom, pm; char piecename[32], piecetype[32], blacktype[32]; char selectedFairy[80]; char *inifile = INI_FILE; @@ -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 */ +(w[b[x^16]&15]<0)) /*** cling to magnetic K ***/ +(R-76>>2); /* end-game Pawn-push bonus */ - b[y]+=V=y+r+1&S?647-p:2*(u&y+16&32); /* upgrade P or convert to Q*/ + b[y]+=V=y+r+1&S?647-p|pm:2*(u&y+16&32);/*upgrade P or convert to Q*/ if(V&makruk)b[y]=u|7,V=480; /* Makruk promotion on 6th */ V>>=sh; /* for Shatranj promo to F */ i+=V; /* promotion / passer bonus */ @@ -378,6 +378,7 @@ InitGame() Fifty = 0; R = 0; for(i=0; i='a'+BW | line[1]<'1' | line[1]>='1'+BH | line[2]<'a' | line[2]>='a'+BW | line[3]<'1' | line[3]>='1'+BH; - if(line[4] == '\n') line[4] = piecename[7]; - PromPiece = 7 - (Side == WHITE ? piecetype : blacktype)[line[4]&31]; - if(PromPiece == 7) PromPiece = 0; + if(line[4] == '\n') line[4] = 0; + PromPiece = (Side == WHITE ? piecetype : blacktype)[line[4]&31]; + if(PromPiece) PromPiece = (Side == WHITE ? 7 : 7+pm) - PromPiece; {char *c=line; K=c[0]-16*c[1]+799;L=c[2]-16*c[3]+799; } if (m) /* doesn't have move syntax */ -- 1.7.0.4