1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#ifndef ASTAR_H_
#define ASTAR_H_
#include "structs.h"
#include "map.h"
/* The currently chosen path func */
extern Path (*path_func)(int, Map, size_t **, size_t, size_t, Position, Position, char **, char);
/* Time it took to calculate a path */
extern double path_time;
/* dirs can be 4 or 8 to disallow or allow diagonal movement */
//Path breadth_first_search_path(int dirs, Map map, size_t **cell_costs, size_t width, size_t height, Position start, Position end, char **visited, char should_anim);
Path dijkstra_path(int dirs, Map map, size_t **cell_costs, size_t width, size_t height, Position start, Position end, char **visited, char should_anim);
Path astar_path(int dirs, Map map, size_t **cell_costs, size_t width, size_t height, Position start, Position end, char **visited, char should_anim);
size_t manhattan_distance(Position a, Position b);
size_t diagonal_distance(Position a, Position b);
Path path_new(size_t width, size_t height);
void path_free(Path path, size_t height);
/* Reverses the path in place and switches start and end */
void path_reverse(Path *path, size_t width, size_t height, Position *start, Position *end);
/* Helper funcs for the visited array */
char **visited_new(size_t width, size_t height);
void visited_clear(char **visited, size_t width, size_t height);
void visited_free(char **visited, size_t height);
size_t visited_count(char **visited, size_t width, size_t height);
/* Helper funcs for the cost arrays */
size_t **cost_new(size_t width, size_t height);
void cost_free(size_t **cost, size_t height);
#endif /* ASTAR_H_ */
|