quick little refactoring
This commit is contained in:
parent
77f77ac04e
commit
b8627ace14
@ -117,7 +117,7 @@ std::string Board::to_fen() const {
|
||||
|
||||
int full_piece = squares[rank * 8 + file];
|
||||
char piece = p2c[full_piece & 0b111];
|
||||
int8_t colour = colour_at({file, rank});
|
||||
Colour colour = colour_at({file, rank});
|
||||
|
||||
if (empty_cell_counter > 0) {
|
||||
ret += std::to_string(empty_cell_counter);
|
||||
@ -181,8 +181,8 @@ Board Board::make_move(Move move) const {
|
||||
ret.squares[move.source_square] = Piece::None;
|
||||
ret.squares[move.target_square] = this->squares[move.source_square];
|
||||
|
||||
int8_t source_piece = piece_at(move.source_square);
|
||||
int8_t target_piece = piece_at(move.target_square);
|
||||
Piece source_piece = piece_at(move.source_square);
|
||||
Piece target_piece = piece_at(move.target_square);
|
||||
|
||||
// -- Handle en passant target being eaten
|
||||
if (en_passant_target != -1 && source_piece == Piece::Pawn
|
||||
|
@ -41,19 +41,19 @@ struct Board {
|
||||
|| is_stalemate_for(White) || is_stalemate_for(Black);
|
||||
}
|
||||
|
||||
int8_t piece_at(int8_t idx) const {
|
||||
return squares[idx] & 0b00111;
|
||||
Piece piece_at(int8_t idx) const {
|
||||
return (Piece) (squares[idx] & 0b00111);
|
||||
}
|
||||
|
||||
int8_t piece_at(Coords xy) const {
|
||||
Piece piece_at(Coords xy) const {
|
||||
return piece_at(xy.to_index());
|
||||
}
|
||||
|
||||
int8_t colour_at(int8_t idx) const {
|
||||
return squares[idx] & 0b11000;
|
||||
Colour colour_at(int8_t idx) const {
|
||||
return (Colour) (squares[idx] & 0b11000);
|
||||
}
|
||||
|
||||
int8_t colour_at(Coords xy) const {
|
||||
Colour colour_at(Coords xy) const {
|
||||
return colour_at(xy.to_index());
|
||||
}
|
||||
};
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
std::vector<Move> pawn_moves(const Board& b, const Coords xy) {
|
||||
std::vector<Move> ret{};
|
||||
int8_t my_colour = b.colour_at(xy);
|
||||
Colour my_colour = b.colour_at(xy);
|
||||
|
||||
// -- Capture to the left
|
||||
if (xy.x > 0) {
|
||||
|
@ -9,7 +9,7 @@ keep_only_blocking(const std::vector<Move> candidates, const Board& board) {
|
||||
if (candidates.size() == 0)
|
||||
return {};
|
||||
|
||||
int8_t my_colour = board.colour_at(candidates[0].source_square);
|
||||
Colour my_colour = board.colour_at(candidates[0].source_square);
|
||||
std::vector<Move> ret;
|
||||
for (Move move : candidates) {
|
||||
Board board_after_move = board.make_move(move);
|
||||
|
Loading…
x
Reference in New Issue
Block a user