[board, position] Simplify check methods
Only one check-testing method, Board::is_in_check(), that tests if the current active player is in check. It doesn't make sense to test if the non-active player is in check.
This commit is contained in:
parent
a30553503f
commit
e3d17219ad
3 changed files with 9 additions and 17 deletions
|
@ -129,7 +129,7 @@ impl Position {
|
|||
);
|
||||
});
|
||||
|
||||
let move_is_legal = !test_board.color_is_in_check(Some(active_color_before_move));
|
||||
let move_is_legal = !test_board.is_in_check();
|
||||
|
||||
test_board.unmake_move(&record).unwrap_or_else(|err| {
|
||||
panic!(
|
||||
|
|
|
@ -107,7 +107,7 @@ fn en_passant_check_capture() {
|
|||
White Pawn on D4,
|
||||
], D3);
|
||||
|
||||
assert!(pos.board().active_color_is_in_check());
|
||||
assert!(pos.board().is_in_check());
|
||||
|
||||
let generated_moves: HashSet<_> = pos.all_legal_moves(Some(Color::Black)).collect();
|
||||
|
||||
|
@ -123,7 +123,7 @@ fn en_passant_check_block() {
|
|||
White Queen on F1,
|
||||
], D3);
|
||||
|
||||
assert!(pos.board().active_color_is_in_check());
|
||||
assert!(pos.board().is_in_check());
|
||||
|
||||
let generated_moves: HashSet<_> = pos.all_legal_moves(Some(Color::Black)).collect();
|
||||
|
||||
|
@ -139,7 +139,7 @@ fn pinned_pieces_rook_cannot_move_out_of_pin() {
|
|||
White King on C1,
|
||||
]);
|
||||
|
||||
assert!(!pos.board().active_color_is_in_check());
|
||||
assert!(!pos.board().is_in_check());
|
||||
|
||||
let rook_moves: HashSet<_> = pos.all_legal_moves(None).collect();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue