X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fposition.cpp;h=3c4fdc63805ca180017a73839a868c3b5bfbf571;hb=287556f97d54c87b3a973e22e133a9d09b62676f;hp=23ffbaa46593c8dad832a7ee6ebd0973a1820228;hpb=5dfbbb79beb198234a1dc42964e7e5936621813d;p=stockfish diff --git a/src/position.cpp b/src/position.cpp index 23ffbaa4..3c4fdc63 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -121,13 +121,12 @@ CheckInfo::CheckInfo(const Position& pos) { /// 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::Position(int th) : threadID(th) {} - Position::Position(const Position& pos, int th) { memcpy(this, &pos, sizeof(Position)); detach(); // Always detach() in copy c'tor to avoid surprises threadID = th; + nodes = 0; } Position::Position(const string& fen, int th) { @@ -752,6 +751,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI assert(is_ok()); assert(move_is_ok(m)); + nodes++; Key key = st->key; // Copy some fields of old state to our new StateInfo object except the @@ -765,7 +765,9 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI Value npMaterial[2]; }; - memcpy(&newSt, st, sizeof(ReducedStateInfo)); + if (&newSt != st) + memcpy(&newSt, st, sizeof(ReducedStateInfo)); + newSt.previous = st; st = &newSt; @@ -1477,6 +1479,7 @@ void Position::clear() { memset(st, 0, sizeof(StateInfo)); st->epSquare = SQ_NONE; startPosPlyCounter = 0; + nodes = 0; memset(byColorBB, 0, sizeof(Bitboard) * 2); memset(byTypeBB, 0, sizeof(Bitboard) * 8);