Hi all
Having recently implemented a nodegraph system into my game engine I decided to move onto traversing it, as to be able to pathfind from one starting node to a target.
The issue is, I’m not too sure how to do this. I tried diving in to write a test implementation, storing previously visited nodes in a list, but I can’t get my head around the logic to progress along. It’s probably obvious that I’m very new to pathfinding logic…
Does anybody know of any resources to implement pathfinding into a node-based system, or is able to share any information of their own?
I’m going to keep plugging at it, but thank you very much in advance for any help
Those are some algorithms for finding the shortest path in a graph.
I’m going to have a look at those, but I’ll quickly update with what I’m trying to do - pathfinding through arbitrarily placed nodes with no real semblance of a grid at all. They’re not uniformly distributed.
The issue for me is finding the right algorithm to implement, not so much writing the code to do it once I have one.
The algorithm you probably want is A*. The problem you actually have is computing the heuristic.
Cas
like princec says, try A*
Forget the grid, think about your node as a graph (connected I hope!), some code and example here:
http://graphstream-project.org/doc/Algorithms/Shortest-path/A-star/
note: there is a looot of theory behind and a lot of code already done, use them!