/*****************************************************************/\r
\r
#define MULTIPATH\r
-#define VERSION "4.8R"\r
+#define VERSION "4.8S"\r
\r
#include <stdio.h>\r
#include <stdlib.h>\r
int MaxDepth;\r
int Post;\r
int Fifty;\r
-int UnderProm;\r
int GameNr;\r
int Resign;\r
int Cambodian;\r
int Threshold = 800;\r
int Score;\r
int makruk;\r
-int prom, pm, gating;\r
+int prom, pm, gating, succession;\r
char piecename[32], piecetype[32], blacktype[32];\r
char selectedFairy[80];\r
char *inifile = INI_FILE;\r
}\r
#endif\r
m=E<16|(E^112)<16&&flag&1&y-E<2&E-y<2?I:m; /* bad castling */\r
- if(p<3&y==E)H=z&127; /* shift capt.sqr. H if e.p.*/\r
+ if(p<3&y==E&flag)H=z&127; /* shift capt.sqr. H if e.p.*/\r
t=b[H];\r
if(flag&1+!t) /* mode (capt/nonc) allowed?*/\r
{if(t&&(t&16)==k)break; /* capture own */\r
v+=e+i;V=m>q?m:q; /*** new eval & alpha ****/\r
if(z&S)V=m-margin>q?m-margin:q; /* multiPV */\r
C=d-1-(d>5&p>2&!t&!h); /* nw depth, reduce non-cpt.*/\r
- C=R<EG|P-I|d<3||t&&p-3?C:d; /* extend 1 ply if in-check */\r
+ C=R<EG|P-I|d<3||t&&w[p]>0?C:d; /* extend 1 ply if in-check */\r
do\r
s=C>2|v>V?-D(16-k,-l,-V,-v,/*** futility, recursive eval. of reply */\r
F,y&255,C):v;\r
if(z&S&&K-I) /* move pending: check legal*/\r
{if(v+I&&x==K&y==L>==GT) /* if move found */\r
{Q=-e-i;O=F;LL=L;prom=gt;\r
- if(b[y]-u&15)prom=b[y]-=PromPiece, /* under-promotion, correct */\r
- Z+=PromPiece; /* piece & invalidate hash */\r
+ if(b[y]-u&15)prom=b[y]-=PromPiece, /* (under-)promotion: */\r
+ Q-=abs(w[prom&=15])-w[p]-6*S, /* correct piece & score & */\r
+ Z+=PromPiece; /* invalidate hash */\r
a->D=99;a->V=0; /* lock game in hash as draw*/\r
R-=i/FAC; /*** total captd material ***/\r
Fifty = t|p<3?0:Fifty+1;\r
if(cnt==-I+1) {\r
if (s == WHITE)\r
printf("0-1 {Black mates}\n");\r
- else\r
+ else {\r
+ if(succession) { // suppress loss claim if black might be able to replace its King by promotion\r
+ for(j=0;j<BW;j++)if((b[j+96]&31)==18)return 0;\r
+ }\r
printf("1-0 {White mates}\n");\r
+ }\r
return 3;\r
}\r
if(Fifty >=100) {\r
if(w[oo[i]] < 0) k = w[oo[i]];\r
}\r
R -= 2*(-k/FAC);\r
- UnderProm = -1; pl[WHITE] = pl[BLACK] = 2*BW; \r
+ pl[WHITE] = pl[BLACK] = 2*BW; \r
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.\r
if(gating) pl[14] = pl[15] = pl[30] = pl[31] = 1, R += 2*(w[9]/FAC + w[10]/FAC);\r
}\r
if(fscanf(f, "version 4.8(%c)", &c)!=1 || c != 'w')\r
{ printf("telluser incompatible fmax.ini file\n"); exit(0); }\r
\r
- gating = 0;\r
+ gating = succession = 0;\r
if(name != NULL)\r
{ /* search for game name in definition file */\r
if(!strcmp(name, "makruk") && Cambodian) name = "cambodian"; else\r
{ od[++i]=j; centr[i] = c>='a';\r
blacktype[c&31]=i; piecename[i]=c&31;\r
if(piecetype[c&31]==0) piecetype[c&31]=i; // only first\r
+ succession |= w[i] < -4; // expendable royalty; assume we can promote to it\r
}\r
j++; o[j]=0;\r
/* 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]); /**/\r
N=0;K=I;\r
if (D(Side,-I,I,Q,O,LL|S,3)==I) {\r
Side ^= BLACK^WHITE;\r
- if(UnderProm>=0 && UnderProm != L)\r
- { printf("tellics I hate under-promotions!\n");\r
- printf("resign { underpromotion } \n");\r
- Computer = EMPTY;\r
- continue;\r
- } else UnderProm = -1;\r
m = GetTickCount() - Ticks;\r
printf("# times @ %u: real=%d cpu=%1.0f\n", m + Ticks, m,\r
(CPUtime() - cpuT)/CLOCKS_PER_SEC);\r
printf("move ");\r
printf("%c%c%c%c",'a'+(K&15),'0'+BH-(K>>4),\r
'a'+(L&15),'0'+BH-(L>>4));\r
- if(prom)printf("%c",piecename[prom&15]+'a'-1);\r
+ if(prom)printf("%c",piecename[prom]+'a'-1);\r
printf("\n");\r
\r
/* time-control accounting */\r
continue;\r
}\r
if (!strcmp(command, "edit")) {\r
- int color = WHITE, p;\r
+ int color = WHITE, p, r;\r
\r
while(fgets(line, 256, stdin)) {\r
m = line[0];\r
} else\r
if(line[1] >= 'a' && line[1] <= 'a'+BW-1\r
&& line[2] >= '1' && line[2] <= '0'+BH) {\r
- m = line[1]-16*line[2]+799;\r
+ m = line[1]-16*line[2]+799; r = m & 0x70;\r
switch(p)\r
{\r
case 1:\r
case 2:\r
if(color==WHITE)\r
- b[m]=(m&0x70)==0x60?1:33,\r
- Q+=w[1];\r
- else b[m]=(m&0x70)==0x10?18:50,\r
- Q+=w[2];\r
+ b[m]=r==0x10?161:r==0x20?97:r==0x60?1:33,\r
+ Q+=w[1]+(r==0x10?S:r==0x20?64:0);\r
+ else b[m]=r==0x60?178:r==0x50?114:r==0x10?18:50,\r
+ Q+=w[2]+(r==0x60?S:r==0x50?64:0);\r
break;\r
default:\r
b[m]=p+color+32; // assume non-virgin\r
GT = (Side == WHITE ? piecetype : blacktype)[line[4]&31];\r
if(GT) PromPiece = (Side == WHITE ? 7 : 7+pm) - GT, GT |= 32 + Side;\r
{char *c=line; K=c[0]-16*c[1]+799;L=c[2]-16*c[3]+799; }\r
+ if(w[GT&15] == -1) L = S; // spoil move for promotion to King\r
if (m & line[1] != '@')\r
/* doesn't have move syntax */\r
printf("Error (unknown command): %s\n", command);\r