X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=fairymax.c;h=e615fd4064863efa5d03562f8323da3c92e933a8;hb=3bb0653e89200982208ae58746d8abba884cc2e4;hp=02e3a097a3056b2bdd62ba1c3ad14c9bbf0db6e4;hpb=7668593a029282d0657102158ecbfdd7d50d1471;p=fairymax.git diff --git a/fairymax.c b/fairymax.c index 02e3a09..e615fd4 100644 --- a/fairymax.c +++ b/fairymax.c @@ -18,7 +18,7 @@ /*****************************************************************/ #define MULTIPATH -#define VERSION "4.8M" +#define VERSION "4.8O" #include #include @@ -92,7 +92,8 @@ int GameNr; int Resign; int Threshold = 800; int Score; -char piecename[32], piecetype[32]; +int makruk; +char piecename[32], piecetype[32], blacktype[32]; char *inifile = INI_FILE; int Ticks, tlim, Setup, SetupQ; @@ -183,8 +184,8 @@ int k,q,l,e,E,z,n; /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/ v=d-1?e:i-p; /*** MVV/LVA scoring if d=1**/ if(d-!t>1) /*** all captures if d=2 ***/ {v=centr[p]?b[x+257]-b[y+257]:0; /* center positional pts. */ + if(!(G&S))b[FF]=b[G],v+=50; /* castling: put R & score */ b[G]=b[H]=b[x]=0;b[y]=u|32; /* do move, set non-virgin */ - if(!(G&S))b[FF]=k+6,v+=50; /* castling: put R & score */ v-=w[p]>0|R>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*/ + 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 */ } if(z&S && GamePtr<6) v+=(rand()>>10&31)-16; @@ -224,29 +226,30 @@ int k,q,l,e,E,z,n; /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/ } /* K-capt. replies) */ J=f;Z=g; SHAMAX( pl[k]+=!!t; ) - b[G]=k+6;b[FF]=b[y]=0;b[x]=u;b[H]=t; /* undo move,G can be dummy */ + b[G]=b[FF];b[FF]=b[y]=0;b[x]=u;b[H]=t; /* undo move,G can be dummy */ } /* if non-castling */ - if(z&S&&Post&v>V&v2&v>V&v>8;Y=*p++; printf(" %c%c%c%c",'a'+(X&15),'8'-(X>>4),'a'+(Y&15),'8'-(Y>>4&7));} printf("\n");fflush(stdout); - } if(v>m) /* new best, update max,best*/ + } + if(v>m) /* new best, update max,best*/ m=v,X=x,Y=y|S&F; /* mark non-double with S */ if(h){h=0;goto A;} /* redo after doing old best*/ } - s=t; + s=t;v=r^flag>>12; /* calc. alternated vector */ if(flag&15^4|u&32|| /* no double or moved before*/ p>2&& /* no P & no lateral K move,*/ - (b[G=r<0?x&~15:BW-1|x&112]-k-6 /* no virgin R in corner G, */ - ||b[G^1]|b[G^2]|b[FF=r<0?G+3:G-2]) /* no 2 empty sq. next to R */ + ((b[G=r<0?x&~15:BW-1|x&112]^32)<33 /* no virgin R in corner G, */ + ||b[G^1]|b[G^2]|b[FF=y+v-r]) /* no 2 empty sq. next to R */ )t+=flag&4; /* fake capt. for nonsliding*/ else F=y; /* enable e.p. */ if(s&&flag&8)t=0,flag^=flag>>4&15; /* hoppers go to next phase */ if(!(flag&S)) /* zig-zag piece? */ - r^=flag>>12,flag^=flag>>4&15; /* alternate vector & mode */ + r=v,flag^=flag>>4&15; /* alternate vector & mode */ }W(!t); /* if not capt. continue ray*/ }} if((++x&15)>=BW)x=x+16&112; /* next sqr. of board, wrap */ @@ -316,10 +319,31 @@ int PrintResult(int s) } K=I; cnt = D(s,-I,I,Q,O,LL|4*S,3); +#ifdef SHATRANJ + if(pl[s]==1 && pl[16-s]==1) { + printf("1/2-1/2 {Insufficient mating material}\n"); + return 4; + } + if(pl[s]<=1 && pl[16-s]>1) { + if (s == BLACK) + printf("0-1 {Bare King}\n"); + else + printf("1-0 {Bare King}\n"); + return 5; + } + if(cnt>-I+1 && K==0 && L==0) { + if (s == WHITE) + printf("0-1 {Stalemate}\n"); + else + printf("1-0 {Stalemate}\n"); + return 2; + } +#else if(cnt>-I+1 && K==0 && L==0) { printf("1/2-1/2 {Stalemate}\n"); return 2; } +#endif if(cnt==-I+1) { if (s == WHITE) printf("0-1 {Black mates}\n"); @@ -331,19 +355,6 @@ int PrintResult(int s) printf("1/2-1/2 {Draw by fifty move rule}\n"); return 4; } -#ifdef SHATRANJ - if(pl[s]==1 && pl[16-s]==1) { - printf("1/2-1/2 {Insufficient mating material}\n"); - return 4; - } - if(pl[s]<=1 && pl[16-s]>1) { - if (s == BLACK) - printf("0-1 {Bare King}\n"); - else - printf("1-0 {Bare King}\n"); - return 5; - } -#endif return 0; } @@ -407,7 +418,7 @@ void PrintOptions() printf("feature option=\"Resign -check %d\"\n", Resign); printf("feature option=\"Resign Threshold -spin %d 200 1200\"\n", Threshold); printf("feature option=\"Ini File -file %s\"\n", inifile); - printf("feature option=\"MultiVariation Margin -spin %d 0 1000\"\n", margin); + printf("feature option=\"Multi-PV Margin -spin %d 0 1000\"\n", margin); printf("feature option=\"Playing Style ;-) -combo Brilliant /// *Brave /// Beautiful\"\n"); printf("feature option=\"Dummy Slider Example -slider 20 0 100\"\n"); printf("feature option=\"Dummy String Example -file happy birthday!\"\n"); @@ -452,14 +463,15 @@ int LoadGame(char *name) for(i=0; i='a'; - piecetype[c&31]=i; piecename[i]=c&31; + blacktype[c&31]=i; piecename[i]=c&31; + if(piecetype[c&31]==0) piecetype[c&31]=i; // only first } 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]); /**/ @@ -468,6 +480,7 @@ int LoadGame(char *name) fclose(f); sh = w[7] < 250 ? 3 : 0; + makruk = w[7]==181 ? 64 : 0; // w[7] is used as kludge to enable makruk promotions } int main(int argc, char **argv) @@ -610,12 +623,14 @@ int main(int argc, char **argv) } if (!strcmp(command, "white")) { /* set white to move in current position */ + if(Side == BLACK) Q = -Q; Side = WHITE; Computer = BLACK; continue; } if (!strcmp(command, "black")) { /* set blck to move in current position */ + if(Side == WHITE) Q = -Q; Side = BLACK; Computer = WHITE; continue; @@ -765,7 +780,7 @@ int main(int argc, char **argv) && line[1] >= 'a' && line[1] <= 'a'+BW-1 && line[2] >= '1' && line[2] <= '0'+BH) { m = line[1]-16*line[2]+799; - switch(p = piecetype[line[0]&31]) + switch(p = (color == WHITE ? piecetype : blacktype)[line[0]&31]) { case 1: case 2: @@ -775,23 +790,16 @@ int main(int argc, char **argv) else b[m]=(m&0x70)==0x10?18:50, Q+=w[2]; break; - case 3: // can castle, normally King - b[m]=3+color+32; - if(m==BW>>1 && color==BLACK || - m==0x70+(BW>>1) && color==WHITE) - b[m] -= 32; - break; - case 6: // can castle, normally Rook - b[m]=6+color+32; - if((m==0x00 || m==BW-1 ) && color==BLACK || - (m==0x70 || m==0x6F+BW) && color==WHITE) - b[m] -= 32; - Q+=w[6]; R+=w[6]/FAC; - break; default: - b[m]=p+color; - Q+=w[p]; R+=w[p]/FAC; - case 0: // undefined piece, ignore + b[m]=p+color+32; // assume non-virgin + if(w[p]<0) { // Royal piece on original square: virgin + if(color==BLACK && m<0x10 && p==oo[m+16] || + color==WHITE && m>0x6F && p==oo[m-0x70]) b[m] -= 32; + } else { Q+=w[p]; R+=w[p]/FAC; } + if((m==0x00 || m==BW-1 ) && color==BLACK && p==oo[m+16] || + (m==0x70 || m==0x6F+BW) && color==WHITE && p==oo[m-0x70]) + b[m] &= ~32; // corner piece as in original setup: virgin + case 0: // undefined piece, ignore break; } pl[BLACK+WHITE-color]++; @@ -810,7 +818,7 @@ int main(int argc, char **argv) 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 - piecetype[line[4]&31]; + PromPiece = 7 - (Side == WHITE ? piecetype : blacktype)[line[4]&31]; if(PromPiece == 7) PromPiece = 0; {char *c=line; K=c[0]-16*c[1]+799;L=c[2]-16*c[3]+799; } if (m)