[position, board, core, moves] Implement a bunch of make_move code

Implement making double push and promotion moves. Then write several tests to
exercise these. Add convenient static functions to the Move struct to build moves
quickly, without using the Builder.

Add a is_promotable_rank() method to Rank to check that a rank can be used for
promotion moves.

The tests found and fixed a bug in pawn movement where the en passant square was
being discarded when deciding whether an e.p. move can be made.
This commit is contained in:
Eryn Wells 2025-05-20 19:29:02 -07:00
parent 6591619e32
commit 039fd2b080
4 changed files with 257 additions and 22 deletions

View file

@ -210,6 +210,12 @@ impl Rank {
pub fn is_pawn_double_push_target_rank(&self, color: Color) -> bool {
self == &Self::PAWN_DOUBLE_PUSH_TARGET_RANKS[color as usize]
}
/// Ranks where promotions happen.
#[must_use]
pub fn is_promotable_rank(&self) -> bool {
matches!(*self, Rank::ONE | Rank::EIGHT)
}
}
#[rustfmt::skip]