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

Title: Move generation in Bomb
Post by fotland on Feb 11th, 2007, 5:55pm
With bitmaps for the board, move generation is very simple.  I generate push and pull moves first, since they are more likely to cause a cutoff in the search, and are very common in the principal variations.

My bomb code was derived from an earlier chess program, so it uses chess terminology.

The code to generate the rest of the moves is just:
     bmap t;
     bmap all = p[WPIECES];
     all.bmor(p[BPIECES]);

     bmap unfrozen = p[WPIECES+tm];
     unfrozen.andnot(frozen);
     if(tm == WHITE){
           // much faster to generate forward moves first
           t = unfrozen;
           t.shu();
           t.andnot(all);
           while((to = t.nextbit()) != NOBITS){
                 (nextmove++)->setmove(to+8, to);
           }
           t = unfrozen;
           t.shl();
           t.andnot(all);
           while((to = t.nextbit()) != NOBITS){
                 (nextmove++)->setmove(to+1, to);
           }
           t = unfrozen;
           t.shr();
           t.andnot(all);
           while((to = t.nextbit()) != NOBITS){
                 (nextmove++)->setmove(to-1, to);
           }
           t = unfrozen;
           t.andnot(p[WPAWN]);      // pawns can't move backwards */
           t.shd();
           t.andnot(all);
           while((to = t.nextbit()) != NOBITS){
                 (nextmove++)->setmove(to-8, to);
           }

and the same code for black.



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