diff options
Diffstat (limited to 'src/board')
-rw-r--r-- | src/board/move_generation.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/board/move_generation.rs b/src/board/move_generation.rs index 5a3650a..7669b85 100644 --- a/src/board/move_generation.rs +++ b/src/board/move_generation.rs @@ -195,5 +195,35 @@ mod tests { println!("{:?}", board.castling_rights); assert!(castle.is_none(), "Castle should not be allowed after king has moved"); } + + #[test] + fn tactical_move_generation() { + let fen = String::from("4k2r/ppp1n3/8/4R1Pp/5P2/q1P5/P1P1BP2/1K1R4 b - - 2 22"); + let board = Board::from_FEN(fen); + + let all_moves = board.generate_pseudolegal_moves(); + + let tactical_only = board.generate_moves_core(true); + let quiet_only = board.generate_moves_core(false); + + let true_tactical = all_moves.iter().filter(|m| m.is_tactical()).copied().collect::<MoveList>(); + let true_quiet = all_moves.iter().filter(|m| !m.is_tactical()).copied().collect::<MoveList>(); + + // Make sure tactical_only and true_tactical are identical sets + for mov in tactical_only.iter() { + assert!(true_tactical.iter().any(|m| *m == *mov)); + } + for mov in true_tactical { + assert!(tactical_only.iter().any(|m| *m == mov)); + } + + // Make sure quiet_only and true_quiet are identical sets + for mov in quiet_only.iter() { + assert!(true_quiet.iter().any(|m| *m == *mov)); + } + for mov in true_quiet { + assert!(quiet_only.iter().any(|m| *m == mov)); + } + } } |