From 3ab1012ea8c55f82812b5998fd6b4fdf53dea70e Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 14 Apr 2025 14:00:44 +0200 Subject: Improved C++ API and added info to README --- python/examples/solve.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 python/examples/solve.py (limited to 'python/examples') diff --git a/python/examples/solve.py b/python/examples/solve.py new file mode 100644 index 0000000..b939183 --- /dev/null +++ b/python/examples/solve.py @@ -0,0 +1,37 @@ +# Small example of nissy_python_module usage + +# Compile the python module with "make python", then run this from the main +# folder containing nissy_python_module.so + +# Append the main folder to the python path so we can load the module +from sys import path +path.append("./") + +# Import with a nicer name +import nissy_python_module as nissy + +# Choose the solver you prefer +solver = "h48h0k4" + +# Load the pruning table from file +data = bytearray(open("tables/" + solver, "rb").read()) + +# If you have not generated the table yet, you can do so: +# data = nissy.gendata("h48h0k4") + +# Get a scrambled cube +cube = nissy.applymoves(nissy.solved_cube, "U F R2"); + +# Solve! +solutions = nissy.solve(cube, solver, nissy.nissflag_normal, 0, 9, 3, -1, 4, data) + +# Print the solutions, one per line +print("Found ", len(solutions), " solutions:") +for s in solutions: + print(s) + +# You can use help(nissy) for more info about the available methods: +# help(nissy) + +# Or help(nissy.methodname) if you want to know more about a specific method: +# help(nissy.solve) -- cgit v1.3