Beispiel #1
0
def solveCube(s):
    # print cube state
    py222.printCube(s)

    # FC-normalize stickers
    print("normalizing stickers...")
    s = py222.normFC(s)

    # generate pruning tables
    print("generating pruning tables...")
    genOTable(py222.initState(), 0)
    genPTable(py222.initState(), 0)

    # run IDA*
    print("searching...")
    solved = False
    depth = 1
    while depth <= 11 and not solved:
        print("depth {}".format(depth))
        solved = IDAStar(s, depth, [])
        depth += 1
Beispiel #2
0
def generateSamples(k, l):
    N = k * l
    samples = np.empty((N, constants.kNumStickers), dtype=bytes)
    states = np.empty((N, constants.kNumCubes * constants.kNumStickers))
    for i in range(l):
        currentCube = py222.initState()
        for j in range(k):
            scrambledCube = py222.doAlgStr(currentCube, getRandomMove())
            samples[k * i + j] = scrambledCube
            states[k * i + j] = py222.getState(scrambledCube).flatten()
            currentCube = scrambledCube
    return samples, coo_matrix(states)
Beispiel #3
0
import py222
import solver
import numpy as np

# get solved state
s = py222.initState()

# apply some scramble
s = py222.doAlgStr(s, "F2")

# solve cube
solver.solveCube(s)
Beispiel #4
0
# solve a cube state
def solveCube(s):
    # print cube state
    py222.printCube(s)

    # FC-normalize stickers
    print("normalizing stickers...")
    s = py222.normFC(s)

    # generate pruning tables
    print("generating pruning tables...")
    genOTable(py222.initState(), 0)
    genPTable(py222.initState(), 0)

    # run IDA*
    print("searching...")
    solved = False
    depth = 1
    while depth <= 11 and not solved:
        print("depth {}".format(depth))
        solved = IDAStar(s, depth, [])
        depth += 1


if __name__ == "__main__":
    # input some scrambled state
    s = py222.doAlgStr(py222.initState(), "R U2 R2 F2 R' F2 R F R")
    # solve cube
    solveCube(s)
Beispiel #5
0
 def reset(self):
     self.cube = py222.initState()
Beispiel #6
0
 def __init__(self):
     # creates Rubik's cube object
     self.cube = py222.initState()