X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=fairymax.c;h=205e89bec67441b2bad77133bc19ad84a38ad3f9;hb=a3fd272813e903e7dcbfa9f80d27d1ecdbc08738;hp=2c1639748649b1e88c9e83e2100cddd8d4f8f150;hpb=630c98a790ff04b8243020fa5479b252d7baed86;p=fairymax.git diff --git a/fairymax.c b/fairymax.c index 2c16397..205e89b 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; +int prom, pm; char piecename[32], piecetype[32], blacktype[32]; char selectedFairy[80]; char *inifile = INI_FILE; @@ -181,7 +181,8 @@ int k,q,l,e,E,z,n; /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/ if(flag&1+!t) /* mode (capt/nonc) allowed?*/ {if(t&&(t&16)==k)break; /* capture own */ i=w[t&15]+((t&192)>>sh); /* value of capt. piece t */ - if(i<0&&(pl[t&31]<2||kk!=H&kk!=S||(kk=H,i=-i,0)))m=I,d=98;/* K capture, duple check */ + if(i<0&&(pl[t&31]<2|| /* K capture, (of last K), */ + t>>3&kk!=H&kk!=S||(kk=H,i=-i,0)))m=I,d=98;/* or duple check: cutoff*/ if(m>=l&d>1)goto C; /* abort on fail high */ v=d-1?e:i-p; /*** MVV/LVA scoring if d=1**/ if(d-!t>1) /*** all captures if d=2 ***/ @@ -195,7 +196,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 */ @@ -224,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++,pl[k+14-PromPiece]--; /* gating */ return l;} /* & not in check, signal */ v=m; /* (prevent fail-lows on */ } /* K-capt. replies) */ @@ -365,19 +368,27 @@ 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--) {b[K]=oo[K+16]+16;b[K+112]=oo[K];b[K+16]=18;b[K+96]=1; /* initial board setup*/ pl[oo[K+16]+16]++;pl[oo[K]]++;pl[18]++;pl[1]++; + if(w[oo[K+16]+16] == -1)pl[oo[K+16]+16]=1; + 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; @@ -762,6 +782,7 @@ int main(int argc, char **argv) sscanf(line, "variant %s", command); LoadGame(command); InitGame(); Setup = 0; + if(strstr(command,"seirawan")) pl[13] = pl[15] = pl[29] = pl[31] = 1; continue; } if (!strcmp(command, "edit")) { @@ -811,6 +832,7 @@ int main(int argc, char **argv) break; } pl[BLACK+WHITE-color]++;pl[p+color]++; + if(w[p+color] == -1)pl[p+color]=1; // fake we have one if value = -1, to thwart extinction condition continue; } } @@ -820,14 +842,15 @@ 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 */ m = line[0]<'a' | line[0]>='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 */