26#define MAZE_INVERT_BITMASK(x) ((0xFu - x) & 0xFu)
173 uint8_t aligned_wall_bitmask,
203 uint16_t buffer_size);
207 uint16_t buffer_size);
struct maze_navigator_state maze_navigator_state_t
This struct contains the state of a navigator in the maze.
struct maze_grid_cell maze_grid_cell_t
This struct contains the node information.
maze_grid_cell_t * maze_get_cell_at_coords(maze_grid_t *p_grid, const maze_point_t *p_coordinates)
Get the cell at the specified coordinates.
Definition: maze.c:470
int16_t maze_deserialise(maze_grid_t *p_grid, maze_gap_bitmask_t *p_no_walls_array)
Deserialises the maze from a bitmask array. maze_serialise.
Definition: maze.c:361
struct maze_grid maze_grid_t
This struct contains the maze grid information.
maze_grid_cell_t * maze_get_cell_in_dir(maze_grid_t *p_grid, maze_grid_cell_t *p_from, maze_cardinal_direction_t direction)
Get the cell in the specified direction from a specific cell.
Definition: maze.c:501
maze_gap_bitmask_t maze_serialise(maze_grid_t *p_grid)
Serialises the maze into a bitmask array. maze_deserialise.
Definition: maze.c:422
int16_t maze_nav_to_buffer(const maze_navigator_state_t *p_navigator, uint8_t *p_buffer, uint16_t buffer_size)
Serialises the navigator state into a uint8_t buffer. The buffer is set with the navigator's coordina...
Definition: maze.c:674
union maze_bitmask_compressed maze_bitmask_compressed_t
Used for sending the maze over serial or WiFi.
void maze_uint16_to_uint8_buffer(uint16_t value, uint8_t *p_buffer)
Helper function to convert a uint16_t to a uint8_t buffer.
Definition: maze.c:721
maze_relative_direction_t maze_get_relative_dir(const maze_cardinal_direction_t direction_from, const maze_cardinal_direction_t direction_to)
Gets the relative direction from the current direction to the desired cardinal direction.
Definition: maze.c:549
struct maze_gap_bitmask maze_gap_bitmask_t
This struct contains the maze gap bitmasks for serialisation.
uint32_t maze_manhattan_dist(const maze_point_t *p_point_a, const maze_point_t *p_point_b)
Calculates the manhattan distance between two points.
Definition: maze.c:532
int16_t maze_serialised_to_buffer(const maze_gap_bitmask_t *p_bitmask, uint8_t *p_buffer, uint16_t buffer_size)
Serialises the maze into a uint8_t buffer.
Definition: maze.c:621
maze_grid_t maze_create(uint16_t rows, uint16_t columns)
Create a maze with the specified number of rows and columns.
Definition: maze.c:56
maze_cardinal_direction_t maze_get_dir_from_to(const maze_point_t *p_point_a, const maze_point_t *p_point_b)
Get the direction from p_point_a to p_point_b if they are adjacent.
Definition: maze.c:316
void maze_nav_modify_walls(maze_grid_t *p_grid, maze_navigator_state_t *p_navigator, uint8_t aligned_wall_bitmask, bool is_set, bool is_unset)
Modifies the walls of the navigator's current node.
Definition: maze.c:168
maze_cardinal_direction_t
This enum contains the possible directions.
Definition: maze.h:47
@ MAZE_SOUTH
South is the bottom of the maze.
Definition: maze.h:50
@ MAZE_EAST
East is the right of the maze.
Definition: maze.h:49
@ MAZE_WEST
West is the left of the maze.
Definition: maze.h:51
@ MAZE_NORTH
North is the top of the maze.
Definition: maze.h:48
@ MAZE_NONE
None is used for errors.
Definition: maze.h:52
void maze_insert_nav_str(const maze_grid_t *p_grid, const maze_navigator_state_t *p_navigator, char *maze_str)
Inserts the navigator character into the maze string for pretty printing.
Definition: maze.c:273
int8_t maze_get_nav_dir_offset(const maze_navigator_state_t *p_navigator)
Get the offset from the navigator's current direction to any other possible direction.
Definition: maze.c:148
void maze_destroy(maze_grid_t *p_grid)
Destroys the maze by freeing the memory allocated to the grid array.
Definition: maze.c:125
void maze_clear_heuristics(maze_grid_t *p_grid)
Clears the maze heuristics. This sets the F, G, and H values of each node to UINT32_MAX for the A* an...
Definition: maze.c:103
maze_wall_direction_t
This enum contains bitmasks for the walls. Useful when updating more than one wall at a time.
Definition: maze.h:63
@ MAZE_NO_WALLS
No walls.
Definition: maze.h:64
@ MAZE_BACK_WALL
Back wall.
Definition: maze.h:67
@ MAZE_RIGHT_WALL
Right wall.
Definition: maze.h:66
@ MAZE_LEFT_WALL
Left wall.
Definition: maze.h:68
@ MAZE_FRONT_WALL
Front wall.
Definition: maze.h:65
struct maze_point maze_point_t
This struct contains the coordinates of a point.
void maze_initialise_empty_walled(maze_grid_t *p_grid)
Initialises an empty maze. This sets the coordinates of each node, all heuristic values to 0,...
Definition: maze.c:74
char * maze_get_string(maze_grid_t *p_grid)
Get the string representation of the maze for pretty printing.
Definition: maze.c:213
maze_relative_direction_t
This enum contains the relative directions of instructions from the navigator's perspective.
Definition: maze.h:77
@ MAZE_LEFT
Left of the navigator.
Definition: maze.h:81
@ MAZE_BACK
Back of the navigator.
Definition: maze.h:80
@ MAZE_RIGHT
Right of the navigator.
Definition: maze.h:79
@ MAZE_FRONT
Front is the direction the navigator is facing.
Definition: maze.h:78
This struct contains the maze gap bitmasks for serialisation.
Definition: maze.h:137
uint16_t * p_bitmask
Definition: maze.h:138
uint16_t rows
Number of rows.
Definition: maze.h:140
uint16_t columns
Number of columns.
Definition: maze.h:141
This struct contains the node information.
Definition: maze.h:91
maze_point_t coordinates
X and Y coordinates of the node.
Definition: maze.h:92
uint32_t g
Definition: maze.h:94
struct maze_grid_cell * p_next[4]
Definition: maze.h:99
uint32_t h
Definition: maze.h:96
struct maze_grid_cell * p_came_from
Definition: maze.h:101
bool is_visited
Indicates if the node has been visited before.
Definition: maze.h:104
uint32_t f
F-value of the node. F = G + H.
Definition: maze.h:93
This struct contains the maze grid information.
Definition: maze.h:113
maze_grid_cell_t * p_grid_array
Definition: maze.h:114
uint16_t rows
Number of rows in the grid.
Definition: maze.h:116
uint16_t columns
Number of columns in the grid.
Definition: maze.h:117
This struct contains the state of a navigator in the maze.
Definition: maze.h:124
maze_grid_cell_t * p_start_node
Pointer to the start node of the maze.
Definition: maze.h:127
maze_grid_cell_t * p_current_node
Definition: maze.h:125
maze_grid_cell_t * p_end_node
Pointer to the end node of the maze.
Definition: maze.h:128
maze_cardinal_direction_t orientation
Definition: maze.h:129
This struct contains the coordinates of a point.
Definition: maze.h:37
uint16_t x
X-coordinate or column.
Definition: maze.h:38
uint16_t y
Y-coordinate or row.
Definition: maze.h:39
Used for sending the maze over serial or WiFi.
Definition: maze.h:148
uint8_t bits
Combined bitmasks.
Definition: maze.h:154
uint8_t cell_b
Cell B bitmask (LSB).
Definition: maze.h:151
struct maze_bitmask_compressed::@0 fields
Bit masks for each cell.
uint8_t cell_a
Cell A bitmask (MSB).
Definition: maze.h:152