1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

Remove castleRightsMask[] hack

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>
This commit is contained in:
Marco Costalba 2010-03-20 11:59:22 +01:00
parent 3de0bc43a2
commit b638f6b035
3 changed files with 1 additions and 7 deletions

View file

@ -44,8 +44,6 @@ using std::string;
//// Variables //// Variables
//// ////
int Position::castleRightsMask[64];
Key Position::zobrist[2][8][64]; Key Position::zobrist[2][8][64];
Key Position::zobEp[64]; Key Position::zobEp[64];
Key Position::zobCastle[16]; Key Position::zobCastle[16];

View file

@ -328,12 +328,12 @@ private:
Color sideToMove; Color sideToMove;
int gamePly; int gamePly;
Key history[MaxGameLength]; Key history[MaxGameLength];
int castleRightsMask[64];
File initialKFile, initialKRFile, initialQRFile; File initialKFile, initialKRFile, initialQRFile;
StateInfo startState; StateInfo startState;
StateInfo* st; StateInfo* st;
// Static variables // Static variables
static int castleRightsMask[64];
static Key zobrist[2][8][64]; static Key zobrist[2][8][64];
static Key zobEp[64]; static Key zobEp[64];
static Key zobCastle[16]; static Key zobCastle[16];

View file

@ -441,10 +441,6 @@ bool think(const Position& pos, bool infinite, bool ponder, int side_to_move,
{ {
TM.set_active_threads(newActiveThreads); TM.set_active_threads(newActiveThreads);
init_eval(TM.active_threads()); 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 // Wake up sleeping threads