in reply to [OT] Is It Possible To Serialize A Chess Board In Fewer Than 23 Bytes?
64pos=2**6bits x 32 pieces = 24 bytes
Plus extra bits for special info, I'll ignore (I think you forgot promotion of pawns at the last rank °)
==== Anyway...
the naive approach is not optimal, since 2 pieces can't be on the same field.
So probably run length encoding of empty fields or Huffman coding are better on average.
You can tell what the optimal limit is by enumerating all possible scenarios.
The the ceiling of log2 count tells you the lower bound of needed bits.
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
°) in theory you can have 9 queens or 10 bishops.
The chess exchange discussion choroba linked to is quite good.
I have a hunch that a 23 bytes maximum is possible (on average even less), but it would require advanced encoding techniques.
For instance are bishops restricted to 32 positions each.
And castleing is only possible if a rook is in the corner.
Pawns can't reach all fields.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: [OT] Is It Possible To Serialize A Chess Board In Fewer Than 23 Bytes?
by ikegami (Patriarch) on Mar 11, 2026 at 00:19 UTC | |
by LanX (Saint) on Mar 11, 2026 at 00:53 UTC | |
by ikegami (Patriarch) on Mar 11, 2026 at 13:57 UTC |