Reject obviously wrong hash move
authorH.G.Muller <hgm@hgm-xboard.(none)>
Mon, 6 Feb 2017 22:13:01 +0000 (23:13 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Mon, 6 Feb 2017 22:13:01 +0000 (23:13 +0100)
A move with a piece of the wrong color, or a drop of a piece not in hand
will now not be accepted as hash move, and cause the hashed in-check info
to be ignored.

dropper.c

index 912f5f0..95b7608 100644 (file)
--- a/dropper.c
+++ b/dropper.c
@@ -1115,6 +1115,8 @@ if(PATH)printf("%d:%d   Hash Probe %016llx\n",ply,depth,f.hashKey);
     entry = hashTable + (f.hashKey + (stm + 9849 + f.rights)*(m.epSqr + 51451) & hashMask);
     if(entry->lock == hashKeyH || (++entry)->lock == hashKeyH || (++entry)->lock == hashKeyH || (++entry)->lock == hashKeyH) { // 4 possible entries
        int score = entry->score, d = entry->depth;
+       signed char p;
+
        f.checker = entry->checker; f.checkDist = 0;
        if(f.checker != CK_NONE) { // in check; restore info needed in evasion test
            if(sqr2file[f.checker] != 12) f.checkDir = 0; else { // off-board represents on-board distant check
@@ -1134,6 +1136,10 @@ if(PATH)printf("      Hit, d=%d, checker = %x\n",entry->depth,f.checker);
        hashMove = entry->move;
 if(hashMove && board[hashMove>>8&255] == 0) {char s[100];sprintf(s,"bad hash move %16llx: %s\n", f.hashKey, MoveToText(hashMove)); Dump(s); }
        hit = 1;
+       p = board[hashMove>>8&255];
+       if(hashMove && ((p & stm) == 0 || p == -1)) {
+           hashMove = 0; f.checker = CK_UNKNOWN;
+       }
     } else hit = hashMove = 0, f.checker = CK_UNKNOWN;
 
     moveSP += 48;  // create space for non-captures