mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 19:49:14 +00:00
Simplify Position::is_mate()
Should be a bit faster too. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
a52ab2afbf
commit
2acc89c6e8
1 changed files with 11 additions and 15 deletions
|
@ -1867,21 +1867,6 @@ Value Position::compute_non_pawn_material(Color c) const {
|
|||
}
|
||||
|
||||
|
||||
/// Position::is_mate() returns true or false depending on whether the
|
||||
/// side to move is checkmated. Note that this function is currently very
|
||||
/// slow, and shouldn't be used frequently inside the search.
|
||||
|
||||
bool Position::is_mate() const {
|
||||
|
||||
if (is_check())
|
||||
{
|
||||
MovePicker mp = MovePicker(*this, false, MOVE_NONE, EmptySearchStack, Depth(0));
|
||||
return mp.get_next_move() == MOVE_NONE;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// Position::is_draw() tests whether the position is drawn by material,
|
||||
/// repetition, or the 50 moves rule. It does not detect stalemates, this
|
||||
/// must be done by the search.
|
||||
|
@ -1906,6 +1891,17 @@ bool Position::is_draw() const {
|
|||
}
|
||||
|
||||
|
||||
/// Position::is_mate() returns true or false depending on whether the
|
||||
/// side to move is checkmated.
|
||||
|
||||
bool Position::is_mate() const {
|
||||
|
||||
MoveStack moves[256];
|
||||
|
||||
return is_check() && !generate_evasions(*this, moves, pinned_pieces(sideToMove));
|
||||
}
|
||||
|
||||
|
||||
/// Position::has_mate_threat() tests whether a given color has a mate in one
|
||||
/// from the current position. This function is quite slow, but it doesn't
|
||||
/// matter, because it is currently only called from PV nodes, which are rare.
|
||||
|
|
Loading…
Add table
Reference in a new issue