ChessCom / Chess-Game

Based on Pear Games_Chess - represents a chess game as a php object
Other
42 stars 20 forks source link

CV-142681 Chess-Game Do not allow pieces in rook position to castle #38

Closed andreij closed 4 years ago

andreij commented 4 years ago

In case of odds game or games with custom FEN such as q3k2q/pbpqppbp/1pnp1np1/8/8/1PNP1NP1/PBPQPPBP/Q3K2Q w KQkq - 2 9 check that there are actually rooks in the board to decide if a king can castle or not.

andreij commented 4 years ago

@jmogilner Thanks for your suggestion to improve tests, it turned out w1r isn't the king side rook as I wrongly supposed but the first rook found in the chessboard. So I've refactored code accordingly.

marcosdsanchez commented 4 years ago

Have you verified that the code works correctly for Fischer random chess castling? https://en.wikipedia.org/wiki/Fischer_random_chess#Castling_rules

marcosdsanchez commented 4 years ago

I don't think that this will work for chess960. Can you please create a test based on the example I shared in the link below?

andreij commented 4 years ago

@marcosdsanchez Thanks for heads up, reverted in #39