make_move now handles castling
This commit is contained in:
parent
a7cf8e0c21
commit
f0467bc516
@ -199,6 +199,24 @@ Board Board::make_move(Move move) const {
|
||||
} else {
|
||||
ret.en_passant_target = -1;
|
||||
}
|
||||
|
||||
// -- Handle castling (just move the rook over)
|
||||
if (move.castle_side & KingSide) {
|
||||
Coords c = Coords::from_index(move.source_square);
|
||||
Coords rook_source{7, c.y};
|
||||
int8_t old_rook = ret.squares[rook_source.to_index()];
|
||||
ret.squares[rook_source.to_index()] = Piece::None;
|
||||
Coords rook_dest{5, c.y};
|
||||
ret.squares[rook_dest.to_index()] = old_rook;
|
||||
} else if (move.castle_side & QueenSide) {
|
||||
Coords c = Coords::from_index(move.source_square);
|
||||
Coords rook_source{0, c.y};
|
||||
int8_t old_rook = ret.squares[rook_source.to_index()];
|
||||
ret.squares[rook_source.to_index()] = Piece::None;
|
||||
Coords rook_dest{3, c.y};
|
||||
ret.squares[rook_dest.to_index()] = old_rook;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user