aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/solutions.h
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/solvers/solutions.h
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 'src/solvers/solutions.h')
-rw-r--r--src/solvers/solutions.h15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/solvers/solutions.h b/src/solvers/solutions.h
index e65f299..95c1d1a 100644
--- a/src/solvers/solutions.h
+++ b/src/solvers/solutions.h
@@ -43,8 +43,6 @@ solution_list_init(solution_list_t sols[static 1], size_t n, char buf[n])
43 sols->size = n; 43 sols->size = n;
44 sols->used = 0; 44 sols->used = 0;
45 sols->buf = buf; 45 sols->buf = buf;
46
47 /* Ensure string buffer is NULL-terminated */
48 sols->buf[0] = '\0'; 46 sols->buf[0] = '\0';
49 47
50 return true; 48 return true;
@@ -215,15 +213,8 @@ solutions_done(
215 int8_t depth 213 int8_t depth
216) 214)
217{ 215{
218 if (list->nsols >= settings->maxsolutions)
219 return true;
220
221 if (depth > settings->maxmoves)
222 return true;
223 216
224 if (list->nsols > 0 && settings->optimal >= 0 && 217 return depth > settings->maxmoves ||
225 depth > list->shortest_sol + settings->optimal) 218 depth > list->shortest_sol + settings->optimal ||
226 return true; 219 list->nsols >= settings->maxsolutions;
227
228 return false;
229} 220}

Generated with cgit - Back to sebastiano.tronto.net