X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fposition.cpp;h=3ae7f50ddae6a99e0c5bb6dbbbefd1ea00e3d84a;hb=8acb1d7e4ddb9627ed3c2910f6c47f466b94ad90;hp=dd6ec05b929d70088c68fd8a3aa40b77486680fb;hpb=76024ac40ea45e44a8389cb4206d40b884e259a5;p=stockfish diff --git a/src/position.cpp b/src/position.cpp index dd6ec05b..3ae7f50d 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -315,9 +315,10 @@ void Position::print(Move m) const { /// Position::copy() creates a copy of the input position. -void Position::copy(const Position &pos) { +void Position::copy(const Position& pos) { memcpy(this, &pos, sizeof(Position)); + saveState(); // detach and copy state info } @@ -1593,7 +1594,7 @@ int Position::see(Square from, Square to) const { if (pt == KING && stmAttackers) { assert(n < 32); - swapList[n++] = 100; + swapList[n++] = QueenValueMidgame*10; break; } } while (stmAttackers); @@ -1607,15 +1608,16 @@ int Position::see(Square from, Square to) const { } -/// Position::setStartState() copies the content of the argument +/// Position::saveState() copies the content of the current state /// inside startState and makes st point to it. This is needed /// when the st pointee could become stale, as example because /// the caller is about to going out of scope. -void Position::setStartState(const StateInfo& s) { +void Position::saveState() { - startState = s; + startState = *st; st = &startState; + st->previous = NULL; // as a safe guard } @@ -1966,7 +1968,7 @@ void Position::init_piece_square_tables() { /// the white and black sides reversed. This is only useful for debugging, /// especially for finding evaluation symmetry bugs. -void Position::flipped_copy(const Position &pos) { +void Position::flipped_copy(const Position& pos) { assert(pos.is_ok());