logoalt Hacker News

Smalltalker-80last Friday at 8:10 PM2 repliesview on HN

Why not do it simpler? : Create an array with 16 elements, one element per piece, black + white. Every array element is 7 bits wide, 1 bit for captured or not, and 6 bits for the square number the piece is on (8 x 8). Then you need 16 * 7 = 112 bits = 14 bytes. (And the captured-bit can even be compressed further as a 65th square, but that makes it more calculation intensive to extract a position)


Replies

Scarblaclast Friday at 8:43 PM

Each side has 16 pieces, so you need 32 elements.

show 1 reply
veidelislast Friday at 8:15 PM

+ 3 bits for piece type?

show 1 reply