aboutsummaryrefslogtreecommitdiff
path: root/src/nissy.c
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 /src/nissy.c
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--src/nissy.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/nissy.c b/src/nissy.c
index a7f8432..ba43e5d 100644
--- a/src/nissy.c
+++ b/src/nissy.c
@@ -534,8 +534,8 @@ nissy_solve(
534 unsigned minmoves, 534 unsigned minmoves,
535 unsigned maxmoves, 535 unsigned maxmoves,
536 unsigned maxsols, 536 unsigned maxsols,
537 int optimal, 537 unsigned optimal,
538 int threads, 538 unsigned threads,
539 unsigned long long data_size, 539 unsigned long long data_size,
540 const char data[data_size], 540 const char data[data_size],
541 unsigned sols_size, 541 unsigned sols_size,
@@ -546,7 +546,7 @@ nissy_solve(
546 cube_t c; 546 cube_t c;
547 long long parse_ret; 547 long long parse_ret;
548 uint8_t h, k; 548 uint8_t h, k;
549 int t, opt; 549 int t;
550 550
551 if (solver == NULL) { 551 if (solver == NULL) {
552 LOG("Error: 'solver' argument is NULL\n"); 552 LOG("Error: 'solver' argument is NULL\n");
@@ -573,8 +573,6 @@ nissy_solve(
573 return 0; 573 return 0;
574 } 574 }
575 575
576 opt = optimal < 0 ? MAXLEN : optimal;
577
578 t = threads == 0 ? THREADS : threads; 576 t = threads == 0 ? THREADS : threads;
579 if (t < 0) { 577 if (t < 0) {
580 LOG("solve: 'threads' is negative. Please provide a " 578 LOG("solve: 'threads' is negative. Please provide a "
@@ -597,10 +595,10 @@ nissy_solve(
597 if (parse_ret != NISSY_OK) 595 if (parse_ret != NISSY_OK)
598 return parse_ret; 596 return parse_ret;
599 return solve_h48(c, minmoves, maxmoves, maxsols, 597 return solve_h48(c, minmoves, maxmoves, maxsols,
600 opt, t, data_size, data, sols_size, sols, stats); 598 optimal, t, data_size, data, sols_size, sols, stats);
601 } else if (!strncmp(solver, "coord_", 6)) { 599 } else if (!strncmp(solver, "coord_", 6)) {
602 return solve_coord_dispatch(c, solver + 6, nissflag, 600 return solve_coord_dispatch(c, solver + 6, nissflag,
603 minmoves, maxmoves, maxsols, opt, t, data_size, data, 601 minmoves, maxmoves, maxsols, optimal, t, data_size, data,
604 sols_size, sols); 602 sols_size, sols);
605 } else { 603 } else {
606 LOG("solve: unknown solver '%s'\n", solver); 604 LOG("solve: unknown solver '%s'\n", solver);

Generated with cgit - Back to sebastiano.tronto.net