]> git.sesse.net Git - stockfish/commitdiff
Fix 'generation' type to uint8_t
authorMarco Costalba <mcostalba@gmail.com>
Mon, 22 Nov 2010 17:40:36 +0000 (18:40 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 28 Nov 2010 16:01:01 +0000 (17:01 +0100)
When we store this value in TT we cut this to 9 bits,
so we need a smaller variable otherwise comparisons
like:

   replace->generation() == generation

Are always false if generation is bigger then the maximum
TT storable value.

This fixes a very nasty and difficult to spot bug (2 weeks for
regression hunting).

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/movepick.cpp
src/movepick.h
src/tt.h

index 264d941f602b45368c5871afa87e6a6d16691da0..2e8eb665b9acd04573c9e438d77212f2888ccff6 100644 (file)
@@ -51,10 +51,10 @@ namespace {
   };
 
   CACHE_LINE_ALIGNMENT
   };
 
   CACHE_LINE_ALIGNMENT
-  const int MainSearchPhaseTable[] = { PH_TT_MOVES, PH_GOOD_CAPTURES, PH_KILLERS, PH_NONCAPTURES, PH_BAD_CAPTURES, PH_STOP};
-  const int EvasionsPhaseTable[] = { PH_TT_MOVES, PH_EVASIONS, PH_STOP};
-  const int QsearchWithChecksPhaseTable[] = { PH_TT_MOVES, PH_QCAPTURES, PH_QCHECKS, PH_STOP};
-  const int QsearchWithoutChecksPhaseTable[] = { PH_TT_MOVES, PH_QCAPTURES, PH_STOP};
+  const uint8_t MainSearchPhaseTable[] = { PH_TT_MOVES, PH_GOOD_CAPTURES, PH_KILLERS, PH_NONCAPTURES, PH_BAD_CAPTURES, PH_STOP};
+  const uint8_t EvasionsPhaseTable[] = { PH_TT_MOVES, PH_EVASIONS, PH_STOP};
+  const uint8_t QsearchWithChecksPhaseTable[] = { PH_TT_MOVES, PH_QCAPTURES, PH_QCHECKS, PH_STOP};
+  const uint8_t QsearchWithoutChecksPhaseTable[] = { PH_TT_MOVES, PH_QCAPTURES, PH_STOP};
 }
 
 
 }
 
 
index c656deaf44bc319ac06fd37bdc679d894ab03422..c71ff1a990f98879c842c483dfc67560039ed440 100644 (file)
@@ -64,7 +64,7 @@ private:
   Bitboard pinned;
   MoveStack ttMoves[2], killers[2];
   int badCaptureThreshold, phase;
   Bitboard pinned;
   MoveStack ttMoves[2], killers[2];
   int badCaptureThreshold, phase;
-  const int* phasePtr;
+  const uint8_t* phasePtr;
   MoveStack *curMove, *lastMove, *lastGoodNonCapture, *badCaptures;
   MoveStack moves[MOVES_MAX];
 };
   MoveStack *curMove, *lastMove, *lastGoodNonCapture, *badCaptures;
   MoveStack moves[MOVES_MAX];
 };
index ff1cb910f63035d1d9582fe652d9c91171dc521d..ee10b3f0d9e28bbedd0e892b13cccfb5c8a58538 100644 (file)
--- a/src/tt.h
+++ b/src/tt.h
@@ -120,7 +120,7 @@ public:
 private:
   size_t size;
   TTCluster* entries;
 private:
   size_t size;
   TTCluster* entries;
-  int generation;
+  uint8_t generation; // To properly compare, size must be smaller then TT stored value
 };
 
 extern TranspositionTable TT;
 };
 
 extern TranspositionTable TT;