pub fn navigate<T: Entity>(&self, target: &T, game_map: &GameMap, max_corrections: u32) -> Option<Command> {
        if max_corrections == 0 {
            return None
        }
        let angular_step = 1.0;
        let speed = MAX_SPEED;
        let distance = self.distance_with(target);
        let angle = self.angle_with(target);
        if game_map.obstacles_between(self, target) {
            let new_target_dx = f64::cos((angle + angular_step).to_radians()) * distance;
            let new_target_dy = f64::sin((angle + angular_step).to_radians()) * distance;
            let Position(self_x, self_y) = self.position;
            let new_target = Position(self_x + new_target_dx, self_y + new_target_dy);
            self.navigate(&new_target, game_map, max_corrections - 1)
        } else {
            Some(self.thrust(min(speed, distance as i32), angle as i32))
        }
    }
/// Move a ship to a specific target position. It is recommended to place the position
/// itself here, else navigate will crash into the target. This function will automatically
/// avoid obstacles on the way, with up to `max_corrections` corrections.
///
/// Note that each correction accounts for 1 degree difference, meaning that
/// the algorithm will naively try `max_correction` degrees before giving
/// up (and returning `None`). The navigation will only consist of up to one command;
/// call this method again in the next turn to continue navigating to the position.
Move a ship to a specific target position. It is recommended to place the position
itself here, else navigate will crash into the target. This function will automatically
avoid obstacles on the way, with up to `max_corrections` corrections.

Note that each correction accounts for 1 degree difference, meaning that
the algorithm will naively try `max_correction` degrees before giving
up (and returning `None`). The navigation will only consist of up to one command;
call this method again in the next turn to continue navigating to the position.
Move a ship to a specific target position . It is recommended to place the position itself here else navigate will crash into the target . This function will automatically avoid obstacles on the way with up to ` max_corrections ` corrections . Note that each correction accounts for 1 degree difference meaning that the algorithm will naively try ` max_correction ` degrees before giving up ( and returning ` None ` ) . The navigation will only consist of up to one command ; call this method again in the next turn to continue navigating to the position .
pub fn navigate<T: Entity>(&self, target: &T, game_map: &GameMap, max_corrections: u32) -> Option<Command> {
        if max_corrections == 0 {
            return None
        }
        let angular_step = 1.0;
        let speed = MAX_SPEED;
        let distance = self.distance_with(target);
        let angle = self.angle_with(target);
        if game_map.obstacles_between(self, target) {
            let new_target_dx = f64::cos((angle + angular_step).to_radians()) * distance;
            let new_target_dy = f64::sin((angle + angular_step).to_radians()) * distance;
            let Position(self_x, self_y) = self.position;
            let new_target = Position(self_x + new_target_dx, self_y + new_target_dy);
            self.navigate(&new_target, game_map, max_corrections - 1)
        } else {
            Some(self.thrust(min(speed, distance as i32), angle as i32))
        }
    }
pub fn navigate < T : Entity > ( & self , target : & T , game_map : & GameMap , max_corrections : u32 ) -> Option < Command > { if max_corrections == 0 { return None } let angular_step = 1.0 ; let speed = MAX_SPEED ; let distance = self . distance_with ( target ) ; let angle = self . angle_with ( target ) ; if game_map . obstacles_between ( self , target ) { let new_target_dx = f64 :: cos ( ( angle + angular_step ) . to_radians ( ) ) * distance ; let new_target_dy = f64 :: sin ( ( angle + angular_step ) . to_radians ( ) ) * distance ; let Position ( self_x , self_y ) = self . position ; let new_target = Position ( self_x + new_target_dx , self_y + new_target_dy ) ; self . navigate ( & new_target , game_map , max_corrections - 1 ) } else { Some ( self . thrust ( min ( speed , distance as i32 ) , angle as i32 ) ) } }
Move a ship to a specific target position.
Move a ship to a specific target position .
&self
target
&T
game_map
&GameMap
max_corrections
u32
&self
target
&T
game_map
&GameMap
max_corrections
u32