pub fn suggested_checks(&self) -> Vec<[u8; 2]> {
        let mut select = vec![];
        let directions = Direction::all();
        let hit_spaces = self
            .spaces
            .iter()
            .filter(|s| s.is_hit() && self.ship(s.pos()).unwrap().is_active())
            .collect::<Vec<&Space>>();

        // Check for a line of hit spaces.
        for space in &hit_spaces {
            for direction in &directions {
                let unchecked = self.find_unchecked_space(space.pos(), *direction, true);

                if let Some(pos) = unchecked {
                    if !select.contains(&pos) {
                        select.push(pos);
                    }
                }
            }
        }

        // If a hit space was found, but no hit spaces next to it, look for unchecked spaces next
        // to it.
        if hit_spaces.len() > 0 && select.is_empty() {
            for direction in &directions {
                let unchecked = self.find_unchecked_space(hit_spaces[0].pos(), *direction, false);

                if let Some(pos) = unchecked {
                    select.push(pos);
                }
            }
        }

        // If no candidates have been found yet, just add any unchecked space.
        // TODO: smarter checking for spaces that remaining ships could realistically occupy.
        if select.is_empty() {
            select = self
                .spaces
                .iter()
                .filter(|space| space.is_unchecked())
                .map(|space| *space.pos())
                .collect::<Vec<[u8; 2]>>();
        }

        select
    }
/// Returns suggestions for the best spaces to check based on the player's hit spaces and ships.
///
/// This is intended for use in cases where the active player is computer-controlled, to
/// determine the space they check.  However, it could also be used to suggest a space that a
/// human player could check.
Returns suggestions for the best spaces to check based on the player's hit spaces and ships.
This is intended for use in cases where the active player is computer-controlled, to
determine the space they check.  However, it could also be used to suggest a space that a
human player could check.
Returns suggestions for the best spaces to check based on the player ' s hit spaces and ships . This is intended for use in cases where the active player is computer - controlled to determine the space they check . However it could also be used to suggest a space that a human player could check .
pub fn suggested_checks(&self) -> Vec<[u8; 2]> {
        let mut select = vec![];
        let directions = Direction::all();
        let hit_spaces = self
            .spaces
            .iter()
            .filter(|s| s.is_hit() && self.ship(s.pos()).unwrap().is_active())
            .collect::<Vec<&Space>>();
        // Check for a line of hit spaces.
        for space in &hit_spaces {
            for direction in &directions {
                let unchecked = self.find_unchecked_space(space.pos(), *direction, true);
                if let Some(pos) = unchecked {
                    if !select.contains(&pos) {
                        select.push(pos);
                    }
                }
            }
        }
        // If a hit space was found, but no hit spaces next to it, look for unchecked spaces next
        // to it.
        if hit_spaces.len() > 0 && select.is_empty() {
            for direction in &directions {
                let unchecked = self.find_unchecked_space(hit_spaces[0].pos(), *direction, false);
                if let Some(pos) = unchecked {
                    select.push(pos);
                }
            }
        }
        // If no candidates have been found yet, just add any unchecked space.
        // TODO: smarter checking for spaces that remaining ships could realistically occupy.
        if select.is_empty() {
            select = self
                .spaces
                .iter()
                .filter(|space| space.is_unchecked())
                .map(|space| *space.pos())
                .collect::<Vec<[u8; 2]>>();
        }
        select
    }
pub fn suggested_checks ( & self ) -> Vec < [ u8 ; 2 ] > { let mut select = vec ! [ ] ; let directions = Direction :: all ( ) ; let hit_spaces = self . spaces . iter ( ) . filter ( | s | s . is_hit ( ) && self . ship ( s . pos ( ) ) . unwrap ( ) . is_active ( ) ) . collect :: < Vec < & Space > > ( ) ; // Check for a line of hit spaces. for space in & hit_spaces { for direction in & directions { let unchecked = self . find_unchecked_space ( space . pos ( ) , * direction , true ) ; if let Some ( pos ) = unchecked { if ! select . contains ( & pos ) { select . push ( pos ) ; } } } } // If a hit space was found, but no hit spaces next to it, look for unchecked spaces next // to it. if hit_spaces . len ( ) > 0 && select . is_empty ( ) { for direction in & directions { let unchecked = self . find_unchecked_space ( hit_spaces [ 0 ] . pos ( ) , * direction , false ) ; if let Some ( pos ) = unchecked { select . push ( pos ) ; } } } // If no candidates have been found yet, just add any unchecked space. // TODO: smarter checking for spaces that remaining ships could realistically occupy. if select . is_empty ( ) { select = self . spaces . iter ( ) . filter ( | space | space . is_unchecked ( ) ) . map ( | space | * space . pos ( ) ) . collect :: < Vec < [ u8 ; 2 ] > > ( ) ; } select }
Returns suggestions for the best spaces to check based on the player's hit spaces and ships.
Returns suggestions for the best spaces to check based on the player ' s hit spaces and ships .
&self
&self