logoalt Hacker News

efitzlast Friday at 7:27 PM3 repliesview on HN

There's a logic error from assuming that because the rook is in its original position that the rook has not moved. Also I'm not sure if en passant is available if the pawn has moved from its home file, even if it subsequently moved back - so you can't assume either of these just by looking at the piece's position.

I think that you need one extra bit, that can contextually encode "rook has moved" or "en passant available".


Replies

nvaderyesterday at 3:10 AM

At the start of the game, qRook - king - kRook all store the location e1.

If the king moves (say we're playing the Bongcloud), qR and kR get set back to their original squares, a1 and h1. Now if the King slides back, castling is off the board.

bobmcnamaralast Friday at 7:35 PM

You could decide if the en passant location is plausible from the position and color of the pawn on ranks 3 & 6, since it's only available of a pawn has moved two squares, so must be on rank 3 or 6, and it hasn't been promoted(another way it could reach those ranks)

vntoklast Friday at 7:28 PM

If the rook has the king's position, it's never moved. As soon as it moves, it can have any position except the king's.

show 2 replies