Storing Chessboard positions

Advanced game related topics
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Welcome to the PureBasic forums, but I have to wonder -

Does this question have anything to do with chess or PureBasic?

If not, perhaps pose it in the offtopic section?

cheers
Camus
New User
New User
Posts: 1
Joined: Mon Jun 29, 2009 11:26 am

Post by Camus »

I know that most of this has been touched on before but wouldn't you be able to store all the necessary information about any board in exactly 24bytes and 7bits?

The 7bits are needed for:
1bit - Which players turn is it B or W?
4bit - En passant available (there can be only one en passant/turn and it has to be for the player whose turn it is. Seeing as there are 9 possiblities (8 squares and no en passant available we'll need 4bits for this)
1bit - Is white still able to castle?
1bit - Is black still able to castle?

After that you store 64bits, one for each square. Each bit decides whether or not there is a piece on that square.
1*64 = Is there a piece on square A1:H8?

After that you store 32*4 bits of information for each possible piece:
1bit = colour
3bit = type of piece (there are six pieces for each colour)

All in all this would amount to a total of 7 + 64 + 128bits which equals 199bits which is also 24bytes (192) and 7bits.
User avatar
Octopus
User
User
Posts: 55
Joined: Sat Jun 13, 2009 6:42 am
Location: Munich (Germany)
Contact:

Post by Octopus »

Have a look at those old thoughts ...
http://www.chessbox.de/Compu/schachzahl1_e.html
Post Reply