Not quite. It is that at least one other piece has to be removed from the board.

Yes, bad wording. "At least" should indicate pawn or higher rank. But then, I never considered removing non-pawns. Removing a pawn removes the least number of bits from the variable length bitstream (only 2 bits).

So, allowing a pawn to remove a rook, knight, or bishop removes 4 bits from the bitstream, allowing it to remove a queen removes 5 bits. That (partially) opens the way for the pawn with the opposite color from the same column to be promoted.

Repeating that for a total of four pawns of each color can get us into a situation where no pawn blocks any pawn of the opposite color. Half of the columns each have two white pawns and no black pawns, and the other half each have two black pawns and no white pawns. To get there, eight pieces had to be removed from the board, each a rook, knight or bishop. I won't remove the queens, because they shorten the bitstream by one more bit, and I want it as long as possible (worst case). Each of the eight pieces frees 4 bits, so we need 32 bits less than for the initial setup. Then, we allow all 16 pawns to be promoted to queens, which need the most bits (5 bits plus color). Pawns used 2 bits plus color, so this adds 48 bits to the bitstream. In total, we are at the initial 164 bis from the fresh board + 16 bits = 180 bits = 23 bytes. Castling adds 4 bits, 184 bits total, still 23 bytes.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re^4: [OT] Is It Possible To Serialize A Chess Board In Fewer Than 23 Bytes? by afoken
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.