Hi, I am working on a chess application and need to create opening book, a file which
could contains a millions of moves and positions. we have 64 squres, some of which have
occupied by pieces while some are empty. Let we represent our pieces with following bits
(using to Huffman encoding technique).
White Black
-Empty 0 0
-Pawn 110 100
-Rook 11111 11110
-Knight 10110 10101
-Bishop 10100 11100
-Queen 111010 111011
-King 101110 101111
At initial position, we have 32 squres occupied by different pieces and 32 squres are
empty. for efficiency I have to store position in consecutive bits. Pieces bits will be
placed in bit array in sequential order, starting from a1 square, then a2 square,..a8,
then b1, b2...b8 square and so on.
So for a starting position this equates to 32 x 1 + 16 x 3 + 12 x 5 + 4 x 6 = 164 bits.
Also some additional 16 more bits are required for different game situation, like
whether castling is enabled or not, and defined enpassant square if applicable.
so I need about 180 bits (or 23 bytes = 184 bits) to store a single position for
chessboard.
Now the problem is that I have to perform some bitwise operations, and so want to know
the scheme how could I manipulate this in my code and also how to store in file. means
which data strucure should I use. e.g. maximum long (data type) will contains only 4
bytes = 64 bits. and i want to avoid using string. Could any body suggest any idea how
to proceed with this.
I am using C#.Net, Framework 3.5.