mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 09:13:08 +00:00
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.
This commit is contained in:
parent
de269ee18e
commit
e6c2899020
4 changed files with 15 additions and 10 deletions
|
@ -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
|
||||
|
|
|
@ -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<LEGAL>(pos).size() : perft<false>(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<NonPV>(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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue