While writing some search function I had this problem:
What happens if a player makes a move that results in the last 50 moves
having been played without any captures or pawn moves, but also gives
checkmate? Is the game a win or a draw?
[D]1k6/8/1K6/8/8/8/8/7R w - - 99 99
Is Rh8 a mate or a draw by 50 move rule?
Harald
Draw by 50 move rule or mate
Moderators: hgm, Rebel, chrisw
-
- Posts: 10297
- Joined: Thu Mar 09, 2006 12:37 am
- Location: Tel-Aviv Israel
Re: Draw by 50 move rule or mate
mate.
You first check for mate and only if there is no mate you check for draw by the 50 move rule.
Edit:I can add that the fide rule does not say that 50 move rule is a draw automatically and the player needs to claim the draw to get it.
Mate ends the game so it is too late to claim a draw after a move that cause checkmate and in this case before the move there was no basis to claim a draw because there were only 99 plies with no capture or pawn move.
You first check for mate and only if there is no mate you check for draw by the 50 move rule.
Edit:I can add that the fide rule does not say that 50 move rule is a draw automatically and the player needs to claim the draw to get it.
Mate ends the game so it is too late to claim a draw after a move that cause checkmate and in this case before the move there was no basis to claim a draw because there were only 99 plies with no capture or pawn move.
-
- Posts: 613
- Joined: Sun Jan 18, 2009 7:03 am
Re: Draw by 50 move rule or mate
It's win.Harald wrote:While writing some search function I had this problem:
What happens if a player makes a move that results in the last 50 moves
having been played without any captures or pawn moves, but also gives
checkmate? Is the game a win or a draw?
[D]1k6/8/1K6/8/8/8/8/7R w - - 99 99
Is Rh8 a mate or a draw by 50 move rule?
Harald
In Stockfish the draw detection goes:
if (st->rule50 > 99 && !is_mate())
return true;
Joona Kiiski
-
- Posts: 318
- Joined: Thu Mar 09, 2006 1:07 am
Re: Draw by 50 move rule or mate
Thank you.
Mate and stalemate have a higher priority than a draw by 50 move rule.
Then I can use a function like this at the end or after the make_move() function:
Perhaps the mate detection should rely on deeper search() but I like my
code clean, modular and easy to understand. Therefore I do some
experiments with this function.
By the way, how does perft() handle draw by repetition?
Harald
Mate and stalemate have a higher priority than a draw by 50 move rule.
Then I can use a function like this at the end or after the make_move() function:
Code: Select all
// Check position for draw or mate.
// Insufficiant mating material is a draw.
// The repetition table must include all previous moves to find draw by repetition.
// Mates are only checked when it is requested because it is slow.
// In that case pos.checked_ must be correct.
// Finally the draw by 50 moves rule is checked.
//
DrawOrMateType check_draw_or_mate( Position & pos, const RepetitionDetectionTable & repetition_detection_table, bool check_mates )
{
// Check if there is insufficient mating material.
// Kk, KNk, KBk, Kkn, Kkb
// KBkb both white/black squared bishops
if ( pos.material_.draw_material() )
{
return DrawMaterial;
}
// Get the repetition counter of a position key in the repetition detection hash table.
// Return the repetition counter or -1 if the entry does not exist.
int rc = repetition_detection_table.get( pos.tt_key_ );
if ( rc == 1 )
{
return DrawRepetition1;
}
if ( rc > 1 )
{
return DrawRepetition2;
}
// What happens if a player makes a move that results in the last 50 moves
// having been played without any captures or pawn moves, but also gives checkmate?
// Is the game a win or a draw? ("1k6/8/1K6/8/8/8/8/7R w - - 99 99")
// Answer from Uri Blass (http://www.talkchess.com/forum/viewtopic.php?topic_view=threads&p=487477&t=45556):
// Mate.
// You first check for mate and only if there is no mate you check for draw by the 50 move rule.
// I can add that the fide rule does not say that 50 move rule is a draw automatically
// and the player needs to claim the draw to get it. Mate ends the game so it is too late
// to claim a draw after a move that cause checkmate and in this case before the move
// there was no basis to claim a draw because there were only 99 plies with no capture or pawn move.
if ( check_mates || pos.moves50_ >= 100 )
{
// Find one legal move. Otherwise it is mate or stalemate.
if ( !find_one_legal_move(pos) )
{
if ( pos.checked_ )
{
return ( pos.stm_ == White ) ? WhiteIsMated : BlackIsMated;
}
else
{
return DrawStalemate;
}
}
}
// Now check 50 moves rule.
if ( pos.moves50_ >= 100 )
{
return Draw50MoveRule;
}
return GameOpen;
}
code clean, modular and easy to understand. Therefore I do some
experiments with this function.
By the way, how does perft() handle draw by repetition?
Harald
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: Draw by 50 move rule or mate
It is a win. The rule book explicitly mentions this example, and says something like 'mate takes precedence over the draw"Harald wrote:While writing some search function I had this problem:
What happens if a player makes a move that results in the last 50 moves
having been played without any captures or pawn moves, but also gives
checkmate? Is the game a win or a draw?
[D]1k6/8/1K6/8/8/8/8/7R w - - 99 99
Is Rh8 a mate or a draw by 50 move rule?
Harald
-
- Posts: 4675
- Joined: Mon Mar 13, 2006 7:43 pm
Re: Draw by 50 move rule or mate
Checkmate (or stalemate) ends it all and has priority over everything else including a flagged clock.bob wrote:It is a win. The rule book explicitly mentions this example, and says something like 'mate takes precedence over the draw"Harald wrote:What happens if a player makes a move that results in the last 50 moves
having been played without any captures or pawn moves, but also gives
checkmate? Is the game a win or a draw?
[D]1k6/8/1K6/8/8/8/8/7R w - - 99 99
Is Rh8 a mate or a draw by 50 move rule?
-
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: Draw by 50 move rule or mate
In perft you ignore all draws except for stalemate (since the latter is the only case of a draw where you can't continue the game without making an illegal move).Harald wrote:By the way, how does perft() handle draw by repetition?
Sven