Skip to content

Commit 4559e5d

Browse files
authored
Hotfix/initial run (#1)
* Add requirements into setup.py to avoid reading requirements.txt file * Fix setup.py requirements * Update CHANGESET * Add tests for CoordCube module * Remove unneeded dependencie * Add MANIFEST.in with requirements and CoordCube csv's * Bump version in setup.py * Add pip install -r requirements.txt to travix config * Fix instalation issue, improve CoorCube tests
1 parent 41ed127 commit 4559e5d

File tree

7 files changed

+145
-81
lines changed

7 files changed

+145
-81
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ python:
77
- '3.6'
88
install:
99
- pip install -e .
10+
- pip install -r requirements.txt
1011
- pip install nose coverage coveralls
1112
script: travis_wait 30 python setup.py nosetests --with-coverage --cover-package rubik_solver
1213
after_success: coveralls

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include requirements.txt rubik_solver/CoordCube/*.csv

rubik_solver/CoordCube/__init__.py

+24-24
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ class CoordCube(object):
1414
N_URtoUL = 1320 # 12!/(12-3)! permutation of UR,UF,UL edges
1515
N_UBtoDF = 1320 # 12!/(12-3)! permutation of UB,DR,DF edges
1616
N_URtoDF = 20160 # 8!/(8-6)! permutation of UR,UF,UL,UB,DR,DF edges in phase2
17-
17+
1818
N_URFtoDLB = 40320 # 8! permutations of the corners
1919
N_URtoBR = 479001600 # 8! permutations of the corners
20-
20+
2121
N_MOVE = 18
2222

2323
# twistMove = [[0 for _ in range(N_MOVE)] for _ in range( N_TWIST )] ## CUIDADO CON LAS REFERENCIAS
@@ -29,32 +29,32 @@ class CoordCube(object):
2929
# UBtoDF_Move = [[0 for _ in range(N_MOVE)] for _ in range( N_UBtoDF )]
3030
# MergeURtoULandUBtoDF = [[0 for _ in range(336)] for _ in range( 336 )]
3131

32-
Slice_URFtoDLF_Parity_Prun = [-1] * (N_SLICE2 * N_URFtoDLF * N_PARITY // 2)
33-
Slice_URtoDF_Parity_Prun = [-1] * (N_SLICE2 * N_URtoDF * N_PARITY // 2)
34-
Slice_Twist_Prun = [-1] * (N_SLICE1 * N_TWIST // 2 + 1)
35-
Slice_Flip_Prun = [-1] * (N_SLICE1 * N_FLIP // 2)
36-
32+
# Slice_URFtoDLF_Parity_Prun = [-1] * (N_SLICE2 * N_URFtoDLF * N_PARITY // 2)
33+
# Slice_URtoDF_Parity_Prun = [-1] * (N_SLICE2 * N_URtoDF * N_PARITY // 2)
34+
# Slice_Twist_Prun = [-1] * (N_SLICE1 * N_TWIST // 2 + 1)
35+
# Slice_Flip_Prun = [-1] * (N_SLICE1 * N_FLIP // 2)
36+
3737
## Parity of the corner permutation. This is the same as the parity for the edge permutation of a valid cube.
3838
## parity has values 0 and 1
3939
parityMove = [
4040
[1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1],
4141
[0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]
4242
]
43-
43+
4444
@staticmethod
4545
def setPruning(table, index, value):
4646
if (index & 1) == 0:
4747
table[index // 2] &= (0xf0 | value)
4848
else:
4949
table[index // 2] &= (0x0f | (value << 4))
50-
50+
5151
@staticmethod
5252
def getPruning(table, index):
5353
if (index & 1) == 0:
5454
return table[index // 2] & 0x0f
5555
else:
5656
return (table[index // 2] & 0xf0) >> 4
57-
57+
5858
def __init__(self, c):
5959
''' c is a CubieCube instance'''
6060
if not isinstance(c, CubieCube):
@@ -67,7 +67,7 @@ def __init__(self, c):
6767
self.URtoUL = c.getURtoUL()
6868
self.UBtoDF = c.getUBtoDF()
6969
self.URtoDF = c.getURtoDF() # only needed in phase2
70-
70+
7171
def move(self, m):
7272
'''A move on the coordinate level'''
7373
self.twist = self.twistMove[self.twist][m]
@@ -80,7 +80,7 @@ def move(self, m):
8080
if self.URtoUL < 336 and self.UBtoDF < 336: # updated only if UR,UF,UL,UB,DR,DF
8181
# are not in UD-slice
8282
self.URtoDF = self.MergeURtoULandUBtoDF[self.URtoUL][self.UBtoDF]
83-
83+
8484
## Init more static values of class CubieCube
8585
def read_or_func_list(file_name, func):
8686
abspath = os.path.join(os.path.dirname(os.path.abspath(__file__)), file_name)
@@ -101,7 +101,7 @@ def read_or_func_matrix(file_name, func):
101101
return ret
102102

103103
def build_twist_move():
104-
twist_move = CoordCube.twistMove
104+
twist_move = [[0 for _ in range(CoordCube.N_MOVE)] for _ in range( CoordCube.N_TWIST )]
105105
a = CubieCube()
106106
for i in range(CoordCube.N_TWIST):
107107
a.setTwist(i)
@@ -113,7 +113,7 @@ def build_twist_move():
113113
return twist_move
114114

115115
def build_flip_move():
116-
flip_move = CoordCube.flipMove
116+
flip_move = [[0 for _ in range(CoordCube.N_MOVE)] for _ in range( CoordCube.N_FLIP )]
117117
a = CubieCube()
118118
for i in range(CoordCube.N_FLIP):
119119
a.setFlip(i)
@@ -125,7 +125,7 @@ def build_flip_move():
125125
return flip_move
126126

127127
def build_urf_to_dlf():
128-
urf_to_dlf = CoordCube.URFtoDLF_Move
128+
urf_to_dlf = [[0 for _ in range(CoordCube.N_MOVE)] for _ in range( CoordCube.N_URFtoDLF )]
129129
a = CubieCube()
130130
for i in range(CoordCube.N_URFtoDLF):
131131
a.setURFtoDLF(i)
@@ -137,7 +137,7 @@ def build_urf_to_dlf():
137137
return urf_to_dlf
138138

139139
def build_fr_to_br():
140-
fr_to_br = CoordCube.FRtoBR_Move
140+
fr_to_br = [[0 for _ in range(CoordCube.N_MOVE)] for _ in range( CoordCube.N_FRtoBR )]
141141
a = CubieCube()
142142
for i in range(CoordCube.N_FRtoBR):
143143
a.setFRtoBR(i)
@@ -149,7 +149,7 @@ def build_fr_to_br():
149149
return fr_to_br
150150

151151
def build_ur_to_df():
152-
ur_to_df = CoordCube.URtoDF_Move
152+
ur_to_df = [[0 for _ in range(CoordCube.N_MOVE)] for _ in range( CoordCube.N_URtoDF )]
153153
a = CubieCube()
154154
for i in range(CoordCube.N_URtoDF):
155155
a.setURtoDF(i)
@@ -161,7 +161,7 @@ def build_ur_to_df():
161161
return ur_to_df
162162

163163
def build_ur_to_ul():
164-
ur_to_ul = CoordCube.URtoUL_Move
164+
ur_to_ul = [[0 for _ in range(CoordCube.N_MOVE)] for _ in range( CoordCube.N_URtoUL )]
165165
a = CubieCube()
166166
for i in range(CoordCube.N_URtoUL):
167167
a.setURtoUL(i)
@@ -173,7 +173,7 @@ def build_ur_to_ul():
173173
return ur_to_ul
174174

175175
def build_ub_to_df():
176-
ub_to_df = CoordCube.UBtoDF_Move
176+
ub_to_df = [[0 for _ in range(CoordCube.N_MOVE)] for _ in range( CoordCube.N_UBtoDF )]
177177
a = CubieCube()
178178
for i in range(CoordCube.N_URtoUL):
179179
a.setUBtoDF(i)
@@ -185,14 +185,14 @@ def build_ub_to_df():
185185
return ub_to_df
186186

187187
def build_merge_ur_to_ul_and_ub_to_df():
188-
merge_ur_to_ul_and_ub_to_df = CoordCube.MergeURtoULandUBtoDF
188+
merge_ur_to_ul_and_ub_to_df = [[0 for _ in range(336)] for _ in range( 336 )]
189189
for uRtoUL in range(336):
190190
for uBtoDF in range(336):
191191
merge_ur_to_ul_and_ub_to_df[uRtoUL][uBtoDF] = CubieCube.getURtoDFs(uRtoUL, uBtoDF)
192192
return merge_ur_to_ul_and_ub_to_df
193193

194194
def build_slice_urf_to_dlf_parity_prun():
195-
slice_urf_to_dlf_parity_prun = CoordCube.Slice_URFtoDLF_Parity_Prun
195+
slice_urf_to_dlf_parity_prun = [-1] * (CoordCube.N_SLICE2 * CoordCube.N_URFtoDLF * CoordCube.N_PARITY // 2)
196196
CoordCube.setPruning(slice_urf_to_dlf_parity_prun, 0, 0)
197197
done, depth = 1, 0
198198
while done < CoordCube.N_SLICE2 * CoordCube.N_URFtoDLF * CoordCube.N_PARITY:
@@ -213,7 +213,7 @@ def build_slice_urf_to_dlf_parity_prun():
213213
return slice_urf_to_dlf_parity_prun
214214

215215
def build_slice_ur_to_df_parity_prun():
216-
slice_ur_to_df_parity_prun = CoordCube.Slice_URtoDF_Parity_Prun
216+
slice_ur_to_df_parity_prun = [-1] * (CoordCube.N_SLICE2 * CoordCube.N_URtoDF * CoordCube.N_PARITY // 2)
217217
CoordCube.setPruning(slice_ur_to_df_parity_prun, 0, 0)
218218
done, depth = 1, 0
219219
while done != (CoordCube.N_SLICE2 * CoordCube.N_URtoDF * CoordCube.N_PARITY):
@@ -233,7 +233,7 @@ def build_slice_ur_to_df_parity_prun():
233233
return slice_ur_to_df_parity_prun
234234

235235
def build_slice_twist_prun():
236-
slice_twist_prun = CoordCube.Slice_Twist_Prun
236+
slice_twist_prun = [-1] * (CoordCube.N_SLICE1 * CoordCube.N_TWIST // 2 + 1)
237237
CoordCube.setPruning(slice_twist_prun, 0, 0)
238238
done, depth = 1, 0
239239
while done < (CoordCube.N_SLICE1 * CoordCube.N_TWIST):
@@ -251,7 +251,7 @@ def build_slice_twist_prun():
251251
return slice_twist_prun
252252

253253
def build_slice_flip_prun():
254-
slice_flip_prun = CoordCube.Slice_Flip_Prun
254+
slice_flip_prun = [-1] * (CoordCube.N_SLICE1 * CoordCube.N_FLIP // 2)
255255
CoordCube.setPruning(slice_flip_prun, 0, 0)
256256
done, depth = 1, 0
257257
while done < (CoordCube.N_SLICE1 * CoordCube.N_FLIP):

0 commit comments

Comments
 (0)