X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=72a261d4d09046cfe9617ac5e0a2084c50df984d;hp=57d6dc09bce917c7d9014f1d31340b6ed6134dd8;hb=673bc5526fa3d352f823ad144fb521b5dc98f45c;hpb=0439a79566d03065317b2025b9b479b9ae9f2d65 diff --git a/src/position.cpp b/src/position.cpp index 57d6dc09..72a261d4 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -92,33 +92,27 @@ CheckInfo::CheckInfo(const Position& pos) { } -/// Position c'tors. Here we always create a copy of the original position -/// or the FEN string, we want the new born Position object do not depend -/// on any external data so we detach state pointer from the source one. +/// Position::copy() creates a copy of 'pos'. We want the new born Position +/// object do not depend on any external data so we detach state pointer from +/// the source one. -void Position::copy(const Position& pos, int th) { +void Position::copy(const Position& pos, Thread* th) { memcpy(this, &pos, sizeof(Position)); startState = *st; st = &startState; - threadID = th; + thisThread = th; nodes = 0; assert(pos_is_ok()); } -Position::Position(const string& fen, bool isChess960, int th) { - - from_fen(fen, isChess960); - threadID = th; -} - /// Position::from_fen() initializes the position object with the given FEN /// string. This function is not very robust - make sure that input FENs are /// correct (this is assumed to be the responsibility of the GUI). -void Position::from_fen(const string& fenStr, bool isChess960) { +void Position::from_fen(const string& fenStr, bool isChess960, Thread* th) { /* A FEN string defines a particular position using only the ASCII character set. @@ -234,6 +228,7 @@ void Position::from_fen(const string& fenStr, bool isChess960) { st->npMaterial[BLACK] = compute_non_pawn_material(BLACK); st->checkersBB = attackers_to(king_square(sideToMove)) & pieces(~sideToMove); chess960 = isChess960; + thisThread = th; assert(pos_is_ok()); } @@ -336,7 +331,7 @@ void Position::print(Move move) const { if (move) { - Position p(*this, this_thread()); + Position p(*this, thisThread); cout << "\nMove is: " << (sideToMove == BLACK ? ".." : "") << move_to_san(p, move); } @@ -903,8 +898,8 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI } // Prefetch pawn and material hash tables - prefetch((char*)Threads[threadID].pawnTable.entries[st->pawnKey]); - prefetch((char*)Threads[threadID].materialTable.entries[st->materialKey]); + prefetch((char*)thisThread->pawnTable.entries[st->pawnKey]); + prefetch((char*)thisThread->materialTable.entries[st->materialKey]); // Update incremental scores st->psqScore += psq_delta(piece, from, to); @@ -1546,10 +1541,10 @@ void Position::init() { void Position::flip() { // Make a copy of current position before to start changing - const Position pos(*this, threadID); + const Position pos(*this, thisThread); clear(); - threadID = pos.this_thread(); + thisThread = &pos.this_thread(); // Board for (Square s = SQ_A1; s <= SQ_H8; s++)