X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=fairymax.c;h=7fb3cadb6fbf52b86541f5ff1d381c118b9a4c93;hb=4b753a4ed5a531703e7456cb92f21b9a0f46b4e3;hp=0eaaf2db228d9bd9f7f28f492e567a6d2136f3e1;hpb=ea32376a2bfabec06dc5276b79ecd9d110a09715;p=fairymax.git diff --git a/fairymax.c b/fairymax.c index 0eaaf2d..7fb3cad 100644 --- a/fairymax.c +++ b/fairymax.c @@ -18,7 +18,7 @@ /*****************************************************************/ #define MULTIPATH -#define VERSION "4.8O" +#define VERSION "4.8P" #include #include @@ -68,10 +68,10 @@ int StartKey; #endif /* make unique integer from engine move representation */ -#define PACK_MOVE 256*K + L; +#define PACK_MOVE 256*K + L + (PromPiece << 16); /* convert intger argument back to engine move representation */ -#define UNPACK_MOVE(A) K = (A)>>8 & 255; L = (A) & 255; +#define UNPACK_MOVE(A) K = (A)>>8 & 255; L = (A) & 255; PromPiece = (A)>>16 & 255; /* Global variables visible to engine. Normally they */ /* would be replaced by the names under which these */ @@ -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) */ @@ -366,8 +368,10 @@ InitEngine() InitGame() { - int i,j; + int i,j,k=0; + Side = WHITE; Q=0; O=S; + Fifty = 0; R = 0; for(i=0;i<16*BH;i++)b[i]=0; for(i=0;i<32;i++)pl[i]=0; K=BW;W(K--) @@ -377,11 +381,15 @@ InitGame() if(w[oo[K]] == -1)pl[oo[K]]=1; L=8;W(L--)b[16*L+K+257]=(K-BW/2)*(K-BW/2)+(L-3.5)*(L-3.5); /* center-pts table */ } /*(in unused half b[])*/ - Side = WHITE; Q=0; O=S; - Fifty = 0; R = 0; - for(i=0; iTimeLeft/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"); @@ -825,6 +846,7 @@ int main(int argc, char **argv) setupPosition[128] = Side; setupPosition[129] = R; for(i=0; i<32; i++) setupPosition[i+130] = pl[i]; + Computer = EMPTY; // after edit: force mode! continue; } /* command not recognized, assume input move */ @@ -837,14 +859,18 @@ 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=K; + if(b[L] && (b[L]&16) == Side && w[b[L]&15] < 0) // capture own King: castling + { 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 */ GameHistory[GamePtr++] = PACK_MOVE; Side ^= BLACK^WHITE; CopyBoard(HistPtr=HistPtr+1&1023); if(PrintResult(Side)) Computer = EMPTY; + } } } }