Bitboard Engine
Posted: 09 Apr 2008, 16:30
Hi,
I'm trying something a little new for chess programming in terms of how to make the computer evaluate positions. I previously wrote a move generator based on representing the board as two arrays of squares occupied by black and squares occupied by white, accompanied by a bog-standard 64-length array. I precomputed all valid moves for every piece on every square of an empty board, and loaded them into memeory at initialisation.
All this, just to try to make my code somewhat less verbose and easier for me to maintain!
As I reached the evaluation routines, and wanted to start looking at structures like outposted knights, etc. I found I was writing very complex code, which would produce a bit of a bottleneck during the tree search.
I have since poked around the source of Crafty and the same evaluations that I'm having to write into 30-40 line functions for are represented by simple boolean ifs because of the bitboard representation.
I understand how this works, but didn't implement it because it was so complicated. Since I'm mostly interested in the evaluation end, I wondered if there was some C++ source for a chessboard class (or somesuch) that implemented bitboards. I would convert Crafty happily, except that I don't understand exactly how ordinary C file structures work and can't seem to find the bit I'm after.
If anyone can help either finding an existing C++ solution, or in suggesting how to extract the one in Crafty I would be very appreciative, as I would rather get on with the "interesting" part than be bogged down in generation again!
I'm trying something a little new for chess programming in terms of how to make the computer evaluate positions. I previously wrote a move generator based on representing the board as two arrays of squares occupied by black and squares occupied by white, accompanied by a bog-standard 64-length array. I precomputed all valid moves for every piece on every square of an empty board, and loaded them into memeory at initialisation.
All this, just to try to make my code somewhat less verbose and easier for me to maintain!
As I reached the evaluation routines, and wanted to start looking at structures like outposted knights, etc. I found I was writing very complex code, which would produce a bit of a bottleneck during the tree search.
I have since poked around the source of Crafty and the same evaluations that I'm having to write into 30-40 line functions for are represented by simple boolean ifs because of the bitboard representation.
I understand how this works, but didn't implement it because it was so complicated. Since I'm mostly interested in the evaluation end, I wondered if there was some C++ source for a chessboard class (or somesuch) that implemented bitboards. I would convert Crafty happily, except that I don't understand exactly how ordinary C file structures work and can't seem to find the bit I'm after.
If anyone can help either finding an existing C++ solution, or in suggesting how to extract the one in Crafty I would be very appreciative, as I would rather get on with the "interesting" part than be bogged down in generation again!