From: H.G.Muller Date: Tue, 30 Sep 2014 20:18:32 +0000 (+0200) Subject: Implement King of the Hill as engine-supported variant X-Git-Url: http://winboard.nl/cgi-bin?p=fairymax.git;a=commitdiff_plain;h=25b177d809f72250a6ec78df11fb84ccff1fe4ad Implement King of the Hill as engine-supported variant The new winning condition is implemented as finding a royal of the stm on the hill at the start of the turn. A global flag 'hill' enables this test, and is set when the value of piece #3 is -2. (Kludgy!) The flag centr[pieceType] is now used as a multiplier, which for 0, 1 amounts to the same, but opens the possibility to up it before the search, for a specific piece type. This is used in 'King of the Hill' to increase the attraction of the King towards the center from 12 to 264cP when material drops from Q+2minor (each) to nothing. (This was worth 100 Elo!) The royal piece must be piece #3! --- diff --git a/data/fmax.ini b/data/fmax.ini index fcc0ff4..627c1d6 100644 --- a/data/fmax.ini +++ b/data/fmax.ini @@ -887,4 +887,17 @@ b:400 15,3 17,3 -15,3 -17,3 R:500 1,3 16,3 -1,3 -16,3 Q:851 1,3 16,3 15,3 17,3 -1,3 -16,3 -15,3 -17,3 +// King of the Hill (King MUST be #3 and have value -2 to trigger hill eval) +Game: king-of-the-hill # PNBRQKpnbrqk # fairy +8x8 +6 4 5 7 3 5 4 6 +6 4 5 7 3 5 4 6 +p:66 -16,24 -16,6 -15,5 -17,5 +p:66 16,24 16,6 15,5 17,5 +k:-2 1,34 -1,34 1,7 16,7 15,7 17,7 -1,7 -16,7 -15,7 -17,7 +n:259 14,7 31,7 33,7 18,7 -14,7 -31,7 -33,7 -18,7 +b:296 15,3 17,3 -15,3 -17,3 +R:444 1,3 16,3 -1,3 -16,3 +Q:851 1,3 16,3 15,3 17,3 -1,3 -16,3 -15,3 -17,3 + // End of game file diff --git a/fairymax.c b/fairymax.c index 72dba19..568a08f 100644 --- a/fairymax.c +++ b/fairymax.c @@ -104,7 +104,7 @@ char Cambodian[80] = "makruk"; int Threshold = 800; int Score; int makruk; -int prom, pm, gating, succession; +int prom, pm, gating, succession, hill; char piecename[32], piecetype[32], blacktype[32]; char selectedFairy[80]; char *inifile = INI_FILE; @@ -170,6 +170,7 @@ int k,q,l,e,E,z,n; /* (q,l)=window, e=current eval. score, E=e.p. sqr.*/ do{u=b[x]; /* scan board looking for */ if(u&&(u&16)==k) /* own piece (inefficient!)*/ {r=p=u&15; /* p = piece type (set r>0) */ + if(hill&&w[p]<0&b[385+x])m=I,d=98; /* King on the hill: we won */ j=od[p]; /* first step vector f.piece*/ W(r=o[++j]) /* loop over directions o[] */ {A: /* resume normal after best */ @@ -198,7 +199,7 @@ 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=gt=0;G: /* retry move with gating */ - v+=centr[p]?b[x+257]-b[y+257]:0; /* center positional pts. */ + v+=centr[p]*(b[x+257]-b[y+257]); /* center positional pts. */ if(G-S)b[FF]=(rk=b[G])|32,v+=50; /* castling: put R & score */ b[G]=b[H]=0;b[x]=gt;b[y]=u|32; /* do move, set non-virgin */ pl[t&31]-=!!t; /* updat victim piece count */ @@ -400,8 +401,9 @@ void InitGame() 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 */ + L=8;W(L--)b[16*L+K+257]=(K-BW/2+hill/2.)*(K-BW/2+hill/2.)+(L-3.5)*(L-3.5); /* center-pts table */ } /*(in unused half b[])*/ + b[385+16*3+BW/2]=b[385+16*4+BW/2]=b[385+16*3+BW/2-1]=b[385+16*4+BW/2-1]=1; /* hill */ for(i=0; i15 || j>255) break; } - sh = w[7] < 250 ? 3 : 0; + sh = w[7] < 250 ? 3 : 0; hill = (w[3] == -2); if(ptc > 1) { // setup board in GUI, by sending it pieceToCharTable and FEN if(ptc == 2) printf("setup (%s) ", pieceToChar); else printf("setup (%s) %dx%d+0_%s ", pieceToChar, BW, BH, parent); @@ -579,6 +581,7 @@ int main(int argc, char **argv) if(tlim>TimeLeft/15) tlim = TimeLeft/15; PromPiece = 0; /* Always promote to Queen ourselves */ N=0;K=I; + if(hill) centr[3] = R>20 ? 1 : 22-R; if (D(Side,-I,I,Q,O,LL|S,3)==I) { Side ^= BLACK^WHITE; m = GetTickCount() - Ticks;