Rehash repetition keys in steps of 1
authorH.G.Muller <hgm@hgm-xboard.(none)>
Mon, 15 May 2017 20:14:21 +0000 (22:14 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Mon, 15 May 2017 20:14:21 +0000 (22:14 +0200)
The repetition key hash table does not store white and black moves
alternately, but in different halves of the table, so to find a slot
for re-hashing we better hunt for empty slots in steps of 1.

dropper.c

index 1200942..ad36e37 100644 (file)
--- a/dropper.c
+++ b/dropper.c
@@ -1330,7 +1330,7 @@ if(PATH)printf("%d:%d:%d new iter moveStack[%d..%d]\n",ply,depth,iterDepth,m.fir
 
                // repetition checking
                int index = (unsigned int)f.newKey >> 24 ^ stm << 2; // uses high byte of low (= hands-free) key
-               while(repKey[index] && (repKey[index] ^ (int)f.newKey) & 0x1FFFFF) index += 2;
+               while(repKey[index] && (repKey[index] ^ (int)f.newKey) & 0x1FFFFF) index++;
                int oldRepKey = repKey[index], oldRepDep = repDep[index];
                if(oldRepKey && ff->mutation != -2) { // key present in table: (quasi-)repetition
                    int gain = (f.newEval << 21) - (repKey[index] & 0xFFE00000);
@@ -1672,7 +1672,7 @@ RootMakeMove(int move)
   if(moveNr >= 19 && !perpLoses) PST[WHITE+1] = knightPST, PST[BLACK+1] = knightPST + 11;
   // store in game history hash table
   index = (unsigned int)undoInfo.newKey >> 24 ^ stm << 2; // uses high byte of low (= hands-free) key
-  while(repKey[index] && (repKey[index] ^ (int)undoInfo.newKey) & 0x1FFFFF) index += 2; // find empty slot
+  while(repKey[index] && (repKey[index] ^ (int)undoInfo.newKey) & 0x1FFFFF) index++; // find empty slot
   repKey[index] = (int)undoInfo.newKey & 0x1FFFFF | undoInfo.newEval << 21; // remember position
   repDep[index] = moveNr;
   stm ^= COLOR; moveNr++;