From c62ef367da4863f395624f3eb02cc9f215b42ada Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Tue, 27 Dec 2011 15:39:42 +0100 Subject: [PATCH 01/16] Fix undo in variant seirawan The gated pieces were not remembered in the game history, so that replaying it when tking bck a move did not work properly. --- fairymax.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fairymax.c b/fairymax.c index 83002e5..dfa3ea6 100644 --- a/fairymax.c +++ b/fairymax.c @@ -68,10 +68,10 @@ int StartKey; #endif /* make unique integer from engine move representation */ -#define PACK_MOVE 256*K + L + (PromPiece << 16); +#define PACK_MOVE 256*K + L + (PromPiece << 16) + (GT<<24); /* convert intger argument back to engine move representation */ -#define UNPACK_MOVE(A) K = (A)>>8 & 255; L = (A) & 255; PromPiece = (A)>>16 & 255; +#define UNPACK_MOVE(A) K = (A)>>8 & 255; L = (A) & 255; PromPiece = (A)>>16 & 255; GT = (A)>>24 & 255; /* Global variables visible to engine. Normally they */ /* would be replaced by the names under which these */ -- 1.7.0.4 From 5dc87dcd0d60262efa7b5ce308b100371f72bc3d Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Wed, 28 Dec 2011 14:28:18 +0100 Subject: [PATCH 02/16] Fix illegal-move message on seirawan gating from gated pieces Entering a gating move hen an already-gated piece left the back rank as interpreted as a on-gating move, rather than rejected. This because gating moves with non-virgin pieces were interpreted as non-gating promotions. The test for true promotions is now done on piece type rather than virginity. --- fairymax.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/fairymax.c b/fairymax.c index dfa3ea6..5106ae1 100644 --- a/fairymax.c +++ b/fairymax.c @@ -876,7 +876,7 @@ int main(int argc, char **argv) if(b[L] && (b[L]&16) == Side && w[b[L]&15] < 0) // capture own King: castling { i=K; K = L; L = i>L ? i-1 : i+2; } if(w[GT&15] < -1) pl[GT&31]++, J+=89729; // promotion to royal piece - if(b[K]&32) GT = 0; // non-virgin mover => true promotion rather than gating + if((b[K]&15) < 3) GT = 0; // Pawn => true promotion rather than gating if(D(Side,-I,I,Q,O,LL|S,3)!=I) { /* did have move syntax, but illegal move */ printf("Illegal move:%s\n", line); -- 1.7.0.4 From 5b64a22e62beb2c9d21d5567993eb0f74b1fa074 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Mon, 13 Feb 2012 13:37:28 +0100 Subject: [PATCH 03/16] Let Fairy-Max print timing info Before and after search a time stamp are printed, and after the search the real and cpu time used for it. The time stamp can be compared to that of the opponent, to calculate communication delay through the GUI. --- fairymax.c | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) diff --git a/fairymax.c b/fairymax.c index 5106ae1..931099a 100644 --- a/fairymax.c +++ b/fairymax.c @@ -32,13 +32,24 @@ #ifdef WIN32 # include +# define CPUtime 1000.*clock #else # include +# include +# include int GetTickCount() // with thanks to Tord { struct timeval t; gettimeofday(&t, NULL); return t.tv_sec*1000 + t.tv_usec/1000; } + double CPUtime() + { // get CPU time used by process, converted to 'MILLICLOCKS' + struct tms cpuTimes; + static int cps = 0; + if(!cps) cps = sysconf(_SC_CLK_TCK); + times(&cpuTimes); + return ((double)(cpuTimes.tms_utime + cpuTimes.tms_stime) * CLOCKS_PER_SEC * 1000)/cps; + } #endif int StartKey; @@ -522,7 +533,8 @@ int main(int argc, char **argv) { int Computer, MaxTime, MaxMoves, TimeInc, sec, i, j; char line[256], command[256], c, cc; - int m, nr; + int m, nr, hh; + double cpuT; FILE *f; if(argc>1 && sscanf(argv[1], "%d", &m)==1) @@ -555,6 +567,7 @@ int main(int argc, char **argv) /* the game have to be done in this time. */ /* If MaxMoves=1 any leftover time is lost*/ Ticks = GetTickCount(); + cpuT = CPUtime(); printf("# times @ %u\n", Ticks); m = MovesLeft<=0 ? 40 : MovesLeft; tlim = (0.6-0.06*(BW-8))*(TimeLeft+(m-1)*TimeInc)/(m+7); if(tlim>TimeLeft/15) tlim = TimeLeft/15; @@ -568,12 +581,14 @@ int main(int argc, char **argv) Computer = EMPTY; continue; } else UnderProm = -1; + m = GetTickCount() - Ticks; + printf("# times @ %u: real=%d cpu=%1.0f\n", m + Ticks, m, + (CPUtime() - cpuT)/CLOCKS_PER_SEC); printf("move "); printf("%c%c%c%c",'a'+(K&15),'0'+BH-(K>>4), 'a'+(L&15),'0'+BH-(L>>4)); if(prom)printf("%c",piecename[prom&15]+'a'-1); printf("\n"); - m = GetTickCount() - Ticks; /* time-control accounting */ TimeLeft -= m; -- 1.7.0.4 From 8f1df62f9ff3091a9d2677b9e0417c50ca863ca2 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Tue, 24 Apr 2012 14:57:12 +0200 Subject: [PATCH 04/16] Recognize drop moves as illegal move An @-sign as second character now makes Fairy-Max recognize the input as a move, so that the Illegal-move response is given rather than the Unknown-command response. It is not really checked if the encoding of the drop move accidentally coincide with that of a legal move. --- fairymax.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/fairymax.c b/fairymax.c index 931099a..91fe48d 100644 --- a/fairymax.c +++ b/fairymax.c @@ -884,7 +884,7 @@ int main(int argc, char **argv) GT = (Side == WHITE ? piecetype : blacktype)[line[4]&31]; if(GT) PromPiece = (Side == WHITE ? 7 : 7+pm) - GT, GT |= 32 + Side; {char *c=line; K=c[0]-16*c[1]+799;L=c[2]-16*c[3]+799; } - if (m) + if (m & line[1] != '@') /* doesn't have move syntax */ printf("Error (unknown command): %s\n", command); else { int i=-1; -- 1.7.0.4 From 2f0beb1f00d5215af1834117b3b69ac82c662400 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Mon, 11 Feb 2013 14:02:05 +0100 Subject: [PATCH 05/16] Fix hash-address bug The lowest bit of the address was clipped off by wrong use of the mask. Because of this only even entries could be used, and spoiling of the key after underpromotion to the 'nearest' alternative would lead to an enormous number of false hash hits, leading to false result claims. --- fairymax.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fairymax.c b/fairymax.c index 91fe48d..8b28a6c 100644 --- a/fairymax.c +++ b/fairymax.c @@ -151,7 +151,7 @@ int k,q,l,e,E,z,n; /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/ { /* e=score, z=prev.dest; J,Z=hashkeys; return score*/ int j,r,m,v,d,h,i,F,G,P,V,f=J,g=Z,C,s,flag,FF,*ps=sp,kk=S; signed char t,p,u,x,y,X,Y,H,B,gt; - struct _*a=A+(J+(k+S)*E&U-1); /* lookup pos. in hash table*/ + struct _*a=A+(J+(k+S)*E&U); /* lookup pos. in hash table*/ *sp++=0; q-=qD;m=a->V;X=a->F;Y=a->Y; /* resume at stored depth */ @@ -747,7 +747,7 @@ int main(int argc, char **argv) if(sscanf(line+7, "Ini File=%s", filename) == 1) { inifile = filename; continue; } - if(sscanf(line+7, "Clear Hash") == 1) for(i=0; iK = 0; + if(sscanf(line+7, "Clear Hash") == 1) for(i=0; i<=U; i++) A->K = 0; if(sscanf(line+7, "MultiVariation Margin=%d", &margin) == 1) continue; if(sscanf(line+7, "Variant fairy selects=%s", selectedFairy+6) == 1) continue; if(sscanf(line+7, "Cambodian Makruk rules=%d", &Cambodian) == 1) continue; -- 1.7.0.4 From c6921012dea09ac75725051259ec211602c58aa2 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Mon, 11 Feb 2013 14:05:46 +0100 Subject: [PATCH 06/16] Fix Clear Hash option The Clear Hash option was not properly tested for, and was thus ignored. --- fairymax.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/fairymax.c b/fairymax.c index 8b28a6c..cbedcbd 100644 --- a/fairymax.c +++ b/fairymax.c @@ -747,7 +747,7 @@ int main(int argc, char **argv) if(sscanf(line+7, "Ini File=%s", filename) == 1) { inifile = filename; continue; } - if(sscanf(line+7, "Clear Hash") == 1) for(i=0; i<=U; i++) A->K = 0; + if(sscanf(line+7, "Clear Hash%c", &c) == 1) for(i=0; i<=U; i++) A->K = 0; if(sscanf(line+7, "MultiVariation Margin=%d", &margin) == 1) continue; if(sscanf(line+7, "Variant fairy selects=%s", selectedFairy+6) == 1) continue; if(sscanf(line+7, "Cambodian Makruk rules=%d", &Cambodian) == 1) continue; -- 1.7.0.4 From 9448cbd851e7d2557853e7b3c2c6fa7b9eccbd19 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Mon, 11 Feb 2013 14:12:48 +0100 Subject: [PATCH 07/16] Fix some warnings --- fairymax.c | 29 +++++++++++++---------------- 1 files changed, 13 insertions(+), 16 deletions(-) diff --git a/fairymax.c b/fairymax.c index cbedcbd..47b9ca5 100644 --- a/fairymax.c +++ b/fairymax.c @@ -140,7 +140,7 @@ n[]=".*XKNBRQEWFMACHG?x+knbrqewfmachg"; /* piece symbols on printout*/ int pv[10000],*sp=pv; // triangular array int margin; -pboard() +void pboard() {int i; i=-1;W(++i<128)printf(" %c",(i&15)==BW&&(i+=15-BW)?10:n[b[i]&31]); } @@ -324,7 +324,7 @@ if(z&4*S)K=X,L=Y&~S; int PrintResult(int s) { - int i, j, k, cnt=0; + int j, k, cnt=0; /* search last 50 states with this stm for third repeat */ for(j=2; j<=100 && j <= HistPtr; j+=2) @@ -377,17 +377,15 @@ int PrintResult(int s) } -InitEngine() +void InitEngine() { - int i, j; - N=32*S+7;W(N-->S+3)T[N]=rand()>>9; srand(GetTickCount()); } -InitGame() +void InitGame() { - int i,j,k=0; + int i,k=0; Side = WHITE; Q=0; O=S; Fifty = 0; R = 0; @@ -413,7 +411,7 @@ InitGame() void CopyBoard(int s) { - int i, j, k, cnt=0; + int i, j; /* copy game representation of engine to HistoryBoard */ /* don't forget castling rights and e.p. state! */ @@ -424,7 +422,7 @@ void CopyBoard(int s) void PrintVariants(int combo) { - int i, j, count=0, total=0; char c=EOF+1, buf[80]; + int count=0, total=0; char c=EOF+1, buf[80]; FILE *f; f = fopen(INI_FILE, "r"); @@ -461,7 +459,7 @@ void PrintOptions() printf("feature done=1\n"); } -int LoadGame(char *name) +void LoadGame(char *name) { int i, j, ptc, count=0; char c, buf[80], pieceToChar[80]; static int currentVariant; @@ -531,11 +529,10 @@ int LoadGame(char *name) int main(int argc, char **argv) { - int Computer, MaxTime, MaxMoves, TimeInc, sec, i, j; - char line[256], command[256], c, cc; - int m, nr, hh; + int Computer, MaxTime, MaxMoves, TimeInc, sec, i; + char line[256], command[256], c; + int m, nr; double cpuT; - FILE *f; if(argc>1 && sscanf(argv[1], "%d", &m)==1) { U = (1< Date: Mon, 11 Feb 2013 21:51:30 +0100 Subject: [PATCH 08/16] Correct typo in error message --- fairymax.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/fairymax.c b/fairymax.c index 47b9ca5..a78c851 100644 --- a/fairymax.c +++ b/fairymax.c @@ -467,7 +467,7 @@ void LoadGame(char *name) f = fopen(inifile, "r"); if(f==NULL) - { printf("telluser piece-desription file '%s' not found\n", inifile); + { printf("telluser piece-description file '%s' not found\n", inifile); exit(0); } if(fscanf(f, "version 4.8(%c)", &c)!=1 || c != 'w') -- 1.7.0.4 From a1b49a22d4f243c8bda00c3f630dbabac8508b15 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Mon, 11 Feb 2013 22:38:13 +0100 Subject: [PATCH 09/16] Remove under-promotion resign This was legacy code from micro-Max, and is no longer used, as Fairy-Max allows the opponent every under-promotion. --- fairymax.c | 9 +-------- 1 files changed, 1 insertions(+), 8 deletions(-) diff --git a/fairymax.c b/fairymax.c index a78c851..cf62466 100644 --- a/fairymax.c +++ b/fairymax.c @@ -98,7 +98,6 @@ int MovesLeft; int MaxDepth; int Post; int Fifty; -int UnderProm; int GameNr; int Resign; int Cambodian; @@ -404,7 +403,7 @@ void InitGame() if(w[oo[i]] < 0) k = w[oo[i]]; } R -= 2*(-k/FAC); - UnderProm = -1; pl[WHITE] = pl[BLACK] = 2*BW; + pl[WHITE] = pl[BLACK] = 2*BW; 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. if(gating) pl[14] = pl[15] = pl[30] = pl[31] = 1, R += 2*(w[9]/FAC + w[10]/FAC); } @@ -572,12 +571,6 @@ int main(int argc, char **argv) N=0;K=I; if (D(Side,-I,I,Q,O,LL|S,3)==I) { Side ^= BLACK^WHITE; - if(UnderProm>=0 && UnderProm != L) - { printf("tellics I hate under-promotions!\n"); - printf("resign { underpromotion } \n"); - Computer = EMPTY; - continue; - } else UnderProm = -1; m = GetTickCount() - Ticks; printf("# times @ %u: real=%d cpu=%1.0f\n", m + Ticks, m, (CPUtime() - cpuT)/CLOCKS_PER_SEC); -- 1.7.0.4 From 857ddcade2d574782d3d8643bedcaf42b79f483f Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Tue, 12 Feb 2013 09:43:20 +0100 Subject: [PATCH 10/16] Fix spurious result claims in Spartan Chess Fairy-Max sometimes sees phantom mates, where evasion is possible through promotion to royalty. The possibility for this is now detected based on presence of expendable royalty in the list of participating pieces, and this is used to suppress loss claims. (Checking if promotion is indeed possible is limited to presence of 2nd-rank Pawn.) In addition promotion to royalty is now rejected as illegal in variants without expendable royalty. --- fairymax.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/fairymax.c b/fairymax.c index cf62466..792ceeb 100644 --- a/fairymax.c +++ b/fairymax.c @@ -104,7 +104,7 @@ int Cambodian; int Threshold = 800; int Score; int makruk; -int prom, pm, gating; +int prom, pm, gating, succession; char piecename[32], piecetype[32], blacktype[32]; char selectedFairy[80]; char *inifile = INI_FILE; @@ -364,8 +364,12 @@ int PrintResult(int s) if(cnt==-I+1) { if (s == WHITE) printf("0-1 {Black mates}\n"); - else + else { + if(succession) { // suppress loss claim if black might be able to replace its King by promotion + for(j=0;j=100) { @@ -472,7 +476,7 @@ void LoadGame(char *name) if(fscanf(f, "version 4.8(%c)", &c)!=1 || c != 'w') { printf("telluser incompatible fmax.ini file\n"); exit(0); } - gating = 0; + gating = succession = 0; if(name != NULL) { /* search for game name in definition file */ if(!strcmp(name, "makruk") && Cambodian) name = "cambodian"; else @@ -507,6 +511,7 @@ void LoadGame(char *name) { od[++i]=j; centr[i] = c>='a'; blacktype[c&31]=i; piecename[i]=c&31; if(piecetype[c&31]==0) piecetype[c&31]=i; // only first + succession |= w[i] < -4; // expendable royalty; assume we can promote to it } 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]); /**/ @@ -874,6 +879,7 @@ int main(int argc, char **argv) GT = (Side == WHITE ? piecetype : blacktype)[line[4]&31]; if(GT) PromPiece = (Side == WHITE ? 7 : 7+pm) - GT, GT |= 32 + Side; {char *c=line; K=c[0]-16*c[1]+799;L=c[2]-16*c[3]+799; } + if(w[GT&15] == -1) L = S; // spoil move for promotion to King if (m & line[1] != '@') /* doesn't have move syntax */ printf("Error (unknown command): %s\n", command); -- 1.7.0.4 From a6e756fc912dd7c895816bd5b117b080bc84b582 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Tue, 12 Feb 2013 16:03:36 +0100 Subject: [PATCH 11/16] Fix bug in Berolina e.p. capture A move to the e.p. square in Berolina is not always an attempt to capture e.p., but can also be a normal non-capture. The latter were refused, however, because the capture square was always shifted for Pawn moves to the e.p. square. Now it is only done when the move has capture rights associated with it. --- fairymax.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/fairymax.c b/fairymax.c index 792ceeb..20b63dd 100644 --- a/fairymax.c +++ b/fairymax.c @@ -187,7 +187,7 @@ int k,q,l,e,E,z,n; /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/ } #endif m=E<16|(E^112)<16&&flag&1&y-E<2&E-y<2?I:m; /* bad castling */ - if(p<3&y==E)H=z&127; /* shift capt.sqr. H if e.p.*/ + if(p<3&y==E&flag)H=z&127; /* shift capt.sqr. H if e.p.*/ t=b[H]; if(flag&1+!t) /* mode (capt/nonc) allowed?*/ {if(t&&(t&16)==k)break; /* capture own */ -- 1.7.0.4 From e78e7b6c6b164ea731454e9a8c85e87eed9e9022 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Mon, 11 Feb 2013 22:30:26 +0100 Subject: [PATCH 12/16] Bump version number to 4.8S --- fairymax.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/fairymax.c b/fairymax.c index 20b63dd..ffa6ca8 100644 --- a/fairymax.c +++ b/fairymax.c @@ -18,7 +18,7 @@ /*****************************************************************/ #define MULTIPATH -#define VERSION "4.8R" +#define VERSION "4.8S" #include #include -- 1.7.0.4 From b18ffa3b21ed5483a82daa153479270813d8fabb Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Tue, 12 Feb 2013 16:38:38 +0100 Subject: [PATCH 13/16] Update changelog --- changelog | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/changelog b/changelog index 976ab9e..33d71a1 100644 --- a/changelog +++ b/changelog @@ -90,7 +90,7 @@ pieceToCharTable and initial position to the GUI, sub-specification of variant fairy through an engine-defined option, allowing Seirawan- type gating moves in search. Seirawan Chess is added as new variant, - pluss several new combinations of Chess with different armies + plus several new combinations of Chess with different armies 7/10/2011 Version 4.8R, keeping better track of which pieces are virgin in a setup position, and have a better distinction between use of the '4' @@ -101,3 +101,15 @@ implement Cambodian Chess as a sub-variant of Makruk (selected through a new option). Falcon Chess was added as a new variant. +12/2/2013 Version 4.8S. Fixes a lot of bugs: + * Setting up Seirawan positions with ungated pieces + * Making Seirawan gating with already gated pieces illegal + * Fix undo in Seirawan (by remembering gatings) + * Recognizing drop moves as illegal moves + * Hash-table was only half used + * Spurious result claims after under-promotion + * False mate claims in Spartan when promotion to K was possible + * Fix bug in Berolina e.p. capture that is actually non-capture + * Fix Clear Hash option, which did not work at all + In addition it prints msec-accurate timing info. + -- 1.7.0.4 From 804ec8ebc971e4e92c96e7209df3f0743a36a70b Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Wed, 13 Feb 2013 20:02:13 +0100 Subject: [PATCH 14/16] Add 6th and 7th rank Pawn bonus when setting up position Both the bonuses hidden in the board, as well as the total material evaluation had to be added. --- changelog | 1 + fairymax.c | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/changelog b/changelog index 33d71a1..6431c94 100644 --- a/changelog +++ b/changelog @@ -111,5 +111,6 @@ * False mate claims in Spartan when promotion to K was possible * Fix bug in Berolina e.p. capture that is actually non-capture * Fix Clear Hash option, which did not work at all + * Fix addition of 6th & 7th-rank Pawn bonus when setting up position In addition it prints msec-accurate timing info. diff --git a/fairymax.c b/fairymax.c index ffa6ca8..15a5ce5 100644 --- a/fairymax.c +++ b/fairymax.c @@ -808,7 +808,7 @@ int main(int argc, char **argv) continue; } if (!strcmp(command, "edit")) { - int color = WHITE, p; + int color = WHITE, p, r; while(fgets(line, 256, stdin)) { m = line[0]; @@ -835,16 +835,16 @@ int main(int argc, char **argv) } else if(line[1] >= 'a' && line[1] <= 'a'+BW-1 && line[2] >= '1' && line[2] <= '0'+BH) { - m = line[1]-16*line[2]+799; + m = line[1]-16*line[2]+799; r = m & 0x70; switch(p) { case 1: case 2: if(color==WHITE) - b[m]=(m&0x70)==0x60?1:33, - Q+=w[1]; - else b[m]=(m&0x70)==0x10?18:50, - Q+=w[2]; + b[m]=r==0x10?161:r==0x20?97:r==0x60?1:33, + Q+=w[1]+(r==0x10?S:r==0x20?64:0); + else b[m]=r==0x60?178:r==0x50?114:r==0x10?18:50, + Q+=w[2]+(r==0x60?S:r==0x50?64:0); break; default: b[m]=p+color+32; // assume non-virgin -- 1.7.0.4 From b170de109dfcfa9db25c93006f9e1ef417243aa9 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Wed, 13 Feb 2013 19:39:02 +0100 Subject: [PATCH 15/16] Fix promotion bonus In its search Fairy-Max always promotes to 'Queen' ad gives itself 768 cP bonus for that. (Which is about right for the original micro-Max Q=851 and P=74.) The opponent can do under-promotion to a piece of wildly different value, though, and this was not corrected. It is now corrected at game level (which is the only place it can happen). --- changelog | 1 + fairymax.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/changelog b/changelog index 6431c94..e8a3654 100644 --- a/changelog +++ b/changelog @@ -112,5 +112,6 @@ * Fix bug in Berolina e.p. capture that is actually non-capture * Fix Clear Hash option, which did not work at all * Fix addition of 6th & 7th-rank Pawn bonus when setting up position + * Adapt score by true piece value in case of (under-)promotion In addition it prints msec-accurate timing info. diff --git a/fairymax.c b/fairymax.c index 15a5ce5..6f420ae 100644 --- a/fairymax.c +++ b/fairymax.c @@ -231,8 +231,9 @@ int k,q,l,e,E,z,n; /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/ if(z&S&&K-I) /* move pending: check legal*/ {if(v+I&&x==K&y==L>==GT) /* if move found */ {Q=-e-i;O=F;LL=L;prom=gt; - if(b[y]-u&15)prom=b[y]-=PromPiece, /* under-promotion, correct */ - Z+=PromPiece; /* piece & invalidate hash */ + if(b[y]-u&15)prom=b[y]-=PromPiece, /* (under-)promotion: */ + Q-=abs(w[prom&=15])-w[p]-6*S, /* correct piece & score & */ + Z+=PromPiece; /* invalidate hash */ a->D=99;a->V=0; /* lock game in hash as draw*/ R-=i/FAC; /*** total captd material ***/ Fifty = t|p<3?0:Fifty+1; @@ -582,7 +583,7 @@ int main(int argc, char **argv) printf("move "); printf("%c%c%c%c",'a'+(K&15),'0'+BH-(K>>4), 'a'+(L&15),'0'+BH-(L>>4)); - if(prom)printf("%c",piecename[prom&15]+'a'-1); + if(prom)printf("%c",piecename[prom]+'a'-1); printf("\n"); /* time-control accounting */ -- 1.7.0.4 From 0a8207c5bba7eac72a459e18be5cbd8df35b1704 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sat, 16 Feb 2013 18:05:46 +0100 Subject: [PATCH 16/16] Fix check extension Check extension in micro-Max was not be awarded when a piece other than King captured the checker. In the code this was still tested assuming the piece number of the King would always be 3, while in Fairy-Max every piece can be Royal, based on the sign of its piece value w[]. In many game definitions piece 3 was actually not a King at all. --- changelog | 1 + fairymax.c | 2 +- 2 files changed, 2 insertions(+), 1 deletions(-) diff --git a/changelog b/changelog index e8a3654..06089ba 100644 --- a/changelog +++ b/changelog @@ -110,6 +110,7 @@ * Spurious result claims after under-promotion * False mate claims in Spartan when promotion to K was possible * Fix bug in Berolina e.p. capture that is actually non-capture + * Fix conditions for check extension on capture of checker * Fix Clear Hash option, which did not work at all * Fix addition of 6th & 7th-rank Pawn bonus when setting up position * Adapt score by true piece value in case of (under-)promotion diff --git a/fairymax.c b/fairymax.c index 6f420ae..769da7f 100644 --- a/fairymax.c +++ b/fairymax.c @@ -218,7 +218,7 @@ int k,q,l,e,E,z,n; /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/ v+=e+i;V=m>q?m:q; /*** new eval & alpha ****/ if(z&S)V=m-margin>q?m-margin:q; /* multiPV */ C=d-1-(d>5&p>2&!t&!h); /* nw depth, reduce non-cpt.*/ - C=R0?C:d; /* extend 1 ply if in-check */ do s=C>2|v>V?-D(16-k,-l,-V,-v,/*** futility, recursive eval. of reply */ F,y&255,C):v; -- 1.7.0.4