logoalt Hacker News

addaonlast Friday at 8:30 PM1 replyview on HN

You only need the piece type for pawns (that can be upgraded), and a bit on the king to track if castling is possible; otherwise a single bit for on-board/captured is sufficient, since the types of the other pieces are implicit in the array index. (You can shave single bits in a few places -- if the state represents a game in progress the king-captured bit isn't needed; natural bishops only need 5 bits for position on board, etc. This doesn't really add up though.)

On the other hand, there are 32 pieces (max) on a chess board, not 16, so grandparent is off by a factor of more than two.


Replies

Scarblaclast Friday at 8:45 PM

Two bits on the king for castling, queenside and kingside.

show 1 reply