remove castle side from move
This commit is contained in:
parent
222adbb8f0
commit
a658673d2b
@ -203,18 +203,20 @@ Board Board::make_move(Move move) const {
|
|||||||
|
|
||||||
// -- Handle castling (just move the rook over)
|
// -- Handle castling (just move the rook over)
|
||||||
Coords c = Coords::from_index(move.source_square);
|
Coords c = Coords::from_index(move.source_square);
|
||||||
if (move.castle_side & KingSide) {
|
if ((squares[move.source_square] & 0b111) == Piece::King) {
|
||||||
Coords rook_source{7, c.y};
|
if (move.target_square - move.source_square == 2) { // king side castle
|
||||||
int8_t old_rook = ret.squares[rook_source.to_index()];
|
Coords rook_source{7, c.y};
|
||||||
ret.squares[rook_source.to_index()] = Piece::None;
|
int8_t old_rook = ret.squares[rook_source.to_index()];
|
||||||
Coords rook_dest{5, c.y};
|
ret.squares[rook_source.to_index()] = Piece::None;
|
||||||
ret.squares[rook_dest.to_index()] = old_rook;
|
Coords rook_dest{5, c.y};
|
||||||
} else if (move.castle_side & QueenSide) {
|
ret.squares[rook_dest.to_index()] = old_rook;
|
||||||
Coords rook_source{0, c.y};
|
} else if (move.target_square - move.source_square == -2) { // queen
|
||||||
int8_t old_rook = ret.squares[rook_source.to_index()];
|
Coords rook_source{0, c.y};
|
||||||
ret.squares[rook_source.to_index()] = Piece::None;
|
int8_t old_rook = ret.squares[rook_source.to_index()];
|
||||||
Coords rook_dest{3, c.y};
|
ret.squares[rook_source.to_index()] = Piece::None;
|
||||||
ret.squares[rook_dest.to_index()] = old_rook;
|
Coords rook_dest{3, c.y};
|
||||||
|
ret.squares[rook_dest.to_index()] = old_rook;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- Check for castling rights
|
// -- Check for castling rights
|
||||||
|
@ -12,7 +12,7 @@ struct Move {
|
|||||||
int8_t target_square;
|
int8_t target_square;
|
||||||
|
|
||||||
// bool is_capturing = false;
|
// bool is_capturing = false;
|
||||||
CastleSide castle_side = CastleSide::NeitherSide;
|
// CastleSide castle_side = CastleSide::NeitherSide;
|
||||||
bool en_passant = false;
|
bool en_passant = false;
|
||||||
int8_t promoting_to = Piece::None;
|
int8_t promoting_to = Piece::None;
|
||||||
|
|
||||||
|
@ -60,7 +60,6 @@ std::vector<Move> king_moves(const Board& b, const Coords xy) {
|
|||||||
ret.push_back(Move{
|
ret.push_back(Move{
|
||||||
xy.to_index(),
|
xy.to_index(),
|
||||||
Coords{6, xy.y}.to_index(),
|
Coords{6, xy.y}.to_index(),
|
||||||
.castle_side = CastleSide::KingSide
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +67,6 @@ std::vector<Move> king_moves(const Board& b, const Coords xy) {
|
|||||||
ret.push_back(Move{
|
ret.push_back(Move{
|
||||||
xy.to_index(),
|
xy.to_index(),
|
||||||
Coords{2, xy.y}.to_index(),
|
Coords{2, xy.y}.to_index(),
|
||||||
.castle_side = CastleSide::QueenSide
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user