cjsaylor / chessbot

Slack bot for playing chess.
https://www.chris-saylor.com/chessbot/
MIT License
35 stars 4 forks source link

@chessbot e1c1 results in "chess: invalid move e1c1" #65

Closed lruminski closed 3 years ago

lruminski commented 3 years ago

I can't seem to castle queenside in a game.

image

the game was in this thread https://drawmeclose.slack.com/archives/C01GJRLD0BW/p1607385649001400

cjsaylor commented 3 years ago

@lruminski Hi Luke.

e1c1 is actually not a valid move according to the rules of castling:

Castling is permissible provided all of the following conditions hold:

  • The castling must be kingside or queenside.
  • Neither the king nor the chosen rook has previously moved.
  • There are no pieces between the king and the chosen rook.
  • The king is not currently in check.
  • The king does not pass through a square that is attacked by an enemy piece.
  • The king does not end up in check. (True of any legal move.)

The emphasized rule is what would make this invalid. The black queen puts the king in check on d1.

See 3.8.2 of the FIDE rule set for reference: https://handbook.fide.com/chapter/E012018