[][src]Function blitz_path::jps_path

pub fn jps_path<U, T: Map2D<U>>(
    map: &T,
    start: Coords2D,
    goal: Coords2D
) -> Option<Route>

Creates a new route using the JPS algorithm. Returns a Route struct containing the distance to the goal and number of steps needed to get there.

Examples

use std::path::Path;

let map = movingai::parser::parse_map_file(Path::new("./tests/map/maze512-32-9.map"))?;
let scenes = movingai::parser::parse_scen_file(Path::new("./tests/map/maze512-32-9.map.scen"))?;
let scene = &scenes[0];

let path = blitz_path::jps_path(&map, scene.start_pos, scene.goal_pos);

// using as f32 as scene.optimal_length is stored as f64,
// but only seems to have precision to f32
if let Some(path) = path {
    assert_eq!(scene.optimal_length as f32, path.distance() as f32);  
}