Sign in to follow this  
suliman

Pathfinding noob, nodes instead of tiles

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Also, the nodes in the graph that you search with A* don't have to correspond to points in your world; they can also correspond to regions. Then the edges of your graph just encode which regions are adjacent. This is the basic idea behind the popular navmesh concept.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this