in reply to Re: [OT] Is It Possible To Serialize A Chess Board In Fewer Than 23 Bytes?
in thread [OT] Is It Possible To Serialize A Chess Board In Fewer Than 23 Bytes?
See Chess StackExchange for a similar question.
Thanks. Apparently prior art is 24 bytes and doesn't include as much information as my 23 bytes BUT my 23 bytes is inadequate as explained by ikegami elsewhere in this thread.
I can't clearly see why you need 8 bytes to represent the positions of white or black pieces
You have 64 squares and a maximum of 32 pieces. I am trying to compress that in the smallest possible space possible. I use 8 bytes to tell you which of the 64 squares are occupied by white pieces. This is done using a bitstring where the value is either 0 or 1 (piece there or not). I do the same for the black pieces. Once I have told you which spaces are occupied by white pieces, I no longer need to distinguish between white and black - I can simply tell you what piece is at each position. There are 6 different possibilities (pawn/rook/knight/bishop/queen/king). I can do that using 3 bits since 2^3 = 8. Hopefully that now makes sense.
Cheers - L~R
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: [OT] Is It Possible To Serialize A Chess Board In Fewer Than 23 Bytes?
by ikegami (Patriarch) on Mar 11, 2026 at 00:22 UTC |