Darryl wrote:tomcant wrote:The board is represented with a method called 0x88.
Read this. Basically, the board is represented by a 16*12 array of Piece values, where the game board is the middle 64 squares. It all becomes clear when you read the article

Ok I read the article and understand a 16x8 board, but why a 16x12 board?
The method I am using is not exactly 0x88. If you want to generate all knight moves from a given square, in 0x88 you would do:
[syntax="cpp"]Move *Board::generate_knight_moves_from_square(Move *m, Square from){
static int KnightJump={-33,-31,-18,-14,+14,+18,+31,+33};
for(int i=0;i<8;++i){
Square to=from+KnightJump[i];
if(!(to&0x88) && color(a[to])!=stm)
*m++=Move(from,to);
}
}
[/syntax]
If instead of 16x8 you use 16x12 with the 8x8 board centered, you can fill the squares outside the 8x8 board with the value `out', which has color `both'. Now you don't have to test if the square is inside the board before you access it. Just do:
[syntax="cpp"]Move *Board::generate_knight_moves_from_square(Move *m, Square from){
static int KnightJump={-33,-31,-18,-14,+14,+18,+31,+33};
for(int i=0;i<8;++i){
Square to=from+KnightJump[i];
if(!(color(a[to])&stm))
*m++=Move(from,to);
}
}
[/syntax]
In the evaluation function you can check if a white knight is defended by a white pawn by doing
[syntax="cpp"] if(a[white_knight_square-15]==wp || a[white_knight_square-17]==wp)
...
[/syntax]
and you don't have to worry about accessing a square outside the board, because that is now a legal operation and you will never find a white pawn there. My old chess program used a 8x8 representation, and the evaluation function is full of exceptions for the sides of the board. 16x12 (or even 10x12) makes all that unnecessary. 10x12 is enough for this, but with 16x12 you also get the nice property that the difference between two squares represents the vector between them exactly, so you can still use the attack detection tricks of 0x88.