Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ruk33/astar

simple path finding / a star code.
https://github.com/ruk33/astar

astar-algorithm astar-pathfinding pathfinding pathfinding-algorithm

Last synced: about 1 month ago
JSON representation

simple path finding / a star code.

Awesome Lists containing this project

README

        

astar / path finding
this is a very simple path finding function. from two points, it will
calculate the next step to walk that's closer to the end goal.

this is intended to be extremely simple and easy to follow, no messing
around with extra steps or trying to be fancy. if you are strugling
with path finding as i was a few months ago, this could be your solution.

how to use it?
first, make sure you implement the functions:
- points_are_equal: checks if two points are equal.
- point_is_walkable: checks if a point is walkable (ie, is terrain?)
- point_has_obstacle: checks if a point, even if walkable, contains
an obstacle (ie, another unit, a wall, etc.)

after that, the function find_path can be called to get/calculate
the next step from start to end.

this is, imagine you have the following map/grid:
[s][x][x][x][x][x][x][e]

where s = start and e = end. upon calling find_path, the result
would be (r):
[s][r][x][x][x][x][x][e]

call it again from result to get closer and closer to the
destination:
[x][s][x][x][x][x][x][e]

would result in:
[x][s][r][x][x][x][x][e]

find_path will return 1 if the path is possible, or 0 if not.

license
whatever, mit?