- // Remove pieces from source squares
- clear_bit(&(byColorBB[us]), kfrom);
- clear_bit(&(byTypeBB[KING]), kfrom);
- clear_bit(&(byTypeBB[0]), kfrom); // HACK: byTypeBB[0] == occupied squares
- clear_bit(&(byColorBB[us]), rfrom);
- clear_bit(&(byTypeBB[ROOK]), rfrom);
- clear_bit(&(byTypeBB[0]), rfrom); // HACK: byTypeBB[0] == occupied squares
-
- // Put pieces on destination squares
- set_bit(&(byColorBB[us]), kto);
- set_bit(&(byTypeBB[KING]), kto);
- set_bit(&(byTypeBB[0]), kto); // HACK: byTypeBB[0] == occupied squares
- set_bit(&(byColorBB[us]), rto);
- set_bit(&(byTypeBB[ROOK]), rto);
- set_bit(&(byTypeBB[0]), rto); // HACK: byTypeBB[0] == occupied squares
+ // Move the pieces
+ Bitboard kmove_bb = make_move_bb(kfrom, kto);
+ do_move_bb(&(byColorBB[us]), kmove_bb);
+ do_move_bb(&(byTypeBB[KING]), kmove_bb);
+ do_move_bb(&(byTypeBB[0]), kmove_bb); // HACK: byTypeBB[0] == occupied squares
+
+ Bitboard rmove_bb = make_move_bb(rfrom, rto);
+ do_move_bb(&(byColorBB[us]), rmove_bb);
+ do_move_bb(&(byTypeBB[ROOK]), rmove_bb);
+ do_move_bb(&(byTypeBB[0]), rmove_bb); // HACK: byTypeBB[0] == occupied squares