X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=fairymax.c;h=0f4dd5f62f69d8c37dd4b43481fd4790582f0ef1;hb=178720867b5f21ece6bde4502d0d249f532f6a7f;hp=bb842dacc6d706bdd2593eade971af7c9b16e736;hpb=a470951095b2ab90dbe7c256d42546b60d63299f;p=fairymax.git diff --git a/fairymax.c b/fairymax.c index bb842da..0f4dd5f 100644 --- a/fairymax.c +++ b/fairymax.c @@ -93,7 +93,7 @@ int Resign; int Threshold = 800; int Score; int makruk; -int prom, pm; +int prom, pm, gating; char piecename[32], piecetype[32], blacktype[32]; char selectedFairy[80]; char *inifile = INI_FILE; @@ -225,6 +225,8 @@ int k,q,l,e,E,z,n; /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/ R-=i/FAC; /*** total captd material ***/ Fifty = t|p<3?0:Fifty+1; sp=ps; + if(!(u&32)&PromPiece&(K&112)==(k?0:112)) + prom=b[K]=39+k-PromPiece,J+=333,pl[k+14-PromPiece]--; /* gating */ return l;} /* & not in check, signal */ v=m; /* (prevent fail-lows on */ } /* K-capt. replies) */ @@ -387,6 +389,7 @@ InitGame() R -= 2*(-k/FAC); UnderProm = -1; pl[WHITE] = pl[BLACK] = 2*BW; 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. + if(gating) pl[13] = pl[15] = pl[29] = pl[31] = 1, R += 2*(w[6]/FAC + w[8]/FAC); } void CopyBoard(int s) @@ -452,9 +455,11 @@ int 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; if(name != NULL) { /* search for game name in definition file */ - if(!strcmp(name, "fairy")) name = selectedFairy; + if(!strcmp(name, "fairy")) name = selectedFairy; + gating = !strcmp(name, "seirawan"); while((ptc=fscanf(f, "Game: %s # %s", buf, pieceToChar))==0 || strcmp(name, buf) ) { while((c = fgetc(f)) != EOF && c != '\n'); count++; @@ -544,9 +549,12 @@ int main(int argc, char **argv) tlim = (0.6-0.06*(BW-8))*(TimeLeft+(m-1)*TimeInc)/(m+7); if(tlim>TimeLeft/15) tlim = TimeLeft/15; PromPiece = 0; /* Always promote to Queen ourselves */ + if(pl[Side+13])PromPiece=1;else if(pl[Side+15])PromPiece=-1; /* S-Chess gating */ N=0;K=I; if (D(Side,-I,I,Q,O,LL|S,3)==I) { Side ^= BLACK^WHITE; + if(b[K]&&Score+D(Side,-I,I,Q,2*S,2*S,2)>S) + prom=b[K]=0,J-=333,pl[30-Side-PromPiece]++; /* undo bad gating */ if(UnderProm>=0 && UnderProm != L) { printf("tellics I hate under-promotions!\n"); printf("resign { underpromotion } \n"); @@ -851,14 +859,19 @@ int main(int argc, char **argv) if (m) /* doesn't have move syntax */ printf("Error (unknown command): %s\n", command); - else if(D(Side,-I,I,Q,O,LL|S,3)!=I) { + else { int i=-1; + if(b[L] && (b[L]&16) == Side && w[b[L]&15] < 0) // capture own King: castling + { i=K; K = L; L = i>L ? i-1 : i+2; } + if(D(Side,-I,I,Q,O,LL|S,3)!=I) { /* did have move syntax, but illegal move */ printf("Illegal move:%s\n", line); - } else { /* legal move, perform it */ + } else { /* legal move, perform it */ + if(i >= 0) b[i]=b[K],b[K]=0; // reverse Seirawan gating GameHistory[GamePtr++] = PACK_MOVE; Side ^= BLACK^WHITE; CopyBoard(HistPtr=HistPtr+1&1023); if(PrintResult(Side)) Computer = EMPTY; + } } } }