mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 11:39:15 +00:00
Fix moveCount after legality check delay
We really want PV moves and also Split Point moves to be legal to avoid messing the move counter and corresonding PV move detection or shared Split Point's counter variable. This fixes a real bug where a position with only one move allowed returns bestValue == -VALUE_INFINITE if the move turns out to be illegal. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
4c3a000211
commit
853e2a9495
1 changed files with 13 additions and 6 deletions
|
@ -904,13 +904,18 @@ split_point_start: // At split points actual search starts from here
|
|||
{
|
||||
assert(move_is_ok(move));
|
||||
|
||||
if (move == excludedMove)
|
||||
continue;
|
||||
|
||||
// At PV and SpNode nodes we want the moves to be legal
|
||||
if ((PvNode || SpNode) && !pos.pl_move_is_legal(move, pinned))
|
||||
continue;
|
||||
|
||||
if (SpNode)
|
||||
{
|
||||
moveCount = ++sp->moveCount;
|
||||
lock_release(&(sp->lock));
|
||||
}
|
||||
else if (move == excludedMove)
|
||||
continue;
|
||||
else
|
||||
moveCount++;
|
||||
|
||||
|
@ -1026,7 +1031,10 @@ split_point_start: // At split points actual search starts from here
|
|||
|
||||
// Check for legality only before to do the move
|
||||
if (!pos.pl_move_is_legal(move, pinned))
|
||||
{
|
||||
moveCount--;
|
||||
continue;
|
||||
}
|
||||
|
||||
ss->currentMove = move;
|
||||
|
||||
|
@ -1370,7 +1378,8 @@ split_point_start: // At split points actual search starts from here
|
|||
}
|
||||
|
||||
// Detect non-capture evasions that are candidate to be pruned
|
||||
evasionPrunable = inCheck
|
||||
evasionPrunable = !PvNode
|
||||
&& inCheck
|
||||
&& bestValue > VALUE_MATED_IN_PLY_MAX
|
||||
&& !pos.move_is_capture(move)
|
||||
&& !pos.can_castle(pos.side_to_move());
|
||||
|
@ -1995,12 +2004,10 @@ split_point_start: // At split points actual search starts from here
|
|||
|
||||
pos.do_move(pv[0], *st++);
|
||||
|
||||
Bitboard pinned = pos.pinned_pieces(pos.side_to_move());
|
||||
|
||||
while ( (tte = TT.probe(pos.get_key())) != NULL
|
||||
&& tte->move() != MOVE_NONE
|
||||
&& pos.move_is_pl(tte->move())
|
||||
&& pos.pl_move_is_legal(tte->move(), pinned)
|
||||
&& pos.pl_move_is_legal(tte->move(), pos.pinned_pieces(pos.side_to_move()))
|
||||
&& ply < PLY_MAX
|
||||
&& (!pos.is_draw() || ply < 2))
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue