X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=62749a913b75cfaa5e317c43bd8879e7370009f6;hp=57d6dc09bce917c7d9014f1d31340b6ed6134dd8;hb=e1919384a23fe728422f995369161efa192380db;hpb=0439a79566d03065317b2025b9b479b9ae9f2d65 diff --git a/src/position.cpp b/src/position.cpp index 57d6dc09..62749a91 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -92,25 +92,17 @@ 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::operator=() 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) { +Position& Position::operator=(const Position& pos) { memcpy(this, &pos, sizeof(Position)); startState = *st; st = &startState; - threadID = th; nodes = 0; - - assert(pos_is_ok()); -} - -Position::Position(const string& fen, bool isChess960, int th) { - - from_fen(fen, isChess960); - threadID = th; + return *this; } @@ -336,7 +328,7 @@ void Position::print(Move move) const { if (move) { - Position p(*this, this_thread()); + Position p(*this); cout << "\nMove is: " << (sideToMove == BLACK ? ".." : "") << move_to_san(p, move); } @@ -903,8 +895,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*)Threads.this_thread()->pawnTable.entries[st->pawnKey]); + prefetch((char*)Threads.this_thread()->materialTable.entries[st->materialKey]); // Update incremental scores st->psqScore += psq_delta(piece, from, to); @@ -1546,10 +1538,9 @@ 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); clear(); - threadID = pos.this_thread(); // Board for (Square s = SQ_A1; s <= SQ_H8; s++)