|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include <bitbishop/attacks/generate_attacks.hpp> |
| 4 | +#include <bitbishop/bitboard.hpp> |
| 5 | +#include <bitbishop/board.hpp> |
| 6 | +#include <bitbishop/color.hpp> |
| 7 | +#include <bitbishop/lookups/attackers.hpp> |
| 8 | +#include <bitbishop/move.hpp> |
| 9 | +#include <bitbishop/movegen/bishop_moves.hpp> |
| 10 | +#include <bitbishop/movegen/check_mask.hpp> |
| 11 | +#include <bitbishop/movegen/king_moves.hpp> |
| 12 | +#include <bitbishop/movegen/knight_moves.hpp> |
| 13 | +#include <bitbishop/movegen/pawn_moves.hpp> |
| 14 | +#include <bitbishop/movegen/pins.hpp> |
| 15 | +#include <bitbishop/movegen/queen_moves.hpp> |
| 16 | +#include <bitbishop/movegen/rook_moves.hpp> |
| 17 | +#include <vector> |
| 18 | + |
| 19 | +void generate_legal_moves(std::vector<Move> moves, const Board& board, Color us) { |
| 20 | + Square king_sq = board.king_square(us).value(); |
| 21 | + Color them = ColorUtil::opposite(us); |
| 22 | + |
| 23 | + Bitboard checkers = attackers_to(king_sq, them); |
| 24 | + Bitboard check_mask = compute_check_mask(king_sq, checkers, board); |
| 25 | + PinResult pins = compute_pins(king_sq, board, us); |
| 26 | + Bitboard enemy_attacks = generate_attacks(board, them); |
| 27 | + |
| 28 | + generate_legal_king_moves(moves, board, us, king_sq, enemy_attacks, check_mask); |
| 29 | + |
| 30 | + if (checkers.count() > 1) { |
| 31 | + return; |
| 32 | + } |
| 33 | + |
| 34 | + generate_knight_legal_moves(moves, board, us, check_mask, pins); |
| 35 | + generate_bishop_legal_moves(moves, board, us, check_mask, pins); |
| 36 | + generate_rook_legal_moves(moves, board, us, check_mask, pins); |
| 37 | + generate_queen_legal_moves(moves, board, us, check_mask, pins); |
| 38 | + generate_pawn_legal_moves(moves, board, us, king_sq, check_mask, pins); |
| 39 | + |
| 40 | + // TODO generate legal castling moves |
| 41 | +} |
0 commit comments