==== Naive approach

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.

Update

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.


In reply to Re: [OT] Is It Possible To Serialize A Chess Board In Fewer Than 23 Bytes? by LanX
in thread [OT] Is It Possible To Serialize A Chess Board In Fewer Than 23 Bytes? by Limbic~Region

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.