fixed board and pawn moves
This commit is contained in:
@ -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) {
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user