-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
157 lines (122 loc) · 4.15 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#include <vector>
#include <iostream>
#include <chrono>
#define pii pair<int, int>
#include "object.h"
#include "miscsymbols.h"
#include "blockgroup.h"
#include "util.h"
#include "grid.h"
#include "solver.h"
#include "randgrid.h"
#include "witnessgame.h"
int main()
{
Solver sx;
RandGrid random;
vector<vector<Object*>> v;
random.pathfind();
/*
WitnessGame game = WitnessGame(random.randMaze());
std::cout << game.origin.first << " " << game.origin.second << "\n";
while (true) {
game.grid.disp();
char c;
std::cin >> c;
if (c == 'X') game.clear();
else game.processInput(c);
if (game.reachedEnd()) {
if (game.grid.ver(game.origin.first, game.origin.second)) {
cout << "YOU WIN!!!!\n";
game.grid.disp();
return 0;
}
else {
cout << "YOU LOSE!!!!\n";
game.clear();
game.grid.disp();
}
}
}
*/
/*
// EXAMPLE VIII
// https://windmill.thefifthmatt.com/cmkhg78
v = vector<vector<Object*>>(11, vector<Object*>(11));
for (int i = 0; i < 11; i++) {
for (int j = 0; j < 11; j++) v[i][j] = new Object();
}
v[10][0] = new Endpoint(true);
v[0][10] = new Endpoint(false);
v[1][1] = new Triangle(1);
v[3][1] = new Triangle(1);
v[5][1] = new Triangle(2);
v[7][1] = new Triangle(2);
v[9][1] = new Triangle(2);
v[1][3] = new Triangle(3);
v[3][3] = new Triangle(2);
v[5][3] = new Triangle(2);
v[7][3] = new Triangle(2);
v[9][3] = new Triangle(3);
v[1][5] = new Triangle(1);
v[3][5] = new Triangle(1);
v[5][5] = new Triangle(2);
v[7][5] = new Triangle(2);
v[9][5] = new Triangle(2);
v[1][7] = new Triangle(1);
v[3][7] = new Triangle(1);
v[5][7] = new Triangle(3);
v[7][7] = new Triangle(2);
v[9][7] = new Triangle(2);
v[1][9] = new Triangle(3);
v[3][9] = new Triangle(2);
v[5][9] = new Triangle(2);
v[7][9] = new Triangle(2);
v[9][9] = new Triangle(3);
cout << "VECTOR SET\n";
Grid grid8 = Grid(v);
grid8.defaultGrid();
cout << "GRID CREATED\n";
sx.set(grid8);
sx.solve();
sx.disp();
// EXAMPLE VI
// https://windmill.thefifthmatt.com/build/CAkSAigIEggIBBoECAIQABICKBUSDAgJIggIAhIEAQEBABICKAMSDAgJIggIAhIEAQEAARICKAYSAggFEgIoDxICCAUSAigOEgIIAxICKAg=_0
*/
/*
v = vector<vector<Object*>>(9, vector<Object*>(9));
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
v[i][j] = new Object();
if (i % 2 == 0 || j % 2 == 0) v[i][j]->isPath = true;
}
}
v[8][0] = new Endpoint(true);
v[0][8] = new Endpoint(false);
v[6][3]->isPath = false;
v[4][5]->isPath = false;
v[3][3] = new BlockGroup(1, 0, vector<pii>({{0, 0}, {0, 1}, {1, 1}}));
v[3][7] = new BlockGroup(1, 0, vector<pii>({{0, 0}, {0, 1}, {-1, 1}}));
Grid grid6 = Grid(v);
sx.set(grid6);
sx.solve();
sx.disp();
*/
for (int i = 0; i < 16; i++) {
auto start = std::chrono::high_resolution_clock::now();
// sx.set(random.randBlocks(4, 0));
Grid grid = random.randBlobs(9, 3, 0);
sx.set(grid);
// sx.set(random.randTriangles(6 + random.randint(4), 0));
sx.solve();
if (sx.solution.size() == 0) cout << "ERROR!!!!!!!!!!!\n";
else sx.disp();
auto finish = std::chrono::high_resolution_clock::now();
auto lol = std::chrono::duration_cast<std::chrono::nanoseconds>(finish-start).count();
std::cout << lol / 1000000.0 << "ms\n";
}
std::cout << "!!!!\n";
// TODO - sx attempts to delete the grid stored internally (which deletes the objects inside problem is they have already been deleted).
// For now these 2 lines will mitigate this issue (since now there is a grid to destroy).
return 0;
}