]> git.sesse.net Git - stockfish/commitdiff
Remove castleRightsMask[] hack
authorMarco Costalba <mcostalba@gmail.com>
Sat, 20 Mar 2010 10:59:22 +0000 (11:59 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 20 Mar 2010 10:59:22 +0000 (11:59 +0100)
Array castleRightsMask[] is not static because it can
be different for different positions, so let it be
a Position member data. This allows to remove tricky
hacks to take in account that although it was defined
static it could change.

Theoretically now copying a position is a bit slower because
we need to copy also an array of 64 integers, but because in
split() we don't copy the position anymore, but just keep the
pointer, the added burden is not mesurable even in MP case.

No functional change.

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

index 5b4dba70abc21fb7ad56c37dd0937ecfd24cbf28..ade1c5d23327470838bb566ebb665e0a0096578b 100644 (file)
@@ -44,8 +44,6 @@ using std::string;
 //// Variables
 ////
 
-int Position::castleRightsMask[64];
-
 Key Position::zobrist[2][8][64];
 Key Position::zobEp[64];
 Key Position::zobCastle[16];
index 0fce1860991eaec247937736062de163d2091b53..71f821b2b3183144849d200242b4250743d71f57 100644 (file)
@@ -328,12 +328,12 @@ private:
   Color sideToMove;
   int gamePly;
   Key history[MaxGameLength];
+  int castleRightsMask[64];
   File initialKFile, initialKRFile, initialQRFile;
   StateInfo startState;
   StateInfo* st;
 
   // Static variables
-  static int castleRightsMask[64];
   static Key zobrist[2][8][64];
   static Key zobEp[64];
   static Key zobCastle[16];
index fcadc9228992155d11eb9f4729014442d3424cb8..4592ac084ebc56d60a59b83415167bd2f75af146 100644 (file)
@@ -441,10 +441,6 @@ bool think(const Position& pos, bool infinite, bool ponder, int side_to_move,
   {
       TM.set_active_threads(newActiveThreads);
       init_eval(TM.active_threads());
-      // HACK: init_eval() destroys the static castleRightsMask[] array in the
-      // Position class. The below line repairs the damage.
-      Position p(pos.to_fen());
-      assert(pos.is_ok());
   }
 
   // Wake up sleeping threads