Computer Chess Club Archives


Search

Terms

Messages

Subject: Ignore the bottom of my first message, that was my true first cut at it

Author: KarinsDad

Date: 14:20:57 05/14/99

Go up one level in this thread


On May 14, 1999 at 17:10:38, KarinsDad wrote:

>On May 14, 1999 at 15:21:57, Dann Corbit wrote:
>
>>0:
>>Title says it all.  What binary format does your program use when you want to
>>store a board position in the smallest space possible?
>
>Without thinking about it alot, here is my first cut (my program does not do
>this yet):
>
>10 bits for side to move, en passant possible, en passant to square (4 bits
>since there are only 16 legal squares for this), white kingside castle possible,
>white queenside castle possible), black kingside castle possible, black
>queenside castle possible (note: for a program, it may be better to know if a
>rook moved and if the king moved, but you save 2 bits without that info here)
>
>12 bits for the king location (6 bits for each color) since the kings must exist
>
>the rest of the structure is based on what piece is in a square (a1 to h1, then
>a2 to h2, etc.):
>
>0 blank
>10x pawn
>1100x knight
>1101x bishop
>1110x rook
>1111x queen
>
>Since for most positions, there are more blanks and pawns, they get the smallest
>sizes.
>
>where x is the color bit.
>
>So, for a normal set of pieces, this would take up 150 bits. You would lose 2
>bits everytime a pawn is promoted to a piece.
>
>The grand total is 172 bits or 21.5 bytes (for normal positions). This also
>means that you could have 2 promoted pieces on the board and still store it in
>22 bytes. However, when pawns and pieces are taken, this structure decreases in
>size.
>
>And, of course, you could put a compression routine on top of this.
>
>KarinsDad :)
>



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.