gbtami / pychess-variants

Chess variant server
https://www.pychess.org
GNU Affero General Public License v3.0
239 stars 116 forks source link

During premove, king appears to be able to capture to the Rook's location when castling is available #1686

Closed PLMMJ-FH closed 1 week ago

PLMMJ-FH commented 1 week ago

When premoving, the King looks to be able to capture the Rook's location. However, selecting this premove does nothing. King Rook Capture

This also occurs in Shatranj (I was going to put this in #1684 until discovering it happens in chess too): Shatranj King Castling Thing

I have no idea what is going on here but it seems too obvious to be a bug.

gbtami commented 1 week ago

This was already fixed via https://github.com/gbtami/pychess-variants/commit/ba285a4fbb418e3623c02f8d0fc0d965188fc7b2 but it was not deployed yet. Premoves are implemented in https://github.com/gbtami/chessgroundx/blob/master/src/premove.ts but I completely forget about adding Shatranj before. Now it is there.

PLMMJ-FH commented 1 week ago

Ahem it still happens You seem to have only fixed it for Shatranj, it is still a thing in S-Chess at least

PLMMJ-FH commented 1 week ago

Duck Chess is even worse. For some reason, the King still appears to be able to capture the kingside rook despite it obviously not being unmoved.

Ducks Even Worse

gbtami commented 1 week ago

This is by design. Premove targets are NOT just valid move targets only. They are created from piece movement rules only without checking all of the other game rules. The is because opponent next move can change which our next move will be possible or not possible in different variants. For example in atomic pieces can vanish when opp player takes something. Screenshot from lichess https://i.imgur.com/PPB73jT.png