Chess rules question

Sort:
Avatar of j0nnyb0y504

Hi,

I'm not sure if this is a good place to ask this question.  I am working on programming a chess game, and I am confused about the threefold repitition rule for draws.  I want to make sure I get this correct, because players will be understandably upset if they lose a game they should have drawn because the programmer doesn't understand the rules.

So here goes:

"In chess, in oder for a position to be considered the same, each player must have the same set of legal moves each time, including possible rights to castle and capture en passant."

What is the exact definition of "rights to castle"?

Specifically what takes precidence the list of legal moves, or rights to castle?  If for instance white is currently unable to castle because the skipped space is under attack, but castling is otherwise legal: 

1. White moves the corresponding rook and castling is no longer possible even if the space wasn't under attack

2. Black then moves some random piece

3. White replaces the rook to its starting position

3. Black restores the random piece to its previous position.  And the exact same list of legal moves are available.

Which is correct?

A.  This is a repitition because the board is in the exact same position with the same player to move and the same available moves.

B.  This is not a repitition because white's "rights to castle" have changed by moving a rook even though castling is not a legal move in the current board configuration because the skipped space is under attack.

Any help with this confusing and admittedly subtle distinction is appreciated.

Avatar of Martin_Stahl
j0nnyb0y504 wrote:

"In chess, in oder for a position to be considered the same, each player must have the same set of legal moves each time, including possible rights to castle and capture en passant."

What is the exact definition of "rights to castle"?

Specifically what takes precidence the list of legal moves, or rights to castle?  If for instance white is currently unable to castle because the skipped space is under attack, but castling is otherwise legal: 

1. White moves the corresponding rook and castling is no longer possible even if the space wasn't under attack

2. Black then moves some random piece

3. White replaces the rook to its starting position

3. Black restores the random piece to its previous position.  And the exact same list of legal moves are available.

Which is correct?

A.  This is a repitition because the board is in the exact same position with the same player to move and the same available moves.

B.  This is not a repitition because white's "rights to castle" have changed by moving a rook even though castling is not a legal move in the current board configuration because the skipped space is under attack.

Any help with this confusing and admittedly subtle distinction is appreciated.

Basically, you could theoretically end up in a position where the King is on the starting square and one or both Rooks are on their starting squares but in the 1st or 2nd time the position occurred, they hadn't moved and castling was allowed. Say then one of the Rooks moved and later gets moved back to its initial square. Now castling is not allowed, at least on one side, due to the Rook move and the position, while it looks the same, is not for the purposes of three-fold repetition.

In your example, B is correct. Since the Rook has moved, then the right to castle is no longer available, regardless of the fact he is still unable to castle through check.

Also, you should note: Three-fold repetition is not an automatic draw and has to be claimed by the player on the move.

Avatar of wowiezowie

B

Avatar of j0nnyb0y504

Thanks, if I understand correctly "right to castle" is independant of the set of legals moves, and determined solely by if the rooks or king have been moved yet. 

I'm aware that three-fold is not automatic.  I'll handle that by adding an offer/declare draw button that can be hit on your turn in addition to your move.  It will first check for three-fold repitition on your current move and opponent's last move and end the game in a draw in case of a repitition.  If there is no repitition your opponent can reject the draw offer (and ignore future offers to prevent annoyingly spamming draw offers every turn if you are losing).

Avatar of Martin_Stahl
j0nnyb0y504 wrote:

Thanks, if I understand correctly "right to castle" is independant of the set of legals moves, and determined solely by if the rooks or king have been moved yet. 

That is correct.