aboutsummaryrefslogtreecommitdiff
path: root/cpp/nissy.cpp
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 /cpp/nissy.cpp
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 'cpp/nissy.cpp')
-rw-r--r--cpp/nissy.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/cpp/nissy.cpp b/cpp/nissy.cpp
index 944944b..92b10bd 100644
--- a/cpp/nissy.cpp
+++ b/cpp/nissy.cpp
@@ -21,8 +21,8 @@ extern "C" {
21 long long nissy_gendata(const char *, unsigned long long, char *); 21 long long nissy_gendata(const char *, unsigned long long, char *);
22 long long nissy_checkdata(unsigned long long, const char *); 22 long long nissy_checkdata(unsigned long long, const char *);
23 long long nissy_solve(const char *, const char *, unsigned, unsigned, 23 long long nissy_solve(const char *, const char *, unsigned, unsigned,
24 unsigned, unsigned, int, int, unsigned long long, const char *, 24 unsigned, unsigned, unsigned, unsigned, unsigned long long,
25 unsigned, char *, long long *); 25 const char *, unsigned, char *, long long *);
26 long long nissy_countmoves(const char *); 26 long long nissy_countmoves(const char *);
27 long long nissy_setlogger(void (*)(const char *, void *), void *); 27 long long nissy_setlogger(void (*)(const char *, void *), void *);
28} 28}
@@ -182,11 +182,19 @@ namespace nissy {
182 182
183 solver::solve_result 183 solver::solve_result
184 solver::solve(const cube& cube, nissflag niss, unsigned minmoves, 184 solver::solve(const cube& cube, nissflag niss, unsigned minmoves,
185 unsigned maxmoves, unsigned maxsols, int optimal, int threads) 185 unsigned maxmoves, unsigned maxsols, unsigned optimal,
186 unsigned threads)
186 { 187 {
188 solver::solve_result result;
189
190 if (maxsols == 0) {
191 result.solutions = {};
192 result.err = error::OK;
193 return result;
194 }
195
187 const size_t len = 3 * (maxmoves+1) * maxsols; 196 const size_t len = 3 * (maxmoves+1) * maxsols;
188 std::vector<char> csols(len); 197 std::vector<char> csols(len);
189 solver::solve_result result;
190 198
191 auto err = nissy_solve(cube.to_string().c_str(), 199 auto err = nissy_solve(cube.to_string().c_str(),
192 name.c_str(), niss.value, minmoves, maxmoves, maxsols, 200 name.c_str(), niss.value, minmoves, maxmoves, maxsols,

Generated with cgit - Back to sebastiano.tronto.net