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

Set up clean pathfinding codebase #249

Open
mkalam-alami opened this issue Feb 23, 2012 · 0 comments
Open

Set up clean pathfinding codebase #249

mkalam-alami opened this issue Feb 23, 2012 · 0 comments

Comments

@mkalam-alami
Copy link
Collaborator

A good pathfinding system would unlock awesome AIs (#7) and more. Regarding the existing code, it could already be used to replace some code in the Zombie and Turret classes. Feel free to make suggestions.

Specifications draft

Interface

Add some methods to the Entity class, to be used by anyone needs them.

  • protected boolean isVisible(Entity e) Uses raytracing to check all tiles on its way to the target's position
  • protected void moveTo(Entity e) Uses Dijkstra/A* to compute the path to a target, then call Entity.move(double xa, double ya) accordingly

Caching

Both methods might be very resource-demanding if used on each tick ; under the hood they should cache the results of all paths, for instance by:

  • Storing a Map<Tile, List<Tile>> (the key being the target tile, and the value the path to the target)
  • Cleaning the map as soon as the Entity goes to another Tile.

This would cost some RAM but also have the huge advantage to be safe for extensive use.

This was referenced Feb 23, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant