From e6c289902069b7bc262ddaf86a21884867d8f83b Mon Sep 17 00:00:00 2001 From: Aram Tumanian Date: Fri, 11 Nov 2016 15:02:28 +0200 Subject: [PATCH] Make a version of Position::do_move() without the givesCheck parameter In 10 of 12 calls total to Position::do_move()the givesCheck argument is simply gives_check(m). So it's reasonable to make an overload without this parameter, which wraps the existing version. No functional change. --- src/position.h | 5 +++++ src/search.cpp | 10 +++++----- src/syzygy/tbprobe.cpp | 8 ++++---- src/uci.cpp | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/position.h b/src/position.h index 21ab63fe..98928277 100644 --- a/src/position.h +++ b/src/position.h @@ -128,6 +128,7 @@ public: bool opposite_bishops() const; // Doing and undoing moves + void do_move(Move m, StateInfo& newSt); void do_move(Move m, StateInfo& newSt, bool givesCheck); void undo_move(Move m); void do_null_move(StateInfo& newSt); @@ -412,4 +413,8 @@ inline void Position::move_piece(Piece pc, Square from, Square to) { pieceList[pc][index[to]] = to; } +inline void Position::do_move(Move m, StateInfo& newSt) { + do_move(m, newSt, gives_check(m)); +} + #endif // #ifndef POSITION_H_INCLUDED diff --git a/src/search.cpp b/src/search.cpp index 7f933a46..6699991a 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -113,8 +113,8 @@ namespace { std::copy(newPv.begin(), newPv.begin() + 3, pv); StateInfo st[2]; - pos.do_move(newPv[0], st[0], pos.gives_check(newPv[0])); - pos.do_move(newPv[1], st[1], pos.gives_check(newPv[1])); + pos.do_move(newPv[0], st[0]); + pos.do_move(newPv[1], st[1]); expectedPosKey = pos.key(); pos.undo_move(newPv[1]); pos.undo_move(newPv[0]); @@ -234,7 +234,7 @@ uint64_t Search::perft(Position& pos, Depth depth) { cnt = 1, nodes++; else { - pos.do_move(m, st, pos.gives_check(m)); + pos.do_move(m, st); cnt = leaf ? MoveList(pos).size() : perft(pos, depth - ONE_PLY); nodes += cnt; pos.undo_move(m); @@ -801,7 +801,7 @@ namespace { { ss->currentMove = move; ss->counterMoves = &thisThread->counterMoveHistory[pos.moved_piece(move)][to_sq(move)]; - pos.do_move(move, st, pos.gives_check(move)); + pos.do_move(move, st); value = -search(pos, ss+1, -rbeta, -rbeta+1, rdepth, !cutNode); pos.undo_move(move); if (value >= rbeta) @@ -1600,7 +1600,7 @@ bool RootMove::extract_ponder_from_tt(Position& pos) { if (!pv[0]) return false; - pos.do_move(pv[0], st, pos.gives_check(pv[0])); + pos.do_move(pv[0], st); TTEntry* tte = TT.probe(pos.key(), ttHit); if (ttHit) diff --git a/src/syzygy/tbprobe.cpp b/src/syzygy/tbprobe.cpp index 9debcc6f..22b3697c 100644 --- a/src/syzygy/tbprobe.cpp +++ b/src/syzygy/tbprobe.cpp @@ -1207,7 +1207,7 @@ WDLScore search(Position& pos, ProbeState* result) { moveCount++; - pos.do_move(move, st, pos.gives_check(move)); + pos.do_move(move, st); value = -search(pos, result); pos.undo_move(move); @@ -1455,7 +1455,7 @@ int Tablebases::probe_dtz(Position& pos, ProbeState* result) { { bool zeroing = pos.capture(move) || type_of(pos.moved_piece(move)) == PAWN; - pos.do_move(move, st, pos.gives_check(move)); + pos.do_move(move, st); // For zeroing moves we want the dtz of the move _before_ doing it, // otherwise we will get the dtz of the next move sequence. Search the @@ -1529,7 +1529,7 @@ bool Tablebases::root_probe(Position& pos, Search::RootMoves& rootMoves, Value& // Probe each move for (size_t i = 0; i < rootMoves.size(); ++i) { Move move = rootMoves[i].pv[0]; - pos.do_move(move, st, pos.gives_check(move)); + pos.do_move(move, st); int v = 0; if (pos.checkers() && dtz > 0) { @@ -1665,7 +1665,7 @@ bool Tablebases::root_probe_wdl(Position& pos, Search::RootMoves& rootMoves, Val // Probe each move for (size_t i = 0; i < rootMoves.size(); ++i) { Move move = rootMoves[i].pv[0]; - pos.do_move(move, st, pos.gives_check(move)); + pos.do_move(move, st); WDLScore v = -Tablebases::probe_wdl(pos, &result); pos.undo_move(move); diff --git a/src/uci.cpp b/src/uci.cpp index 0b3e3a51..0f1c6943 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -76,7 +76,7 @@ namespace { while (is >> token && (m = UCI::to_move(pos, token)) != MOVE_NONE) { States->push_back(StateInfo()); - pos.do_move(m, States->back(), pos.gives_check(m)); + pos.do_move(m, States->back()); } } -- 2.39.2