-
Notifications
You must be signed in to change notification settings - Fork 1
/
prepare_maze.cpp
57 lines (44 loc) · 1.82 KB
/
prepare_maze.cpp
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include "AStar.hpp"
#include <vector>
using namespace std;
using pos_type = vector<int>;
vector<string> maze = {
"###############################",
"#a # # #",
"# #### # # # # #### ####",
"# # # # # #",
"# #### #### # # ####### #",
"# # # # # # #",
"###################### # ####",
"# # # #",
"# ####### #### #### # # #",
"# # # # # # # #",
"# # # # ####### # # # #",
"# # # # # # #",
"# # # ####### #### #######",
"# # # # #",
"# #### # # # # ####### #",
"# # # # # # # # # #",
"# ########## # # # # # #",
"# # # # # #",
"# ####### ########## #######",
"# # # b#",
"###############################"
};
// prepare maze to be able to pass it into AStar()
vector<vector<int>> prepared_maze = prepared_maze(maze);
int main() {
vector<int> start = findobj(maze, 'a');
vector<int> end = findobj(maze, 'b');
// returns AStarResult Class
AStarResult result = AStar(prepare_maze(maze), start, end);
// returns min movements made to get from start_node to end_node
cout << "A* made " << result.movements << " moves to reach (" <<
end[0] << ", " << end[1] << ")"
<< " from (" << start[0] << ", " << start[1] << ")\n";
// prints out the whole maze with drawn path
result.print_maze_solution_path();
// .path_went variable contains the path went by the fastest node
vector<pos_type> went_path = result.path_went;
}