example.py (1040B)
1 # Small example of nissy_python_module usage 2 3 # Compile the python module with "make python", then run this from the main 4 # folder containing nissy_python_module.so 5 6 # Append the main folder to the python path so we can load the module 7 from sys import path 8 path.append("./") 9 10 # Import with a nicer name 11 import nissy_python_module as nissy 12 13 # Choose the solver you prefer 14 solver = "h48h0k4" 15 16 # Load the pruning table from file 17 data = bytearray(open("tables/" + solver, "rb").read()) 18 19 # If you have not generated the table yet, you can do so: 20 # data = nissy.gendata("h48h0k4") 21 22 # Get a scrambled cube 23 cube = nissy.applymoves(nissy.solved_cube, "U F R2"); 24 25 # Solve! 26 solutions = nissy.solve(cube, solver, nissy.nissflag_normal, 0, 9, 3, -1, data) 27 28 # Print the solutions, one per line 29 print("Found ", len(solutions), " solutions:") 30 for s in solutions: 31 print(s) 32 33 # You can use help(nissy) for more info about the available methods: 34 # help(nissy) 35 36 # Or help(nissy.methodname) if you want to know more about a specific method: 37 # help(nissy.solve)