-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlgorithms.py
95 lines (82 loc) · 3.49 KB
/
Algorithms.py
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
from Cube import CubeColor, Cube
class CubeRotation:
def __init__(self, side, angle=90):
self.side = side
self.angle = angle
def rotateAlgo(algorithm, facing=CubeColor.RED):
algo = []
rotation = [CubeColor.RED, CubeColor.GREEN, CubeColor.ORANGE, CubeColor.BLUE]
offset = rotation.index(facing)
for move in algorithm:
newSide = move.side
if move.side in rotation:
newSide = rotation[(rotation.index(move.side) + offset) % 4]
algo.append(CubeRotation(newSide, move.angle))
return algo
def flipAlgo(algorithm):
algo = []
for move in algorithm:
newSide = move.side
if move.side == CubeColor.BLUE:
newSide = CubeColor.GREEN
elif move.side == CubeColor.GREEN:
newSide = CubeColor.BLUE
algo.append(CubeRotation(newSide, -move.angle))
return algo
# right hand side F2L
F2L = [ CubeRotation(CubeColor.YELLOW, 90),
CubeRotation(CubeColor.GREEN, 90),
CubeRotation(CubeColor.YELLOW, -90),
CubeRotation(CubeColor.GREEN, -90),
CubeRotation(CubeColor.YELLOW, -90),
CubeRotation(CubeColor.RED, -90),
CubeRotation(CubeColor.YELLOW, 90),
CubeRotation(CubeColor.RED, 90)
]
# right hand side edge orienter
OLL_EDGE = [ CubeRotation(CubeColor.RED, -90),
CubeRotation(CubeColor.YELLOW, -90),
CubeRotation(CubeColor.BLUE, -90),
CubeRotation(CubeColor.YELLOW, 90),
CubeRotation(CubeColor.BLUE, 90),
CubeRotation(CubeColor.RED, 90),
]
SUNE = [ CubeRotation(CubeColor.GREEN, 90),
CubeRotation(CubeColor.YELLOW, 90),
CubeRotation(CubeColor.GREEN, -90),
CubeRotation(CubeColor.YELLOW, 90),
CubeRotation(CubeColor.GREEN, 90),
CubeRotation(CubeColor.YELLOW, 180),
CubeRotation(CubeColor.GREEN, -90),
]
PLL_A = [ CubeRotation(CubeColor.BLUE, 90),
CubeRotation(CubeColor.RED, -90),
CubeRotation(CubeColor.BLUE, 90),
CubeRotation(CubeColor.ORANGE, 180),
CubeRotation(CubeColor.BLUE, -90),
CubeRotation(CubeColor.RED, 90),
CubeRotation(CubeColor.BLUE, 90),
CubeRotation(CubeColor.ORANGE, 180),
CubeRotation(CubeColor.BLUE, 180),
]
GHOST = [ CubeRotation(CubeColor.BLUE, 90),
CubeRotation(CubeColor.WHITE, 90),
CubeRotation(CubeColor.BLUE, -90),
CubeRotation(CubeColor.WHITE, -90),
CubeRotation(CubeColor.BLUE, 90),
CubeRotation(CubeColor.WHITE, 90),
CubeRotation(CubeColor.BLUE, -90),
CubeRotation(CubeColor.WHITE, -90),
]
PLL_H = [ CubeRotation(CubeColor.BLUE, 180),
CubeRotation(CubeColor.GREEN, 180),
CubeRotation(CubeColor.WHITE, 90),
CubeRotation(CubeColor.BLUE, 90),
CubeRotation(CubeColor.GREEN, -90),
CubeRotation(CubeColor.ORANGE, 180),
CubeRotation(CubeColor.BLUE, -90),
CubeRotation(CubeColor.GREEN, 90),
CubeRotation(CubeColor.WHITE, 90),
CubeRotation(CubeColor.BLUE, 180),
CubeRotation(CubeColor.GREEN, 180)
]