Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/ruk33/astar
- Owner: Ruk33
- Created: 2023-01-31T23:01:14.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-08-19T09:18:04.000Z (4 months ago)
- Last Synced: 2024-08-19T10:57:46.749Z (4 months ago)
- Topics: astar-algorithm, astar-pathfinding, pathfinding, pathfinding-algorithm
- Language: C
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
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?