posted 14 years ago
Hi guys,
I'm having some problems with my AI homework. We're studying A* pathfinding and I'm trying to implement a greedy best-first search algorithm before building on it to create the A* algorithm. My algorithm should return a graph from A to B once the algorithm has done its thing.
As a parameter, I supply the search function with a grid (two-dimensional array) to find a path through. Each time the algorithm decides the next step to take, it creates a new node and adds this node to an ArrayList (of type Node). My problems start when my program finds that it's walked down a dead end due to being greedy and needs to retrace steps to try the next quickest route from where it went wrong. How would I implement this behavior? (Recording how the current position was reached and backpedalling until the point where it went bad).
Thanks in advance for your help!