fotland
Forum Guru
Arimaa player #211
Gender:
Posts: 216
|
|
Move generation in Bomb
« on: Feb 11th, 2007, 5:55pm » |
Quote Modify
|
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.
|