[position, moves] Implement some castling tests

Add white castling for both wings. Found some bugs in how king sight is computed
while writing these.

In order for the king to perform the castle, the Movement bitboard needs to return
the two squares the king can castle to. That means anytime movement is calculated
for the king, the (relatively expensive) castling evaluation needs to happen.

Write two new helper static functions to create a Move for castling and promotion
moves. Since structs cannot have any functions with the same name, the two methods
that return properties related to those moves (Move::castle and Move::promotion)
need to be renamed. They're now called Move::castle_wing and Move::promotion_shape.
This commit is contained in:
Eryn Wells 2025-05-21 08:25:49 -07:00
parent 7c9c5484ba
commit feaa81bbd8
5 changed files with 99 additions and 27 deletions

View file

@ -78,7 +78,7 @@ fn move_flags_promotion() -> TestResult {
.build()?;
assert!(ply.is_promotion());
assert_eq!(ply.promotion(), Some(Shape::Queen));
assert_eq!(ply.promotion_shape(), Some(Shape::Queen));
Ok(())
}
@ -93,7 +93,7 @@ fn move_flags_capture_promotion() -> TestResult {
assert!(ply.is_capture());
assert!(ply.is_promotion());
assert_eq!(ply.promotion(), Some(Shape::Queen));
assert_eq!(ply.promotion_shape(), Some(Shape::Queen));
Ok(())
}