75#define ASTAR_CARDINAL_ONLY 0
77#define ASTAR_ALLOW_DIAGONAL 1
80#define ASTAR_COST_CARDINAL 1000
82#define ASTAR_COST_DIAGONAL 1414
84#define ASTAR_COST_DIAGONAL3D 1732
87#define ASTAR_NODE_NONE 0
89#define ASTAR_NODE_OPEN 1
91#define ASTAR_NODE_CLOSED 2
int f
priority (f = g + h)
int capacity
allocated capacity
int parent_z
parent cell Z
int parent_x
parent cell X (-1 if none)
int depth
grid depth (Z axis, 1 for 2D)
int cost
total path cost (x1000 fixed-point)
uint8_t status
ASTAR_NODE_NONE / OPEN / CLOSED.
int width
grid width (X axis)
ASTAR_NODE * nodes
array of path nodes from start to goal
int height
grid height (Y axis)
int g
cost from start to this cell
uint8_t * walkable
walkability map: 1=passable, 0=blocked
int * cost
per-cell movement cost multiplier (x1000)
ASTAR_HEAP_NODE * data
heap array
int size
current number of elements
int h
heuristic estimate to goal
int parent_y
parent cell Y
int z
grid Z coordinate (0 for 2D)
int length
number of nodes in the path
int n_astar_grid_get_cost(const ASTAR_GRID *grid, int x, int y, int z)
get a cell's movement cost multiplier (x1000)
ASTAR_PATH * n_astar_find_path(const ASTAR_GRID *grid, int sx, int sy, int sz, int gx, int gy, int gz, int diagonal, ASTAR_HEURISTIC heuristic)
find a path using A* search, returns NULL if no path exists
void n_astar_grid_set_cost(ASTAR_GRID *grid, int x, int y, int z, int cost)
set a cell's movement cost multiplier (x1000)
uint8_t n_astar_grid_get_walkable(const ASTAR_GRID *grid, int x, int y, int z)
get a cell's walkability (1=passable, 0=blocked, 0 if out of bounds)
ASTAR_HEURISTIC
Heuristic function selection for h(n) estimation.
void n_astar_grid_free(ASTAR_GRID *grid)
free a grid and all its internal data
int n_astar_heuristic(int x1, int y1, int z1, int x2, int y2, int z2, ASTAR_HEURISTIC heuristic)
compute heuristic distance between two points (x1000)
void n_astar_grid_set_rect_blocked(ASTAR_GRID *grid, int x1, int y1, int z1, int x2, int y2, int z2)
set a rectangular region as blocked
void n_astar_path_free(ASTAR_PATH *path)
free a path returned by n_astar_find_path
void n_astar_grid_set_walkable(ASTAR_GRID *grid, int x, int y, int z, uint8_t walkable)
set a cell's walkability (1=passable, 0=blocked)
ASTAR_GRID * n_astar_grid_new(int width, int height, int depth)
create a new grid for pathfinding, all cells default to walkable
@ ASTAR_HEURISTIC_EUCLIDEAN
straight-line distance
@ ASTAR_HEURISTIC_CHEBYSHEV
max of axis deltas (optimal for 8-dir)
@ ASTAR_HEURISTIC_MANHATTAN
sum of axis deltas (optimal for 4-dir)
Internal node data used during pathfinding.
Grid structure holding walkability, costs, and dimensions.
Binary min-heap (priority queue) for the open list.
Min-heap entry for the open list priority queue.
A single node in the resulting path.
The computed path result.