-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
47 lines (44 loc) · 1.46 KB
/
main.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
#include <iostream>
#include "dijkstra.h"
#include "structures.h"
int main(int argc, const char *argv[])
{
Dijkstra planner;
bool dma = true;
std::string input_name = "Data/0.map";
if(argc > 1)
input_name = argv[1];
Input input(input_name, dma);
SearchResult result = planner.findPath(input);
if(result.pathfound)
{
for(auto it = result.path.begin(); it != --result.path.end(); it++)
std::cout<<"("<<it->x<<","<<it->y<<")->";
std::cout<<"("<<(--result.path.end())->x<<","<<(--result.path.end())->y<<")";
}
else
std::cout<<"PATH NOT FOUND!";
std::cout<<"\nCost:"<<result.cost
<<"\nRuntime: "<<result.runtime
<<"\nSteps: "<<result.steps
<<"\nNodes Created: "<<result.createdNodes
<<"\nTrue Cardinal Cost:"<<input.true_cardinal_cost
<<"\nTrue Diagonal Cost:"<<input.true_diagonal_cost<<"\n";
std::cout<<"\ndma:"<<dma;
if(dma) {
std::cout<<"Does costs equal?"<<std::endl;
if(result.cost == input.true_diagonal_cost) {
std::cout<<"Yes"<<std::endl;
}else {
std::cout<<"No"<<std::endl;
}
}else {
std::cout<<"Does costs equal?"<<std::endl;
if(result.cost == input.true_cardinal_cost) {
std::cout<<"Yes"<<std::endl;
}else {
std::cout<<"No"<<std::endl;
}
}
return 0;
}