A pair of bugs I uncovered while investigating the Crazyhouse perft today.
En Passant for Crazyhouse
The previous _copyWith() would carry the epSquare forward to the next move, which made this sequence possible:
Black: Qg5
White: Nxg5
Black: f5 (creates epSquare at f6)
White: Q@f7 (copyWith() is given null for epSquare, which then copies f6 forward to Black)
Black: gxf6 (captures the Queen on f7)
Castling
The previous _getCastlingSide() created all sorts of "legal" castling moves. e.g. depending on the setup, I saw things like Ka2, Kd4, and Kf3 (moving onto his own pawn or knight) resulting in a kingside castle, and Ke1 (moving onto its own square) resulting in a queenside castle. In one position I had 13 legal moves that resulted in a castle. They all involved moving onto another friendly piece or e1.
The corrected version only allows 2 castling options for kingside and 2 options for queenside: moving the king two squares to the left or right OR moving the king onto the rook
A pair of bugs I uncovered while investigating the Crazyhouse perft today.
En Passant for Crazyhouse
The previous _copyWith() would carry the epSquare forward to the next move, which made this sequence possible:
Black: Qg5 White: Nxg5 Black: f5 (creates epSquare at f6) White: Q@f7 (copyWith() is given null for epSquare, which then copies f6 forward to Black) Black: gxf6 (captures the Queen on f7)
Castling
The previous _getCastlingSide() created all sorts of "legal" castling moves. e.g. depending on the setup, I saw things like Ka2, Kd4, and Kf3 (moving onto his own pawn or knight) resulting in a kingside castle, and Ke1 (moving onto its own square) resulting in a queenside castle. In one position I had 13 legal moves that resulted in a castle. They all involved moving onto another friendly piece or e1.
The corrected version only allows 2 castling options for kingside and 2 options for queenside: moving the king two squares to the left or right OR moving the king onto the rook