Thanks, will investigate. There is an exception to the 50 move rule, in that the position is not drawn if one side is mated, regardless of how many reversible moves have been made. This is probably not handled correctly based on this game...
int fullSearch(...) {
if (isInCheck()) setCheckFlag();
// ...
if (fifty() >= 100 && !isCheckFlagSet()) {
// draw by 50 moves rule detected when not in check
return 0;
}
// ...
for (ALL LEGAL MOVES) {
// regular search ...
}
if (NO LEGAL MOVES WERE FOUND) {
bestValue = (isCheckFlagSet() ? -MATE_VALUE(...) : 0);
} else
if (fifty() >= 100) {
ASSERT(isCheckFlagSet());
// in check but not mated => draw by 50 moves rule
bestValue = 0;
}
// ...
return bestValue;
}
It is possible that checking for 50 moves draw also before searching all moves is redundant and skipping this is slightly faster, I have not tested whether this makes any difference. But at least doing it twice looks "logical" for me.
While you are at it: there also are rumors hat Crafty makes false draw claims (i.e. in violation of FIDE rules) in KBKN end-games.
I don't think it matters. Player or computer, I'd still offer a draw playing a game.
It's only polite to offer a draw in this endgame. Who wants to move 50 more times? Any FIDE player will accept a draw or just blunder 1 of the pieces too force a draw from lack of mating material...
jhaglund wrote:I don't think it matters. Player or computer, I'd still offer a draw playing a game.
It's only polite to offer a draw in this endgame. Who wants to move 50 more times? Any FIDE player will accept a draw or just blunder 1 of the pieces too force a draw from lack of mating material...
Offering is not the same as claiming. As it is, Crafty forfeits games by this, and I would say that does matter. If it wants to offer a draw, it should offer it, not one-sidedly terminate the game.
On top of this, there are situations where there is a forced mate that ends in KBKN, because the opponent has to recapture a piece (converting to KBKN) after which he is mated. I have not tested if Crafty makes an exception for this case, but engines that unconditionally declare draw as soon as the material is KBKN will declare draw in some won or lost positions.
bob wrote:Thanks, will investigate. There is an exception to the 50 move rule, in that the position is not drawn if one side is mated, regardless of how many reversible moves have been made. This is probably not handled correctly based on this game...
I can't see such an exception in the 23.1 code. In Search(), line 68, you return with a draw score if the function RepetitionCheck() has returned non-zero. This happens before searching all moves. RepetitionCheck() also handles the 50 moves draw and returns 1 if the 50 moves counter is >= 100. Since mate detection occurs later within Search(), this implementation can't detect the case shown here IMO. Please correct me if I have misunderstood your code.
I propose to separate repetition detection from 50 moves detection by moving the 50-moves related code from RepetitionCheck() into a new function which is then called right below the mate detection code at the bottom of Search(). There should be almost zero performance impact.