Arimaa Forum (http://arimaa.com/arimaa/forum/cgi/YaBB.cgi)
Arimaa >> Bot Development >> Board representation in Bomb
(Message started by: fotland on Feb 11th, 2007, 5:43pm)

Title: Board representation in Bomb
Post by fotland on Feb 11th, 2007, 5:43pm
Bomb uses one bitmap for each piece type with a bit set for each square containing that piece.  It also has an array for the board giving the piece on each square.  This is a single dimension array since a two dimension array would be slower.

It tracks the strongest piece adjacent to each square, and has a bitmap for pieces that are frozen.

It has a 64-bit zobrist hash used to detect repetiion and to index into the transposition table during search.

It keeps track of the current step and push/pull status.

It has some incremental evaluation values, for material balance, and number of rabbits for each side.

The full board data structue is:

     bmap p[NUMBITMAPS];            // locations of pieces, by PIECE NAMES (inluding one for empty squares)
     bmap frozen;                  // bit set if that piece is frozen
     char pieces[64];            // piece on each point, 0 is upper left (black side of board )
     char strongest[2][64];      // strongest piece next to each square, by color (or EMPTY)
     unsigned int hashindex, hashkey1;      // transposition table values
     int material;                  // material balance, 1000 per pawn, positive for gold
     int bestmateval;            // best pawn matestep value
     char bestmateloc;            // best mate location
     char tm;                        // side to move (0-white, 1-black)
     char phase;                        // phase of the the move, 0-3
     char wtotmat, btotmat;      // white and black total material, 1, 2, 3, 5, 9, 11
     unsigned char pullsquare, pullpiece;      // last move's pulling square (empty square where piece was)
                                                                 // and piece doing the pulling - unless pullpiece is empty
     unsigned char pushsquare, pushpiece;      // last move pushed square (empty point where piece was)
                                                                 // and enemy piece that was pushed -
                                                                 // unless pushpiece is empty - next step is forced
     unsigned char pawncount[2];                        // how many pawns left by color
     char matesearch;            // doing a mate search now

Title: Re: Board representation in Bomb
Post by fotland on Feb 11th, 2007, 5:46pm
When doing a search we have to make a move, evaluate (possibly with more search), and unmake the move.  I find it fastest to only write code for making the move.  During search I make a copy of the board before making a move, so unmaking a move is not needed.  This saves a lot of code to do incremental unmakes, and since the board data is small, the copy takes very little time.



Arimaa Forum » Powered by YaBB 1 Gold - SP 1.3.1!
YaBB © 2000-2003. All Rights Reserved.