Skip to content

Commit

Permalink
import errors
Browse files Browse the repository at this point in the history
  • Loading branch information
muodov committed Dec 23, 2015
1 parent d2097c2 commit 8105988
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions kociemba/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def _solve(s):
"project page for a native implementation: "
"https://github.com/muodov/kociemba",
SlowContextWarning)
import pykociemba.search
_solve = lambda s: pykociemba.search.Search().solution(s, 24, 1000, False).strip()
from .pykociemba import search
_solve = lambda s: search.Search().solution(s, 24, 1000, False).strip()


def solve(cubestring):
Expand Down
14 changes: 11 additions & 3 deletions kociemba/pykociemba/coordcube.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import logging
import os.path
import cPickle

try:
import cPickle
except ImportError:
import pickle as cPickle

from .cubiecube import CubieCube, moveCube, getURtoDF

log = logging.getLogger(__name__)

cache_dir = os.path.join(os.path.dirname(__file__), 'prunetables')


def setPruning(table, index, value):
"""Set pruning value in table. Two values are stored in one byte."""
if ((index & 1) == 0):
Expand All @@ -16,6 +21,7 @@ def setPruning(table, index, value):
table[index / 2] &= 0x0f | (value << 4)
# table[index] = value & 0xf


def getPruning(table, index):
"""Extract pruning value"""

Expand All @@ -26,6 +32,7 @@ def getPruning(table, index):
return res
# return table[index] & 0xf


def load_cachetable(name):
obj = None
try:
Expand All @@ -35,6 +42,7 @@ def load_cachetable(name):
log.warning('could not read cache for %s: %s. Recalculating it...', name, e)
return obj


def dump_cachetable(obj, name):
with open(os.path.join(cache_dir, name + '.pkl'), 'w') as f:
cPickle.dump(obj, f)
Expand Down Expand Up @@ -147,8 +155,8 @@ def move(self, m):
# Parity of the corner permutation. This is the same as the parity for the edge permutation of a valid cube.
# parity has values 0 and 1
parityMove = [
[ 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1 ],
[ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ],
[1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1],
[0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0],
]

# ***********************************Phase 1 and 2 movetable********************************************************
Expand Down

0 comments on commit 8105988

Please sign in to comment.