aboutsummaryrefslogtreecommitdiff
path: root/python/example.py
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-10-19 19:17:13 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-10-19 19:17:13 +0200
commita3a477870cdbdb4b9c4c8b403c09b13502291234 (patch)
treedb26bc921e48ea8c919f19aa05395f100b854fec /python/example.py
parentb80b1b78901154240bc5d2ab6f5ea4465bf7fa67 (diff)
downloadnissy-core-a3a477870cdbdb4b9c4c8b403c09b13502291234.tar.gz
nissy-core-a3a477870cdbdb4b9c4c8b403c09b13502291234.zip
Finished Python module
Diffstat (limited to '')
-rw-r--r--python/example.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/python/example.py b/python/example.py
new file mode 100644
index 0000000..fdea2d4
--- /dev/null
+++ b/python/example.py
@@ -0,0 +1,37 @@
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
7from sys import path
8path.append("./")
9
10# Import with a nicer name
11import nissy_python_module as nissy
12
13# Choose the solver you prefer
14solver = "h48h0k4"
15
16# Load the pruning table from file
17data = 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
23cube = nissy.applymoves(nissy.solved_cube, "U F R2");
24
25# Solve!
26solutions = nissy.solve(cube, solver, nissy.nissflag_normal, 0, 9, 3, -1, data)
27
28# Print the solutions, one per line
29print("Found ", len(solutions), " solutions:")
30for 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)

Generated with cgit - Back to sebastiano.tronto.net