-# Returns 'none', 'white', 'black' or 'both', depending on which sides are in check.
-# The latter naturally indicates an invalid position.
-sub in_check {
- my $board = shift;
- my ($black_check, $white_check) = (0, 0);
+my %pieces_against_side = (
+ k => { K => 1, Q => 1, R => 1, N => 1, B => 1, P => 1 },
+ K => { k => 1, q => 1, r => 1, n => 1, b => 1, p => 1 },
+);