fn best_move(&self, map: &Map) -> Option<Action> {
        // TODO: Silence as an alternative to Move
        let viable_moves = self.viable_moves(&map);
        let moves_to_surface: Vec<Option<usize>> = viable_moves
            .iter()
            .map(|mv| {
                let (dest, _) = &mv.movement_result(&self.pos);
                self.moves_to_surface(map, dest, &mut CoordSet::new(), 3)
            })
            .collect();

        if let Some((far_surface_move, _)) = viable_moves
            .iter()
            .zip(moves_to_surface.iter())
            .find(|(_, mts)| matches!(mts, None))
        {
            let owned_move = (*far_surface_move).clone();
            return Some(owned_move);
        }

        let moves_to_surface_unwrapped = moves_to_surface.iter().map(|opt| opt.unwrap());
        viable_moves
            .into_iter()
            .zip(moves_to_surface_unwrapped)
            .max_by(|a, b| a.1.cmp(&b.1))
            .map(|(m, _mts)| m)
    }
// None if no viable moves, otherwise any with None/max moves_to_surface
None if no viable moves, otherwise any with None/max moves_to_surface
None if no viable moves otherwise any with None / max moves_to_surface
fn best_move(&self, map: &Map) -> Option<Action> {
        // TODO: Silence as an alternative to Move
        let viable_moves = self.viable_moves(&map);
        let moves_to_surface: Vec<Option<usize>> = viable_moves
            .iter()
            .map(|mv| {
                let (dest, _) = &mv.movement_result(&self.pos);
                self.moves_to_surface(map, dest, &mut CoordSet::new(), 3)
            })
            .collect();
        if let Some((far_surface_move, _)) = viable_moves
            .iter()
            .zip(moves_to_surface.iter())
            .find(|(_, mts)| matches!(mts, None))
        {
            let owned_move = (*far_surface_move).clone();
            return Some(owned_move);
        }
        let moves_to_surface_unwrapped = moves_to_surface.iter().map(|opt| opt.unwrap());
        viable_moves
            .into_iter()
            .zip(moves_to_surface_unwrapped)
            .max_by(|a, b| a.1.cmp(&b.1))
            .map(|(m, _mts)| m)
    }
fn best_move ( & self , map : & Map ) -> Option < Action > { // TODO: Silence as an alternative to Move let viable_moves = self . viable_moves ( & map ) ; let moves_to_surface : Vec < Option < usize > > = viable_moves . iter ( ) . map ( | mv | { let ( dest , _ ) = & mv . movement_result ( & self . pos ) ; self . moves_to_surface ( map , dest , & mut CoordSet :: new ( ) , 3 ) } ) . collect ( ) ; if let Some ( ( far_surface_move , _ ) ) = viable_moves . iter ( ) . zip ( moves_to_surface . iter ( ) ) . find ( | ( _ , mts ) | matches ! ( mts None ) ) { let owned_move = ( * far_surface_move ) . clone ( ) ; return Some ( owned_move ) ; } let moves_to_surface_unwrapped = moves_to_surface . iter ( ) . map ( | opt | opt . unwrap ( ) ) ; viable_moves . into_iter ( ) . zip ( moves_to_surface_unwrapped ) . max_by ( | a , b | a . 1 . cmp ( & b . 1 ) ) . map ( | ( m , _mts ) | m ) }
None if no viable moves, otherwise any with None/max moves_to_surface
None if no viable moves otherwise any with None / max moves_to_surface
&self
map
&Map
&self
map
&Map