Author: Russell Reagan
Date: 08:34:54 12/21/05
Go up one level in this thread
On December 21, 2005 at 09:04:17, David Rasmussen wrote:
>I am most familiar with bitboards, but now I have to make a chess program with
>an old C compiler (gcc 2.6.0) that doesn't support "long long". I could typedef
>a struct with two 32-bit ints to be a bitboard and then implement the logical
>operators in functions, but I want to consider other options.
>
>What would be a good representation for a "competitive" chess program (not a toy
>project), on a platform with little memory and slow performance (C is compiled
>into a interpreted language in this case).
>
>/David
Probably a 12x16 array of pointers to piece structs, combining the advantages of
12x12 and 8x16 (i.e. 0x88). The advantage of 12x12 is that you don't have to do
anything special for out of bounds detection, and the advantage of 8x16 is that
square relationships are unique so you can do lots of table lookup magic. You
can even avoid dereferencing the pointer most of the time by just testing the
pointer itself (whether it's null, or points to a special "empty" piece struct,
or whatever).
http://chessprogramming.org/cccsearch/ccc.php?art_id=114377
// Example
typedef struct {
unsigned char color;
unsigned char type;
unsigned char square;
unsigned char captured;
// whatever else...
} PIECE;
enum {
a1 = 36, b1, c1, d1, e1, f1, g1, h1,
a8 = 148, b8, c8, d8, e8, f8, g8, h8,
};
PIECE * board[12*16];
PIECE * piece_list[2][6];
int piece_count[2][6];
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.