-
Notifications
You must be signed in to change notification settings - Fork 22
/
coord.py
31 lines (22 loc) · 1.07 KB
/
coord.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
# ####### The cube on the coordinate level is described by a 3-tuple of natural numbers in phase 1 and phase 2. ########
import moves as mv
from defs import N_MOVE
SOLVED = 0 # 0 is index of solved state (except for u_edges coordinate)
class CoordCube:
"""Represents a 2x2x2 cube on the coordinate level.
A state is uniquely determined by the coordinates corntwist and cornperm.
"""
def __init__(self, cc=None):
if cc is None:
self.corntwist = SOLVED # twist of corners
self.cornperm = SOLVED # permutation of corners
else:
self.corntwist = cc.get_corntwist()
self.cornperm = cc.get_cornperm()
def __str__(self):
s = '(corntwist: ' + str(self.corntwist) + ', cornperm: ' + str(self.cornperm) + ')'
return s
def move(self, m):
self.corntwist = mv.twist_move[N_MOVE * self.corntwist + m]
self.cornperm = mv.corners_move[N_MOVE * self.cornperm + m]
########################################################################################################################