Pathfinding noob, nodes instead of tiles
Hi
Im using pathfinding code i found on the net (A*). And i understand most of it. Its based on tiles so each tile connects automatically to each 8 tiles around it.
In my new game i need to add nodes manually on the map and let my actors (ships on ocean moving between ports) pathfind these nodes to travel correctly.
How would this work? My idea is to have all nodes check for suitable "neibours" beforehand and store this.
The patherclass has functions like AdjacentCost, findPath etc. So you think i could modify the old tilebased class into something that works with arbitrary positioned nodes or does that work completely different?
Thanks
E
The A* algorithm isnt exclusive to tiles, it is actually a graph search algorithm, tile based a* just treats each tile as a node with 4 (or 8) connections to neighbour nodes. You could use any arbitrary number of nodes or layout of the nodes, you could use any mesh (essentially a 2d graph) where the mesh represents the sea (or seaways) and some nodes are ports. The ship could sail to the nearest node and run A* to find its way to port.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement