mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
Third attempt: hopefully the last one
This commit is contained in:
parent
de5a03ff0f
commit
36d6a1fd0a
1 changed files with 11 additions and 4 deletions
|
@ -1499,21 +1499,28 @@ int Tablebases::probe_dtz(Position& pos, ProbeState* result)
|
|||
|
||||
for (const Move& move : MoveList<LEGAL>(pos))
|
||||
{
|
||||
bool isZeroingMove = pos.capture(move) || type_of(pos.moved_piece(move)) == PAWN;
|
||||
bool zeroing = pos.capture(move) || type_of(pos.moved_piece(move)) == PAWN;
|
||||
|
||||
pos.do_move(move, st, pos.gives_check(move, ci));
|
||||
dtz = isZeroingMove ? -zeroing_move_dtz(wdl) : -probe_dtz(pos, result);
|
||||
|
||||
// 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
|
||||
// position after the move to get the score sign (because even in a
|
||||
// winning position we could make a losing capture or going for a draw).
|
||||
dtz = zeroing ? -zeroing_move_dtz(search(pos, WDLLoss, WDLWin, result))
|
||||
: -probe_dtz(pos, result);
|
||||
|
||||
pos.undo_move(move);
|
||||
|
||||
if (*result == FAIL)
|
||||
return 0;
|
||||
|
||||
// Skip the draws and ensure that if we are winning we pick only positive dtz
|
||||
// Skip the draws and if we are winning only pick positive dtz
|
||||
if (dtz < minDTZ && sign_of(dtz) == sign_of(wdl))
|
||||
minDTZ = dtz;
|
||||
}
|
||||
|
||||
return minDTZ > 0 ? minDTZ + 1 : minDTZ - 1; // Convert result from 1-ply search
|
||||
return minDTZ + sign_of(minDTZ); // Convert result from 1-ply search
|
||||
}
|
||||
|
||||
// Check whether there has been at least one repetition of positions
|
||||
|
|
Loading…
Add table
Reference in a new issue