pub fn rewind_jps(start: &Node, closed: &Vec<Node>) -> Vec<Coords2D> {
    let mut path = Vec::with_capacity(closed.len().pow(2) + 1);

    path.push(start.position);

    let mut parent = start.parent;
    let mut node = start.position;

    while parent != node {
        if let Some(step) = closed.iter().find(|x| x.position == parent) {
            let direction = direction(parent, node);
            let mut next = shift(node, direction);

            //Push intermidiate nodes if any
            while next != parent {
                path.push(next);

                next = shift(next, direction);
            }

            //Push actual steps
            parent = step.parent;
            node = step.position;
            path.push(node);
        }
    }

    path
}
//Helper function to recreate path once goal is located
Helper function to recreate path once goal is located
Helper function to recreate path once goal is located
pub fn rewind_jps(start: &Node, closed: &Vec<Node>) -> Vec<Coords2D> {
    let mut path = Vec::with_capacity(closed.len().pow(2) + 1);
    path.push(start.position);
    let mut parent = start.parent;
    let mut node = start.position;
    while parent != node {
        if let Some(step) = closed.iter().find(|x| x.position == parent) {
            let direction = direction(parent, node);
            let mut next = shift(node, direction);
            //Push intermidiate nodes if any
            while next != parent {
                path.push(next);
                next = shift(next, direction);
            }
            //Push actual steps
            parent = step.parent;
            node = step.position;
            path.push(node);
        }
    }
    path
}
pub fn rewind_jps ( start : & Node , closed : & Vec < Node > ) -> Vec < Coords2D > { let mut path = Vec :: with_capacity ( closed . len ( ) . pow ( 2 ) + 1 ) ; path . push ( start . position ) ; let mut parent = start . parent ; let mut node = start . position ; while parent != node { if let Some ( step ) = closed . iter ( ) . find ( | x | x . position == parent ) { let direction = direction ( parent , node ) ; let mut next = shift ( node , direction ) ; //Push intermidiate nodes if any while next != parent { path . push ( next ) ; next = shift ( next , direction ) ; } //Push actual steps parent = step . parent ; node = step . position ; path . push ( node ) ; } } path }
Helper function to recreate path once goal is located
Helper function to recreate path once goal is located
start
&Node
closed
&Vec<Node>