From 857ddcade2d574782d3d8643bedcaf42b79f483f Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Tue, 12 Feb 2013 09:43:20 +0100 Subject: [PATCH] Fix spurious result claims in Spartan Chess Fairy-Max sometimes sees phantom mates, where evasion is possible through promotion to royalty. The possibility for this is now detected based on presence of expendable royalty in the list of participating pieces, and this is used to suppress loss claims. (Checking if promotion is indeed possible is limited to presence of 2nd-rank Pawn.) In addition promotion to royalty is now rejected as illegal in variants without expendable royalty. --- fairymax.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/fairymax.c b/fairymax.c index cf62466..792ceeb 100644 --- a/fairymax.c +++ b/fairymax.c @@ -104,7 +104,7 @@ int Cambodian; int Threshold = 800; int Score; int makruk; -int prom, pm, gating; +int prom, pm, gating, succession; char piecename[32], piecetype[32], blacktype[32]; char selectedFairy[80]; char *inifile = INI_FILE; @@ -364,8 +364,12 @@ int PrintResult(int s) if(cnt==-I+1) { if (s == WHITE) printf("0-1 {Black mates}\n"); - else + else { + if(succession) { // suppress loss claim if black might be able to replace its King by promotion + for(j=0;j=100) { @@ -472,7 +476,7 @@ void LoadGame(char *name) if(fscanf(f, "version 4.8(%c)", &c)!=1 || c != 'w') { printf("telluser incompatible fmax.ini file\n"); exit(0); } - gating = 0; + gating = succession = 0; if(name != NULL) { /* search for game name in definition file */ if(!strcmp(name, "makruk") && Cambodian) name = "cambodian"; else @@ -507,6 +511,7 @@ void LoadGame(char *name) { od[++i]=j; centr[i] = c>='a'; blacktype[c&31]=i; piecename[i]=c&31; if(piecetype[c&31]==0) piecetype[c&31]=i; // only first + succession |= w[i] < -4; // expendable royalty; assume we can promote to it } j++; o[j]=0; /* printf("# c='%c' i=%d od[i]=%d j=%d (%3d,%8x)\n",c?c:' ',i,od[i],j,o[j-1],of[j-1]); /**/ @@ -874,6 +879,7 @@ int main(int argc, char **argv) GT = (Side == WHITE ? piecetype : blacktype)[line[4]&31]; if(GT) PromPiece = (Side == WHITE ? 7 : 7+pm) - GT, GT |= 32 + Side; {char *c=line; K=c[0]-16*c[1]+799;L=c[2]-16*c[3]+799; } + if(w[GT&15] == -1) L = S; // spoil move for promotion to King if (m & line[1] != '@') /* doesn't have move syntax */ printf("Error (unknown command): %s\n", command); -- 1.7.0.4