-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
70 lines (56 loc) · 1.8 KB
/
main.cpp
File metadata and controls
70 lines (56 loc) · 1.8 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <iostream>
#include "Situation.hpp"
#include "BFS.hpp"
#include "DFS.hpp"
#include "AStar.hpp"
#include "GradientSearch.hpp"
#include "PriceMatch.hpp"
#include "BranchAndBound.hpp"
#include "Dijkstra.hpp"
void printPath(const std::vector<Situation>& path) {
std::cout << "Path length: " << path.size() << std::endl;
for (const auto& state : path) {
for (const auto& row : state.getGrid()) {
for (char c : row) std::cout << c << " ";
std::cout << std::endl;
}
std::cout << "----------------" << std::endl;
}
}
void startSearch(Situation start){
std::cout << "BFS:" << std::endl;
auto bfsPath = bfsSearch(start);
printPath(bfsPath);
std::cout << "\nDFS:" << std::endl;
auto dfsPath = dfsSearch(start);
printPath(dfsPath);
std::cout << "\nGradient Manhattan Search:" << std::endl;
auto gdPath0 = gradientManhattanSearch(start);
printPath(gdPath0);
std::cout << "\nGradient Euclid Search:" << std::endl;
auto gdPath1 = gradientEuclidSearch(start);
printPath(gdPath1);
std::cout << "\nPrice Match Search:" << std::endl;
auto ucPath = priceMatchSearch(start);
printPath(ucPath);
std::cout << "\nBranch and Bound Search:" << std::endl;
auto bbPath = branchAndBoundSearch(start);
printPath(bbPath);
std::cout << "\nDijkstra Search:" << std::endl;
auto DijkstraPath = dijkstraSearch(start);
printPath(DijkstraPath);
std::cout << "\nA* Search:" << std::endl;
auto aStarPath = aStarSearch(start);
printPath(aStarPath);
}
int main() {
std::vector<std::vector<char>> grid = {
{'0', '0', '0', 'F'},
{'0', '1', '0', '1'},
{'0', 'R', '1', '0'},
{'0', '0', '0', '0'}
};
Situation start(grid);
startSearch(start);
return 0;
}