fn king_playable_move(
    state: &State,
    player: Color,
    square: Square,
    squares_under_attack_map: &HashMap<usize, bool>,
) -> bool {
    let other_player = get_other_player(player);
    if !square_is_on_board(square) {
        return false;
    }

    let square_flat = square_tuple_to_flat(square);
    match squares_under_attack_map.get(&square_flat) {
        Some(&_) => return false,
        None => {}
    }

    if square_is_empty(state, square) || is_piece_from_player(state, other_player, square) {
        return true;
    }
    if is_piece_from_player(state, player, square) {
        return false;
    }
    if is_king_from_player(state, other_player, square) {
        panic!("KINGS NEXT TO EACH OTHER ERROR");
    }
    panic!("KING PLAYABLE MOVE ERROR");
}
///
/// return squares to which the king can move,
/// i.e. unattacked squares that can be:
/// - empty squares
/// - opponent pieces (excluding king)
/// If opponent king is encountered, then there's a problem...
/// => return <bool> is_playable
return squares to which the king can move,
i.e. unattacked squares that can be:
empty squares
opponent pieces (excluding king)
If opponent king is encountered, then there's a problem
> return  is_playable
return squares to which the king can move i . e . unattacked squares that can be : empty squares opponent pieces ( excluding king ) If opponent king is encountered then there ' s a problem > return is_playable
fn king_playable_move(
    state: &State,
    player: Color,
    square: Square,
    squares_under_attack_map: &HashMap<usize, bool>,
) -> bool {
    let other_player = get_other_player(player);
    if !square_is_on_board(square) {
        return false;
    }
    let square_flat = square_tuple_to_flat(square);
    match squares_under_attack_map.get(&square_flat) {
        Some(&_) => return false,
        None => {}
    }
    if square_is_empty(state, square) || is_piece_from_player(state, other_player, square) {
        return true;
    }
    if is_piece_from_player(state, player, square) {
        return false;
    }
    if is_king_from_player(state, other_player, square) {
        panic!("KINGS NEXT TO EACH OTHER ERROR");
    }
    panic!("KING PLAYABLE MOVE ERROR");
}
fn king_playable_move ( state : & State , player : Color , square : Square , squares_under_attack_map : & HashMap < usize , bool > , ) -> bool { let other_player = get_other_player ( player ) ; if ! square_is_on_board ( square ) { return false ; } let square_flat = square_tuple_to_flat ( square ) ; match squares_under_attack_map . get ( & square_flat ) { Some ( & _ ) => return false , None => { } } if square_is_empty ( state , square ) || is_piece_from_player ( state , other_player , square ) { return true ; } if is_piece_from_player ( state , player , square ) { return false ; } if is_king_from_player ( state , other_player , square ) { panic ! ( " " ) ; } panic ! ( " " ) ; }
return squares to which the king can move,
i.e.
return squares to which the king can move i . e .
state
&State
player
Color
square
Square
squares_under_attack_map
&HashMap<usize, bool>
state
&State
player
Color
square
Square
squares_under_attack_map
&HashMap<usize, bool>