X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=fairymax.c;h=92bf8a9616f304905b9cc3e65b9025fb4c0b469d;hb=518211a4310898171d8bb4e0a865f97e9cbda28a;hp=15e4f15b915165ae024481a9405e5375c480097b;hpb=d8b71c2edea654c591fa67f973348e34e44073c6;p=fairymax.git diff --git a/fairymax.c b/fairymax.c index 15e4f15..92bf8a9 100644 --- a/fairymax.c +++ b/fairymax.c @@ -18,7 +18,7 @@ /*****************************************************************/ #define MULTIPATH -#define VERSION "4.8N" +#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 */ @@ -452,14 +455,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 +472,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) @@ -765,7 +770,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 +780,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 +808,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)