Board reports legal moves after drawn position
See original GitHub issueTo reproduce, use the code snippet below for MyBot and play g1 to g3, then shuffle the rook back and forth. The computer should do the same in the opposite corner, and a repetition draw will (correctly) occur after a few moves back and forth.
public class MyBot : IChessBot
{
public Move Think(Board board, Timer timer)
{
Move[] moves = board.GetLegalMoves();
Move moveToPlay = moves[0];
board.MakeMove(moveToPlay);
if (board.IsDraw())
{
System.Console.WriteLine(
"Number of legal positions from drawn position: {0}",
board.GetLegalMoves().Length
);
}
board.UndoMove(moveToPlay);
return moveToPlay;
}
}
Doing so produces the following output:
Launching Chess-Challenge version 1.13
Number of legal positions from drawn position: 19
Number of legal positions from drawn position: 20
Number of legal positions from drawn position: 19
Game Over: Repetition
There should be no legal moves following a draw, as the game has ended. Further, the bot misreports that its next move will be a draw twice too early, but I think https://github.com/SebLague/Chess-Challenge/issues/170 deals with this already.
Issue Analytics
- State:
- Created 2 months ago
- Reactions:2
- Comments:6
Top Results From Across the Web
Repeat Moves In Drawn Position
The game is not automatically drawn if a position occurs for the third time – one of the players, on their turn to...
Read more >Does 'dead position' consider the 75 moves rule?
The game is drawn when a position has arisen in which neither player can checkmate the opponent's king with any series of legal...
Read more >(Rant) This was the position on move 47. My opponent kept ...
Under FIDE rules: When no legal sequence of moves can lead to checkmate, the game is already drawn. Does not matter whether time...
Read more >Draw (chess)
Under the standard FIDE rules, a draw also occurs in a dead position (when no sequence of legal moves can lead to checkmate),...
Read more >Summary of differences between the FIDE Laws of ...
US. Chess rules allow a player to claim a draw by triple occurrence or the 50-move rule after moving (determining the move) but...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A simple tree search (the way I’ve implemented it for instance) will usually only evaluate the state of the board at the leaf nodes. The easiest way to do this is to get a list of legal moves, and then recursively evaluate on the board state following those moves.
With the current behaviour, you would have to check whether the board is a draw at each internal node if you don’t want to search an invalid state space, rather than just the leaves. Since we’re constrained on token space in this challenge, this absolutely matters. Whether or not it is intended behaviour is up to @SebLague of course, but the current behaviour seems unintuitive, it’s certainly not documented.
The
Board
class includes a check for whether the current state is a draw, because it knows whether or not it is (or at least it should). So it should already know that the moves it’s generating are bogus. It’s not just a move generator, it already tracks this information, just a matter of including that in its knowledge of move legality.That’s a perfectly valid point! Wasn’t aware that it was optional per actual rules. Within this version of the game, it is an instant draw, so I’ll leave the issue open for now as it could still be a convenience feature.