return 0;
}
int square_index_extractor(U64 btbrd) {
static U64 bitboard;
if (btbrd != no_sq)
bitboard = btbrd;
if (bitboard == C64(0))
return no_sq;
int index = bit_lsb_index(bitboard);
bit_pop(bitboard, index);
return index;
}
void CBoard_move_generate(CBoard_T self) {
Square source, target;
U64 bitboard, attack;
U64 occupancy = self->colorBB[WHITE] | self->colorBB[BLACK];
for (int color = 0; color < 2; color++) {
// Generate quiet pawn moves
{
int add = (color == WHITE) ? +8 : -8;
bitboard = self->pieceBB[PAWN] & self->colorBB[color];
while (bitboard) {
target = source = bit_lsb_index(bitboard);
target += add;
if (target > a1 && target < h8 && !bit_get(occupancy, target)) {
// promote
if ((color == WHITE && source >= a7 && source <= h7) ||
(color == BLACK && source >= a2 && source <= h2)) {
// add move to move list
printf("PROMOTION!!! ");
} else {
// one ahead
// add move to move list
printf("SINGLE PUSH!!! ");
// two ahead
if (((color == BLACK && source >= a7 && source <= h7) ||
(color == WHITE && source >= a2 && source <= h2)) &&
!bit_get(occupancy, target + add)) {
// add to move list;
printf("DOUBLE PUSH!!! ");
}
}
printf("%s pawn: %s; target: %s\n",
(color == WHITE) ? "white" : "black",
square_to_coordinates[source], square_to_coordinates[target]);
}
bit_pop(bitboard, source);
}
/* for (int piece = 0; piece < 6; piece++) { */
/* bitboard = self->pieceBB[piece] & self->colorBB[color]; */
/* } */
}
}
}
void CBoard_print(CBoard_T self) {
for (int rank = 0; rank < 8; rank++) {
for (int file = 0; file < 8; file++) {