fixed board and pawn moves

This commit is contained in:
Karma Riuk
2025-02-02 19:49:21 +01:00
parent fea3f6c98a
commit e08dbb913e
4 changed files with 62 additions and 9 deletions

View File

@ -2,11 +2,23 @@
#include "../board.hpp"
std::vector<Move>
keep_only_blocking(const std::vector<Move> candidates, const Board& board) {
if (candidates.size() == 0)
return {};
int8_t my_colour = board.squares[candidates[0].source_square] & 0b11000;
std::vector<Move> ret;
for (Move move : candidates) {
Board board_after_move = board.make_move(move);
if (!board_after_move.is_check_for(my_colour))
ret.push_back(move);
}
return ret;
}
std::vector<Move> legal_moves(
const Piece p,
const Board& b,
const Coords xy,
bool looking_for_check = false
int8_t p, const Board& b, const Coords xy, bool looking_for_check = false
) {
std::vector<Move> ret;
switch (p) {

View File

@ -23,7 +23,8 @@ enum Colour : int8_t {
class Board;
struct Coords;
std::vector<Move> legal_moves(const Piece, const Board&, const Coords, bool);
std::vector<Move> legal_moves(int8_t, const Board&, const Coords, bool);
std::vector<Move> keep_only_blocking(const std::vector<Move>, const Board&);
std::vector<Move> pawn_moves(const Board&, const Coords);
std::vector<Move> rook_moves(const Board&, const Coords);