-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvisualize.cpp
More file actions
120 lines (93 loc) · 2.89 KB
/
visualize.cpp
File metadata and controls
120 lines (93 loc) · 2.89 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include <iostream>
#include <stdlib.h>
#include <limits>
#include "class_node.h"
#include "class_map.h"
#include "uniformCost.cpp"
#include "breadthfirst.cpp"
#include "greedyBestFirst.cpp"
#include "class_AStar.h"
void enterToContinue(){
std::cout << "press ENTER to continue" << '\n';
std::cin.ignore(std::numeric_limits <std::streamsize> ::max(), '\n');
}
/* NOTES:
**
** The A* algorithm displays the f = g+h value, due to the limitation of two
** characters on the printed map this can not be displayed correctly on large
** maps.
**
** This program can be uesed on all maps;
**
*/
int main(){
// change size of random map if you want
int hight = 40;
int width = 40;
// Use saved maps:
pfMap compare1(*pfMap::LoadMap("maps/compare1.csv"));
//pfMap compare1(*pfMap::LoadMap("maps/map1.csv"));
//pfMap compare1(*pfMap::LoadMap("maps/map2.csv"));
// Use random generated map with specified dimensions:
// (be careful not to initiate compare1 twice)
//pfMap compare1(hight, width);
if(false){ // toggle if using random maps
compare1.SetTypeAt(2,2,4); // set start
compare1.SetTypeAt(hight-2, width-2, 5); // set target
}
// copy maps for all algorithms
pfMap compare1BF(compare1);
pfMap compare1UC(compare1);
pfMap compare1GB(compare1);
pfMap compare1ASMan(compare1);
pfMap compare1ASEuk(compare1);
pfMap compare1ASMin(compare1);
pfMap compare1ASSup(compare1);
bool animate = false;
bool visualize = false;
std::cout << "animate?" << '\n';
std::cout << "(yes/no):";
std::string input;
std::cin >> input;
std::cout << std::endl;
if(input == "yes")
animate = true;
else if(input=="no")
visualize = true;
else
return 1;
// because the first one doesn't do anything..
std::cin.ignore(std::numeric_limits <std::streamsize> ::max(), '\n');
std::cout << "breadthfirst:";
Breadthfirst(compare1BF,visualize, animate);
if(!animate){compare1BF.PrintMap();}
enterToContinue();
std::cout << "uniform cost:";
uniformCost(compare1UC,visualize, animate);
if(!animate){compare1UC.PrintMap();}
enterToContinue();
std::cout << "greedy best first:";
GreedyBestFirst(compare1GB, visualize, animate);
if(!animate){compare1GB.PrintMap();}
enterToContinue();
std::cout << "A* (manhattan):";
pfAStar ASMan(compare1ASMan);
ASMan.solve("Manhattan",visualize, animate);
if(!animate){compare1ASMan.PrintMap();}
enterToContinue();
std::cout << "A* (euklid):";
pfAStar ASEuk(compare1ASEuk);
ASEuk.solve("Euklid",visualize, animate);
if(!animate){compare1ASEuk.PrintMap();}
enterToContinue();
std::cout << "A* (minimum):";
pfAStar ASMin(compare1ASMin);
ASMin.solve("Minimum",visualize, animate);
if(!animate){compare1ASMin.PrintMap();}
enterToContinue();
std::cout << "A* (supremum):";
pfAStar ASSup(compare1ASSup);
ASSup.solve("Supremum",visualize, animate);
if(!animate){compare1ASSup.PrintMap();}
return 0;
}