Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Minimum bits for chess board representation?

Author: Paul Byrne

Date: 20:18:06 09/29/00

Go up one level in this thread


On September 29, 2000 at 20:03:02, Larry Griffiths wrote:

>I store mine in 32 bytes (256 bits). Each 4 bits contains the piece and its
>color as follows...
>
>cppp
>
>where c is the color and ppp is the piece (could have up to 8 piece types).
>
>OR
>
>If you really like to pack bits you could have a fixed array of 6 bits times 32
>bits (192 bits) where each of the 32 buckets has the square the piece is setting
>on.
>The problem with this second arrangement is that you would need another 8
>buckets for each side (32*6bits+16*6bits=288 bits) if promotions occurred.

For my book & learning tables I use 24 bytes (192 bits).  64 bits -- one for
each square -- to indicate occupied/empty.  Then 4 bits X 32 pieces to describe
each piece in order.  It's far from optimal, but quick & easy to put together.

>Neither of these arrangements include bytes to hold the en-passant status of the
>board or castleing state.

Since you only use 12 of 16 possible values for each piece, you can use the
others to include castling & e-p.  pawn-that-can-be-captured-ep and
rook-that-can-castle.

-paul



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.