• Create Account

### #Actualalvaro

Posted 28 June 2012 - 07:55 PM

I would use consecutive bits to represent columns. Following the same convention as Fhourstones:

.  .  .  .  .  .  .
5 12 19 26 33 40 47
4 11 18 25 32 39 46
3 10 17 24 31 38 45
2  9 16 23 30 37 44
1  8 15 22 29 36 43
0  7 14 21 28 35 42


You can then generate moves as
u64 generate_moves() {
u64 occupied = pieces[0] | pieces[1];
return BOARD_MASK & (occupied >> 1) & ~occupied;
}

When you need to loop over the moves, you do something like this:
for (u64 moves = generate_moves(); moves; moves &= moves-1) {
u64 move = moves & -moves;
// move' now has a bitboard with a single 1 in the position where you can move.
// You can use the De Bruijn sequence trick if you want to convert it to an index.
}

### #1alvaro

Posted 28 June 2012 - 06:34 PM

I would use consecutive bits to represent columns. Following the same convention as Fhourstones:

.  .  .  .  .  .  .
5 12 19 26 33 40 47
4 11 18 25 32 39 46
3 10 17 24 31 38 45
2  9 16 23 30 37 44
1  8 15 22 29 36 43
0  7 14 21 28 35 42


You can then generate moves as
u64 generate_moves() {
u64 occupied = pieces[0] | pieces[1];
return BOARD_MASK & (occupied >> 1) & ~occupied;
}

When you need to loop over the moves, you do something like this:
for (u64 moves = generate_moves(); moves; moves &= moves-1) {
u64 move = move & -move;
// move' now has a bitboard with a single 1 in the position where you can move.
// You can use the De Bruijn sequence trick if you want to convert it to an index.
}

PARTNERS