INF2004-Project v0.1
 
Loading...
Searching...
No Matches
a_star.h
Go to the documentation of this file.
1
11#ifndef A_STAR_H // Include guard.
12#define A_STAR_H
13
14#include <stdint.h>
16#include "pathfinding/maze.h"
17
18#ifndef NDEBUG
25#define DEBUG_PRINT(...) printf(__VA_ARGS__)
26#else
27#define DEBUG_PRINT(...)
28#endif
29
30// Type definitions.
31// ----------------------------------------------------------------------------
32//
33
39typedef struct a_star_path
40{
41 uint32_t length;
44
45// Public functions.
46// ----------------------------------------------------------------------------
47//
48
49void a_star(maze_grid_t *p_grid,
50 maze_grid_cell_t *p_start_node,
51 maze_grid_cell_t *p_end_node);
52
54
55char *a_star_get_path_str(maze_grid_t *p_grid, a_star_path_t *p_path);
56
57int16_t a_star_path_to_buffer(const a_star_path_t *p_path,
58 uint8_t *p_buffer,
59 uint16_t buffer_size);
60
62 maze_grid_t *p_grid,
63 const a_star_path_t *p_path,
64 const maze_navigator_state_t *p_navigator,
65 uint8_t *p_buffer,
66 uint16_t buffer_size);
67
68#endif // A_STAR_H
69
70// End of pathfinding/a_star.h
int16_t a_star_maze_path_nav_to_buffer(maze_grid_t *p_grid, const a_star_path_t *p_path, const maze_navigator_state_t *p_navigator, uint8_t *p_buffer, uint16_t buffer_size)
Inserts the maze, path and navigator state into a buffer.
Definition: a_star.c:264
a_star_path_t * a_star_get_path(maze_grid_cell_t *p_end_node)
Get the path from the start node to the end node (inclusive).
Definition: a_star.c:108
int16_t a_star_path_to_buffer(const a_star_path_t *p_path, uint8_t *p_buffer, uint16_t buffer_size)
Inserts the path in coordinates from the start node to the end node into a buffer.
Definition: a_star.c:208
struct a_star_path a_star_path_t
Struct containing the path from the start node to the end node.
void a_star(maze_grid_t *p_grid, maze_grid_cell_t *p_start_node, maze_grid_cell_t *p_end_node)
Runs the A* algorithm on a grid maze to find the shortest path between two points,...
Definition: a_star.c:59
char * a_star_get_path_str(maze_grid_t *p_grid, a_star_path_t *p_path)
Gets the string representation of the path from the start node to the end node.
Definition: a_star.c:142
This file contains the declarations for the binary min-heap used in the a* algorithm.
Header file for the maze data structure and public functions.
Struct containing the path from the start node to the end node.
Definition: a_star.h:40
maze_grid_cell_t * p_path
Pointer to the first node in the path.
Definition: a_star.h:42
uint32_t length
Length of the path.
Definition: a_star.h:41
This struct contains the node information.
Definition: maze.h:91
This struct contains the maze grid information.
Definition: maze.h:113
This struct contains the state of a navigator in the maze.
Definition: maze.h:124