Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/BALANC3R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import logging
from ev3dev.GyroBalancer import GyroBalancer
Expand Down
80 changes: 40 additions & 40 deletions demo/MINDCUB3R/kociemba/pykociemba/coordcube.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os.path
import cPickle

from cubiecube import CubieCube, moveCube, getURtoDF
from .cubiecube import CubieCube, moveCube, getURtoDF

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -115,12 +115,12 @@ def move(self, m):
# twist = 0 in phase 2.
twistMove = load_cachetable('twistMove')
if not twistMove:
twistMove = [[0] * N_MOVE for i in xrange(N_TWIST)] # new short[N_TWIST][N_MOVE]
twistMove = [[0] * N_MOVE for i in range(N_TWIST)] # new short[N_TWIST][N_MOVE]
a = CubieCube()
for i in xrange(N_TWIST):
for i in range(N_TWIST):
a.setTwist(i)
for j in xrange(6):
for k in xrange(3):
for j in range(6):
for k in range(3):
a.cornerMultiply(moveCube[j])
twistMove[i][3 * j + k] = a.getTwist()
a.cornerMultiply(moveCube[j]) # 4. faceturn restores
Expand All @@ -135,12 +135,12 @@ def move(self, m):

flipMove = load_cachetable('flipMove')
if not flipMove:
flipMove = [[0] * N_MOVE for i in xrange(N_FLIP)] # new short[N_FLIP][N_MOVE]
flipMove = [[0] * N_MOVE for i in range(N_FLIP)] # new short[N_FLIP][N_MOVE]
a = CubieCube()
for i in xrange(N_FLIP):
for i in range(N_FLIP):
a.setFlip(i)
for j in xrange(6):
for k in xrange(3):
for j in range(6):
for k in range(3):
a.edgeMultiply(moveCube[j])
flipMove[i][3 * j + k] = a.getFlip()
a.edgeMultiply(moveCube[j])
Expand All @@ -165,12 +165,12 @@ def move(self, m):

FRtoBR_Move = load_cachetable('FRtoBR_Move')
if not FRtoBR_Move:
FRtoBR_Move = [[0] * N_MOVE for i in xrange(N_FRtoBR)] # new short[N_FRtoBR][N_MOVE]
FRtoBR_Move = [[0] * N_MOVE for i in range(N_FRtoBR)] # new short[N_FRtoBR][N_MOVE]
a = CubieCube()
for i in xrange(N_FRtoBR):
for i in range(N_FRtoBR):
a.setFRtoBR(i)
for j in xrange(6):
for k in xrange(3):
for j in range(6):
for k in range(3):
a.edgeMultiply(moveCube[j])
FRtoBR_Move[i][3 * j + k] = a.getFRtoBR()
a.edgeMultiply(moveCube[j])
Expand All @@ -186,12 +186,12 @@ def move(self, m):
log.info('Preparing move table for permutation of six corners. The positions of the DBL and DRB corners are determined by the parity.')
URFtoDLF_Move = load_cachetable('URFtoDLF_Move')
if not URFtoDLF_Move:
URFtoDLF_Move = [[0] * N_MOVE for i in xrange(N_URFtoDLF)] # new short[N_URFtoDLF][N_MOVE]
URFtoDLF_Move = [[0] * N_MOVE for i in range(N_URFtoDLF)] # new short[N_URFtoDLF][N_MOVE]
a = CubieCube()
for i in xrange(N_URFtoDLF):
for i in range(N_URFtoDLF):
a.setURFtoDLF(i)
for j in xrange(6):
for k in xrange(3):
for j in range(6):
for k in range(3):
a.cornerMultiply(moveCube[j])
URFtoDLF_Move[i][3 * j + k] = a.getURFtoDLF()
a.cornerMultiply(moveCube[j])
Expand All @@ -206,12 +206,12 @@ def move(self, m):
log.info('Preparing move table for the permutation of six U-face and D-face edges in phase2. The positions of the DL and DB edges are')
URtoDF_Move = load_cachetable('URtoDF_Move')
if not URtoDF_Move:
URtoDF_Move = [[0] * N_MOVE for i in xrange(N_URtoDF)] # new short[N_URtoDF][N_MOVE]
URtoDF_Move = [[0] * N_MOVE for i in range(N_URtoDF)] # new short[N_URtoDF][N_MOVE]
a = CubieCube()
for i in xrange(N_URtoDF):
for i in range(N_URtoDF):
a.setURtoDF(i)
for j in xrange(6):
for k in xrange(3):
for j in range(6):
for k in range(3):
a.edgeMultiply(moveCube[j])
URtoDF_Move[i][3 * j + k] = a.getURtoDF()
# Table values are only valid for phase 2 moves!
Expand All @@ -225,12 +225,12 @@ def move(self, m):
log.info('Preparing move table for the three edges UR,UF and UL in phase1.')
URtoUL_Move = load_cachetable('URtoUL_Move')
if not URtoUL_Move:
URtoUL_Move = [[0] * N_MOVE for i in xrange(N_URtoUL)] # new short[N_URtoUL][N_MOVE]
URtoUL_Move = [[0] * N_MOVE for i in range(N_URtoUL)] # new short[N_URtoUL][N_MOVE]
a = CubieCube()
for i in xrange(N_URtoUL):
for i in range(N_URtoUL):
a.setURtoUL(i)
for j in xrange(6):
for k in xrange(3):
for j in range(6):
for k in range(3):
a.edgeMultiply(moveCube[j])
URtoUL_Move[i][3 * j + k] = a.getURtoUL()
a.edgeMultiply(moveCube[j])
Expand All @@ -241,12 +241,12 @@ def move(self, m):
log.info('Preparing move table for the three edges UB,DR and DF in phase1.')
UBtoDF_Move = load_cachetable('UBtoDF_Move')
if not UBtoDF_Move:
UBtoDF_Move = [[0] * N_MOVE for i in xrange(N_UBtoDF)] # new short[N_UBtoDF][N_MOVE]
UBtoDF_Move = [[0] * N_MOVE for i in range(N_UBtoDF)] # new short[N_UBtoDF][N_MOVE]
a = CubieCube()
for i in xrange(N_UBtoDF):
for i in range(N_UBtoDF):
a.setUBtoDF(i)
for j in xrange(6):
for k in xrange(3):
for j in range(6):
for k in range(3):
a.edgeMultiply(moveCube[j])
UBtoDF_Move[i][3 * j + k] = a.getUBtoDF()
a.edgeMultiply(moveCube[j])
Expand All @@ -257,11 +257,11 @@ def move(self, m):
log.info('Preparing table to merge the coordinates of the UR,UF,UL and UB,DR,DF edges at the beginning of phase2')
MergeURtoULandUBtoDF = load_cachetable('MergeURtoULandUBtoDF')
if not MergeURtoULandUBtoDF:
MergeURtoULandUBtoDF = [[0] * 336 for i in xrange(336)] # new short[336][336]
MergeURtoULandUBtoDF = [[0] * 336 for i in range(336)] # new short[336][336]
# for i, j <336 the six edges UR,UF,UL,UB,DR,DF are not in the
# UD-slice and the index is <20160
for uRtoUL in xrange(336):
for uBtoDF in xrange(336):
for uRtoUL in range(336):
for uBtoDF in range(336):
MergeURtoULandUBtoDF[uRtoUL][uBtoDF] = getURtoDF(uRtoUL, uBtoDF)
dump_cachetable(MergeURtoULandUBtoDF, 'MergeURtoULandUBtoDF')

Expand All @@ -278,12 +278,12 @@ def move(self, m):
setPruning(Slice_URFtoDLF_Parity_Prun, 0, 0)
done = 1
while (done != N_SLICE2 * N_URFtoDLF * N_PARITY):
for i in xrange(N_SLICE2 * N_URFtoDLF * N_PARITY):
for i in range(N_SLICE2 * N_URFtoDLF * N_PARITY):
parity = i % 2
URFtoDLF = (i / 2) / N_SLICE2
_slice = (i / 2) % N_SLICE2
if getPruning(Slice_URFtoDLF_Parity_Prun, i) == depth:
for j in xrange(18):
for j in range(18):
if j in (3, 5, 6, 8, 12, 14, 15, 17):
continue
else:
Expand Down Expand Up @@ -313,12 +313,12 @@ def move(self, m):
setPruning(Slice_URtoDF_Parity_Prun, 0, 0)
done = 1
while (done != N_SLICE2 * N_URtoDF * N_PARITY):
for i in xrange(N_SLICE2 * N_URtoDF * N_PARITY):
for i in range(N_SLICE2 * N_URtoDF * N_PARITY):
parity = i % 2
URtoDF = (i / 2) / N_SLICE2
_slice = (i / 2) % N_SLICE2
if (getPruning(Slice_URtoDF_Parity_Prun, i) == depth):
for j in xrange(18):
for j in range(18):
if j in (3, 5, 6, 8, 12, 14, 15, 17):
continue
else:
Expand Down Expand Up @@ -347,11 +347,11 @@ def move(self, m):
setPruning(Slice_Twist_Prun, 0, 0)
done = 1
while (done != N_SLICE1 * N_TWIST):
for i in xrange(N_SLICE1 * N_TWIST):
for i in range(N_SLICE1 * N_TWIST):
twist = i / N_SLICE1
_slice = i % N_SLICE1
if (getPruning(Slice_Twist_Prun, i) == depth):
for j in xrange(18):
for j in range(18):
newSlice = FRtoBR_Move[_slice * 24][j] / 24
newTwist = twistMove[twist][j]
if (getPruning(Slice_Twist_Prun, N_SLICE1 * newTwist + newSlice) == 0x0f):
Expand All @@ -373,11 +373,11 @@ def move(self, m):
setPruning(Slice_Flip_Prun, 0, 0)
done = 1
while (done != N_SLICE1 * N_FLIP):
for i in xrange(N_SLICE1 * N_FLIP):
for i in range(N_SLICE1 * N_FLIP):
flip = i / N_SLICE1
_slice = i % N_SLICE1
if (getPruning(Slice_Flip_Prun, i) == depth):
for j in xrange(18):
for j in range(18):
newSlice = FRtoBR_Move[_slice * 24][j] / 24
newFlip = flipMove[flip][j]
if (getPruning(Slice_Flip_Prun, N_SLICE1 * newFlip + newSlice) == 0x0f):
Expand Down
Loading