Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving by predefined weaypoints #4

Closed
linuxenko opened this issue Mar 11, 2016 · 4 comments
Closed

Moving by predefined weaypoints #4

linuxenko opened this issue Mar 11, 2016 · 4 comments

Comments

@linuxenko
Copy link

First of all sorry , my question does not directly related to the path-finder :$

Can you please help me understand, find tools or documentation how to make some movement by predefined maps, how to create them, best practices idk. I'm trying learn through source code of some "towerdefence" games published on github, but.. it looks like they are does not implement it right . I don't know, but it feels like they are trying invent from 0 something like good known and many years available allgorithm. It looks like you know the secret of right algorithm for waypoints (2d of source), can you please help me, or suggest something to read to understand how to do it in right way.

Thank you

@mikolalysenko
Copy link
Owner

For a tower defense game you might want to consider using Dijkstra's algorithm to compute all single source shortest paths, then have each unit follow along the path tree to get to the root node. If you precalculate this data once, then you can just store it and get the movement for each unit in O(1) time.

@linuxenko
Copy link
Author

Thank you !

@redblobgames
Copy link
Collaborator

And if you don't have different movement costs for edges, you can use Breadth First Search instead of Dijkstra's Algorithm. Demo: http://www.redblobgames.com/pathfinding/tower-defense/

@linuxenko
Copy link
Author

Thank you @redblobgames ! bfs looks simple, i'll try implement it. What the better way to visualize it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants