-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
featImplementation of a new featureImplementation of a new featuremove-generationChess moves generation (legal, pseudo-legal).Chess moves generation (legal, pseudo-legal).testingAdding, updating or removing any kind of tests.Adding, updating or removing any kind of tests.
Description
🎯 Goal
Validate the entire pipeline.
🧠 Key Idea
Perft never lies.
🛠️ Tasks
- Integrate generate_legal_moves:
void generate_legal_moves(MoveList& moves, const Board& board, Color us) {
Square king_sq = board.king_square(us);
Color them = opposite(us);
// 1. Who is checking the king?
Bitboard checkers = attackers_to(king_sq, board, them);
// 2. Where are we allowed to play to resolve check?
Bitboard check_mask = compute_check_mask(king_sq, checkers, board);
// 3. Which of our pieces are pinned?
Bitboard pinned;
Bitboard pin_ray[64] = {0};
compute_pins(king_sq, board, us, pinned, pin_ray);
// 4. Squares attacked by the enemy (needed for king safety)
Bitboard enemy_attacks = compute_enemy_attacks(board, them);
// 5. King moves (always generated)
generate_legal_king_moves(
moves,
board,
us,
king_sq,
enemy_attacks,
check_mask
);
// 6. Double check → only king moves are legal
if (popcount(checkers) > 1)
return;
// 7. Other pieces
generate_legal_knight_moves(moves, board, us, check_mask, pinned, pin_ray);
generate_legal_bishop_moves(moves, board, us, check_mask, pinned, pin_ray);
generate_legal_rook_moves(moves, board, us, check_mask, pinned, pin_ray);
generate_legal_queen_moves(moves, board, us, check_mask, pinned, pin_ray);
generate_legal_pawn_moves(moves, board, us, check_mask, pinned, pin_ray);
// 8. Castling (depends on check + enemy attacks)
generate_legal_castling_moves(
moves,
board,
us,
checkers,
enemy_attacks
);
}
- Run perft (depth 1 -> 5)
- Compare against known references
✅ Acceptance Criteria
- Exact perft numbers
- No illegal moves generated
Metadata
Metadata
Assignees
Labels
featImplementation of a new featureImplementation of a new featuremove-generationChess moves generation (legal, pseudo-legal).Chess moves generation (legal, pseudo-legal).testingAdding, updating or removing any kind of tests.Adding, updating or removing any kind of tests.