solve.py (1174B)
1 # Small example of nissy Python module usage 2 3 # Run "./build.sh python", then run this from either the top-level directory 4 # of the nissy-core repo or from the python subdirectory. 5 6 # Append the directories to the python path so we can load the module 7 import sys, os 8 sys.path.append(os.getcwd()) 9 sys.path.append(os.getcwd() + os.path.sep + "python") 10 11 # Import with a nicer name 12 import nissy 13 14 # Choose the solver you prefer 15 solver = "h48h0k4" 16 17 # Load the pruning table from file, generate it if needed 18 datapath = "tables" + os.path.sep + solver 19 if os.path.exists(datapath): 20 data = bytearray(open(datapath, "rb").read()) 21 else: 22 data = nissy.gendata("h48h0k4") 23 print("Generated data will NOT be persisted") 24 25 # Get a scrambled cube 26 cube = nissy.applymoves(nissy.solved_cube, "U F R2"); 27 28 # Solve! 29 solutions = nissy.solve(cube, solver, nissy.nissflag_normal, 0, 9, 3, 20, 4, data) 30 31 # Print the solutions, one per line 32 print("Found ", len(solutions), " solutions:") 33 for s in solutions: 34 print(s) 35 36 # You can use help(nissy) for more info about the available methods: 37 # help(nissy) 38 39 # Or help(nissy.methodname) if you want to know more about a specific method: 40 # help(nissy.solve)