aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/example.py2
-rw-r--r--python/nissy_module.c12
2 files changed, 8 insertions, 6 deletions
diff --git a/python/example.py b/python/example.py
index fdea2d4..b939183 100644
--- a/python/example.py
+++ b/python/example.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, data) 26solutions = nissy.solve(cube, solver, nissy.nissflag_normal, 0, 9, 3, -1, 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 2357b90..947d06f 100644
--- a/python/nissy_module.c
+++ b/python/nissy_module.c
@@ -306,7 +306,8 @@ checkdata(PyObject *self, PyObject *args)
306} 306}
307 307
308PyDoc_STRVAR(solve_doc, 308PyDoc_STRVAR(solve_doc,
309"solve(cube, solver, nissflag, minmoves, maxmoves, maxsolutions, optimal, data)\n" 309"solve(cube, solver, nissflag, minmoves, maxmoves, maxsolutions,"
310" optimal, threads, data)\n"
310"--\n\n" 311"--\n\n"
311"Solves the given 'cube' with the given 'solver' and other parameters." 312"Solves the given 'cube' with the given 'solver' and other parameters."
312"See the documentation for libnissy (in nissy.h) for details.\n" 313"See the documentation for libnissy (in nissy.h) for details.\n"
@@ -319,6 +320,7 @@ PyDoc_STRVAR(solve_doc,
319" - maxsolution: the maximum number of solutions to return\n" 320" - maxsolution: the maximum number of solutions to return\n"
320" - optimal: the largest number of moves from the shortest solution" 321" - optimal: the largest number of moves from the shortest solution"
321"(set to -1 to ignore)\n" 322"(set to -1 to ignore)\n"
323" - threads: the number of threads to use (0 for default)\n"
322" - data: a bytearray containing the data for the solver\n" 324" - data: a bytearray containing the data for the solver\n"
323"\n" 325"\n"
324"Returns: a list with the solutions found\n" 326"Returns: a list with the solutions found\n"
@@ -328,20 +330,20 @@ solve(PyObject *self, PyObject *args)
328{ 330{
329 long long result; 331 long long result;
330 unsigned nissflag, minmoves, maxmoves, maxsolutions; 332 unsigned nissflag, minmoves, maxmoves, maxsolutions;
331 int optimal, i, j, k; 333 int optimal, i, j, k, threads;
332 const char *cube, *solver; 334 const char *cube, *solver;
333 char solutions[MAX_SOLUTIONS_SIZE]; 335 char solutions[MAX_SOLUTIONS_SIZE];
334 long long stats[NISSY_SIZE_SOLVE_STATS]; 336 long long stats[NISSY_SIZE_SOLVE_STATS];
335 PyByteArrayObject *data; 337 PyByteArrayObject *data;
336 PyObject *list, *item; 338 PyObject *list, *item;
337 339
338 if (!PyArg_ParseTuple(args, "ssIIIIiY", &cube, &solver, &nissflag, 340 if (!PyArg_ParseTuple(args, "ssIIIIiiY", &cube, &solver, &nissflag,
339 &minmoves, &maxmoves, &maxsolutions, &optimal, &data)) 341 &minmoves, &maxmoves, &maxsolutions, &optimal, &threads, &data))
340 return NULL; 342 return NULL;
341 343
342 Py_BEGIN_ALLOW_THREADS 344 Py_BEGIN_ALLOW_THREADS
343 result = nissy_solve(cube, solver, nissflag, minmoves, maxmoves, 345 result = nissy_solve(cube, solver, nissflag, minmoves, maxmoves,
344 maxsolutions, optimal, data->ob_alloc, data->ob_bytes, 346 maxsolutions, optimal, threads, data->ob_alloc, data->ob_bytes,
345 MAX_SOLUTIONS_SIZE, solutions, stats); 347 MAX_SOLUTIONS_SIZE, solutions, stats);
346 Py_END_ALLOW_THREADS 348 Py_END_ALLOW_THREADS
347 349

Generated with cgit - Back to sebastiano.tronto.net