-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
70 lines (51 loc) · 1.63 KB
/
Copy pathmain.cpp
File metadata and controls
70 lines (51 loc) · 1.63 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
// main.cpp
#include <list>
#include <iostream>
#include <fstream>
#include "Path.hpp"
#include "Path_Finder.hpp"
using namespace std;
int main() {
Map m;
string name;
cout << "Kartenname: ";
cin >> name;
name += ".txt";
ifstream f(name);
if (f.fail()) {
cout << "Die Karte konnte nicht gefunden werden. Stellen Sie sicher, dass diese im gleichen Verzeichnnis wie das Programm liegt und diese auf .txt endet."
<< endl << endl << "Bsp: 'karte' öffnet die Datei 'karte.txt'" << endl<< endl;
return EXIT_FAILURE;
}
f >> m;
if(!f.eof() && f.fail()) {
cout << "Die Karte hat das flasche Format. Geben Sie nicht die Maße der Karte zu beginn der Datei an. Verwenden Sie keine leeren Zeilen."
<< endl << endl << "Bsp: " << endl << "XXXXX" << endl << "X...X" << endl << "XXXXX" << endl << endl;
return EXIT_FAILURE;
}
f.close();
cout << "eingelesene Karte:" << endl;
cout << "Y X -->" << endl << "|" << endl << "|" << endl << "V" << endl << endl;
cout << m << endl;
Coordinate start;
Coordinate target;
cout << "eingabe Format: X Y" << endl;
cout << "Start: ";
cin >> start;
cout << "Ziel: ";
cin >> target;
Path_Finder pf(m);
cout << endl << "First Best:" << endl;
vector<Coordinate> path = pf.search(start, target, heur_best_first);
cout << "Laenge:" << path.size() << endl;
m.print(path);
cout << endl << "Dijkstra:" << endl;
path = pf.search(start, target, heur_dijkstra);
cout << "Laenge:" << path.size() << endl;
m.print(path);
cout << endl << "A*:" << endl;
path = pf.search(start, target, heur_a_star);
cout << "Laenge:" << path.size() << endl;
m.print(path);
return EXIT_SUCCESS;
}