goal_exact_node

Function goal_exact_node 

Source
pub fn goal_exact_node<T: PartialEq + 'static>(goal: T) -> impl Fn(T) -> bool
Expand description

Helper function to create a goal function closure for exact node matching with a single goal node.

If using the convenience functions for common pathfinding use-cases, you will not normally need to use this function.

ยงExamples

use screeps::RoomXY;
use screeps_pathfinding::utils::goals::goal_exact_node;
use screeps_pathfinding::utils::heuristics::heuristic_get_range_to;

let start = RoomXY::checked_new(24, 18).unwrap();
let goal = RoomXY::checked_new(34, 40).unwrap();
let cost_fn = |_| Some(1);
screeps_pathfinding::algorithms::astar::shortest_path_roomxy(
    start,
    &goal_exact_node(goal),
    cost_fn,
    &heuristic_get_range_to(goal),
);