-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
95 lines (76 loc) · 1.7 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
#include "cube.h"
#include "solver.h"
CubeState cube;
void process(int opcode) {
if (opcode < 0) {
for (int i = 0; i < 3; i++) process(abs(opcode));
return;
}
if (opcode >= 10) {
for (int i = 0; i < 2; i++) process(opcode - 10);
return;
}
if (opcode == 1) cube.F_(); // somehow a built in method is also called F so we rename all instances in this one.
if (opcode == 2) cube.R_();
if (opcode == 3) cube.U_();
if (opcode == 4) cube.B_();
if (opcode == 5) cube.L_();
if (opcode == 6) cube.D_();
if (opcode == 7) cube.X_();
if (opcode == 8) cube.Y_();
if (opcode == 9) cube.Z_();
}
int main()
{
/*
CubeState state;
state.F();
state.F();
state.B();
state.B();
state.disp();
state.L();
state.L();
state.R();
state.R();
state.disp();
state.U();
state.U();
state.D();
state.D();
state.disp();
std::cout << state.isSolved() << "\n";
for (int i = 0; i < 3; i++) {
state.R();
state.L();
state.L();
state.L();
state.U();
state.D();
state.D();
state.D();
}
state.X();
state.disp();
state.Y();
state.disp();
state.Z();
state.disp();
std::cout << state.isSolved() << "\n";
*/
srand(time(0));
cube.scramble();
cube.disp();
Solver solver;
solver.solve(CubeState(cube), false);
for (auto i : solver.moves) std::cout << i << " ";
std::cout << "\n" << solver.moves.size() << "\n";
solver.state.disp();
cube.disp();
for (int i = 0; i < solver.moves.size(); i++) {
process(solver.moves[i]);
// cube.disp();
}
cube.disp();
return 0;
}