1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-01 17:19:36 +00:00

Workaround a bug in Position::has_mate_threat()

It seems that pos.has_mate_threat() changes the position !

So that calling MovePicker c'tor before or after the
has_mate_threat() call changes the things !

Bug was unhidden by previous patch that makes MovePicker c'tor
to generate, score and sort good captures under some circumstances.

Because scoring the captures is position dependent it seems that
the moves returned by MovePicker are different when c'tor is
called before has_mate_threat()

Of course this is only a workaround because the real bug is still
hidden :-(

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2009-08-30 19:12:08 +01:00
parent 1130c8d815
commit af220cfd52

View file

@ -1091,16 +1091,16 @@ namespace {
// Initialize a MovePicker object for the current position, and prepare // Initialize a MovePicker object for the current position, and prepare
// to search all moves // to search all moves
MovePicker mp = MovePicker(pos, ttMove, depth, H, &ss[ply]);
Move move, movesSearched[256]; Move move, movesSearched[256];
int moveCount = 0; int moveCount = 0;
Value value, bestValue = -VALUE_INFINITE; Value value, bestValue = -VALUE_INFINITE;
Bitboard dcCandidates = mp.discovered_check_candidates();
Color us = pos.side_to_move(); Color us = pos.side_to_move();
bool isCheck = pos.is_check(); bool isCheck = pos.is_check();
bool mateThreat = pos.has_mate_threat(opposite_color(us)); bool mateThreat = pos.has_mate_threat(opposite_color(us));
MovePicker mp = MovePicker(pos, ttMove, depth, H, &ss[ply]);
Bitboard dcCandidates = mp.discovered_check_candidates();
// Loop through all legal moves until no moves remain or a beta cutoff // Loop through all legal moves until no moves remain or a beta cutoff
// occurs. // occurs.
while ( alpha < beta while ( alpha < beta