aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-04-17 10:50:57 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-04-17 14:36:27 +0200
commit0ece4b72db22139db51e8f5f37c25f24c84f3e43 (patch)
treefa9d0f5ec4124b2e51194ec6dc888e037b9da7e2 /python
parent785f2859e336db49095a8443be8d204ba0989925 (diff)
downloadnissy-core-0ece4b72db22139db51e8f5f37c25f24c84f3e43.tar.gz
nissy-core-0ece4b72db22139db51e8f5f37c25f24c84f3e43.zip
Small rework of optimal vs maxsols
I wanted to make the "optimal" and "maxsolutions" options mutually exclusive, but in the end I decided there is value in keeping both (e.g. for specifying a limit to the number of solutions when asking for "all" optimal"). Now optimal cannot be negative anymore, for the same reason of maxsolutions. The interface user (shell, UI) will have to take care of handling this in a way that makes sense for the user. Usually this means setting the maximum number of solutions to UINT_MAX (or a similar very high number) when the user wants "all optimal".
Diffstat (limited to '')
-rw-r--r--python/examples/solve.py2
-rw-r--r--python/nissy_module.c5
2 files changed, 3 insertions, 4 deletions
diff --git a/python/examples/solve.py b/python/examples/solve.py
index b939183..a60c432 100644
--- a/python/examples/solve.py
+++ b/python/examples/solve.py
@@ -23,7 +23,7 @@ data = bytearray(open("tables/" + solver, "rb").read())
23cube = nissy.applymoves(nissy.solved_cube, "U F R2"); 23cube = nissy.applymoves(nissy.solved_cube, "U F R2");
24 24
25# Solve! 25# Solve!
26solutions = nissy.solve(cube, solver, nissy.nissflag_normal, 0, 9, 3, -1, 4, data) 26solutions = nissy.solve(cube, solver, nissy.nissflag_normal, 0, 9, 3, 20, 4, data)
27 27
28# Print the solutions, one per line 28# Print the solutions, one per line
29print("Found ", len(solutions), " solutions:") 29print("Found ", len(solutions), " solutions:")
diff --git a/python/nissy_module.c b/python/nissy_module.c
index e92cfd9..46570dc 100644
--- a/python/nissy_module.c
+++ b/python/nissy_module.c
@@ -324,8 +324,7 @@ PyDoc_STRVAR(solve_doc,
324" - minmoves: the minimum number of moves to use\n" 324" - minmoves: the minimum number of moves to use\n"
325" - maxmoves: the maximum number of moves to use\n" 325" - maxmoves: the maximum number of moves to use\n"
326" - maxsolution: the maximum number of solutions to return\n" 326" - maxsolution: the maximum number of solutions to return\n"
327" - optimal: the largest number of moves from the shortest solution" 327" - optimal: the largest number of moves from the shortest solution\n"
328"(set to -1 to ignore)\n"
329" - threads: the number of threads to use (0 for default)\n" 328" - threads: the number of threads to use (0 for default)\n"
330" - data: a bytearray containing the data for the solver\n" 329" - data: a bytearray containing the data for the solver\n"
331"\n" 330"\n"
@@ -343,7 +342,7 @@ solve(PyObject *self, PyObject *args)
343 PyByteArrayObject *data; 342 PyByteArrayObject *data;
344 PyObject *list, *item; 343 PyObject *list, *item;
345 344
346 if (!PyArg_ParseTuple(args, "ssIIIIiiY", &cube, &solver, &nissflag, 345 if (!PyArg_ParseTuple(args, "ssIIIIIIY", &cube, &solver, &nissflag,
347 &minmoves, &maxmoves, &maxsolutions, &optimal, &threads, &data)) 346 &minmoves, &maxmoves, &maxsolutions, &optimal, &threads, &data))
348 return NULL; 347 return NULL;
349 348

Generated with cgit - Back to sebastiano.tronto.net