This repository was archived by the owner on Jul 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
114 lines (86 loc) · 2.61 KB
/
main.cpp
File metadata and controls
114 lines (86 loc) · 2.61 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
//
// Created by grant on 8/2/19.
//
#include <iostream>
#include <fstream>
#include "maze.h"
int main(int argc, char** argv)
{
if(argc == 2)
{
std::fstream mazeFile;
mazeFile.open(argv[1]);
maze Maze = maze();
int key = 0;
int N;
mazeFile >> N; //stores the size of the maze
for (int k = 0; k < (N * N); ++k) {
std::vector<int> flags;
for (int i = 0; i < 4; ++i) {
int temp;
mazeFile >> temp;
flags.push_back(temp);
}
Maze.addRoom(key, flags);
key++;
}
Maze.generateMaze(N);
Maze.printMaze(N);
std::cout << std::endl;
std::cout << "Rooms visited by BFS" << std::endl;
auto bfsPath = Maze.solveBFS();
std::cout << std::endl;
std::cout << "Path determined by BFS" << std::endl;
for(auto &i : bfsPath)
std::cout << i->getRoomNumber() << " ";
Maze.printPath(bfsPath, N);
std::cout << std::endl;
std::cout << "Rooms visited by DFS" << std::endl;
auto dfsPath = Maze.solveDFS();
std::cout << std::endl;
std::cout << "Path determined by DFS" << std::endl;
for(auto &i : dfsPath)
std::cout << i->getRoomNumber() << " ";
Maze.printPath(dfsPath , N);
mazeFile.close();
}
else if(argc > 2)
{
std::cout << "invalid arguments";
return 69;
}
else
{
//generate graph with closed doors
int N;
std::cout << "Input maze size" << std::endl;
std::cin >> N;
maze Maze = maze();
for (int i = 0; i < (N * N) ; ++i)
{
std::vector<int> flags = {1,1,1,1};
Maze.addRoom(i, flags);
}
Maze.prepRooms();
Maze.linkAdjRooms(N);
Maze.randRoomFlags();
Maze.generateMaze(N);
Maze.printMaze(N);
std::cout << "Rooms visited by BFS" << std::endl;
auto bfsPath = Maze.solveBFS();
std::cout << std::endl;
std::cout << "Path determined by BFS" << std::endl;
for(auto &i : bfsPath)
std::cout << i->getRoomNumber() << " ";
Maze.printPath(bfsPath, N);
std::cout << std::endl;
std::cout << "Rooms visited by DFS" << std::endl;
auto dfsPath = Maze.solveDFS();
std::cout << std::endl;
std::cout << "Path determined by DFS" << std::endl;
for(auto &i : dfsPath)
std::cout << i->getRoomNumber() << " ";
Maze.printPath(dfsPath , N);
}
return 100;
}