X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=18f4978da197241f5ab3d437e56c123cd2c58bbb;hp=962fa87829407398fef17c0b26702927437d3443;hb=ad1f28bc1c1c5426fb8ab246f5d43ad57002b4d5;hpb=69f4954df1de3ed264212a6e871986781d717e08 diff --git a/src/position.cpp b/src/position.cpp index 962fa878..18f4978d 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -30,7 +30,6 @@ #include "rkiss.h" #include "thread.h" #include "tt.h" -#include "ucioption.h" using std::string; using std::cout; @@ -103,6 +102,8 @@ Position::Position(const Position& pos, int th) { detach(); // Always detach() in copy c'tor to avoid surprises threadID = th; nodes = 0; + + assert(is_ok()); } Position::Position(const string& fen, bool isChess960, int th) { @@ -214,6 +215,8 @@ void Position::from_fen(const string& fenStr, bool isChess960) { st->value = compute_value(); st->npMaterial[WHITE] = compute_non_pawn_material(WHITE); st->npMaterial[BLACK] = compute_non_pawn_material(BLACK); + + assert(is_ok()); } @@ -492,7 +495,6 @@ bool Position::move_attacks_square(Move m, Square s) const { bool Position::pl_move_is_legal(Move m, Bitboard pinned) const { - assert(is_ok()); assert(move_is_ok(m)); assert(pinned == pinned_pieces()); @@ -559,8 +561,6 @@ bool Position::move_is_legal(const Move m) const { bool Position::move_is_pl(const Move m) const { - assert(is_ok()); - Color us = sideToMove; Color them = opposite_color(sideToMove); Square from = move_from(m); @@ -683,7 +683,6 @@ bool Position::move_is_pl(const Move m) const { bool Position::move_gives_check(Move m, const CheckInfo& ci) const { - assert(is_ok()); assert(move_is_ok(m)); assert(ci.dcCandidates == discovered_check_candidates()); assert(piece_color(piece_on(move_from(m))) == side_to_move()); @@ -794,6 +793,8 @@ void Position::do_setup_move(Move m) { // Our StateInfo newSt is about going out of scope so copy // its content before it disappears. detach(); + + assert(is_ok()); } @@ -809,7 +810,6 @@ void Position::do_move(Move m, StateInfo& newSt) { void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveIsCheck) { - assert(is_ok()); assert(move_is_ok(m)); assert(&newSt != st); @@ -1181,7 +1181,6 @@ void Position::do_castle_move(Move m) { void Position::undo_move(Move m) { - assert(is_ok()); assert(move_is_ok(m)); sideToMove = opposite_color(sideToMove); @@ -1355,7 +1354,6 @@ void Position::undo_castle_move(Move m) { void Position::do_null_move(StateInfo& backupSt) { - assert(is_ok()); assert(!in_check()); // Back up the information necessary to undo the null move to the supplied @@ -1385,6 +1383,8 @@ void Position::do_null_move(StateInfo& backupSt) { st->rule50++; st->pliesFromNull = 0; st->value += (sideToMove == WHITE) ? TempoValue : -TempoValue; + + assert(is_ok()); } @@ -1392,7 +1392,6 @@ void Position::do_null_move(StateInfo& backupSt) { void Position::undo_null_move() { - assert(is_ok()); assert(!in_check()); // Restore information from the our backup StateInfo object @@ -1407,6 +1406,8 @@ void Position::undo_null_move() { sideToMove = opposite_color(sideToMove); st->rule50--; st->gamePly--; + + assert(is_ok()); } @@ -1757,8 +1758,6 @@ void Position::init() { void Position::flip() { - assert(is_ok()); - // Make a copy of current position before to start changing const Position pos(*this, threadID);