Value castling rights
authorH.G.Muller <hgm@hgm-xboard.(none)>
Sat, 14 Jan 2017 12:06:23 +0000 (13:06 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Sat, 14 Jan 2017 12:06:23 +0000 (13:06 +0100)
The evaluation now takes possesion of castling rights into account.
It is also figured out if castling is actually possible.

dropper.c

index 219c868..bbaf83d 100644 (file)
--- a/dropper.c
+++ b/dropper.c
@@ -691,15 +691,17 @@ typedef struct {   // move stack sectioning
     int castlings; // end of list of board moves without castlings
     int epSqr;
     int checker;
-    int safety, hole, escape;
+    int safety, cBonus, hole, escape;
 } MoveStack;
 
 HashEntry *hashTable;
 Key hashKey, pawnKey;
 int hashMask;
 
+static int rightsScore[] = { 0, -10, 10, 0, -10, -30, 0, -20, 10, 0, 30, 20, 0, -20, 20, 0 };
+
 int
-Evaluate (int stm)
+Evaluate (int stm, int rights)
 {
     int k, score = 0;
     k = location[31];
@@ -711,6 +713,7 @@ Evaluate (int stm)
     score += !board[k-22] + !board[k-22+1] + !board[k-22-1];
     score += ((board[k-44] == WHITE) + (board[k-44+1] == WHITE) + (board[k-44-1] == WHITE))*5;
     score *= 20;
+    score += rightsScore[rights];
     return stm == WHITE ? score : -score;
 }
 
@@ -812,6 +815,7 @@ MoveGen (int stm, MoveStack *m, int castle)
        f++;
        if(board[r-1] == 0 && board[r-2] == 0 && board[r-3] == 0) f += 2, moveStack[moveSP++] = r << 8 | 8*22+21 + 22*(stm == BLACK);
     }
+    m->cBonus = f;
 
     r = location[stm+31^COLOR]; // enemy King
 #   define HOLE(X) (attacks[X] == c)*!board[X]
@@ -1095,7 +1099,7 @@ if(hashMove && board[hashMove>>8&255] == 0) {char s[100];sprintf(s,"bad hash mov
     }
 
     if((++nodeCount & 0xFFF) == 0) abortFlag |= TimeIsUp(3); // check time limit every 4K nodes
-    curEval = f.pstEval + Evaluate(stm);
+    curEval = f.pstEval + Evaluate(stm, f.rights);
     alpha -= (alpha < curEval); //pre-compensate delayed-loss bonus
     beta  -= (beta <= curEval);
     killers[ply+1][0] = killers[ply+1][1] = 0;