diff options
Diffstat (limited to 'cpp')
| -rw-r--r-- | cpp/examples/solve_h48h3k2.cpp | 2 | ||||
| -rw-r--r-- | cpp/nissy.cpp | 16 | ||||
| -rw-r--r-- | cpp/nissy.h | 4 |
3 files changed, 15 insertions, 7 deletions
diff --git a/cpp/examples/solve_h48h3k2.cpp b/cpp/examples/solve_h48h3k2.cpp index 7f06376..f7ba235 100644 --- a/cpp/examples/solve_h48h3k2.cpp +++ b/cpp/examples/solve_h48h3k2.cpp | |||
| @@ -68,7 +68,7 @@ int main() { | |||
| 68 | 68 | ||
| 69 | // Solve | 69 | // Solve |
| 70 | auto solve_result = h48h3k2.solve(c, nissy::nissflag::NORMAL, | 70 | auto solve_result = h48h3k2.solve(c, nissy::nissflag::NORMAL, |
| 71 | 0, maxmoves, 1, -1, 8); | 71 | 0, maxmoves, 1, 20, 8); |
| 72 | 72 | ||
| 73 | // Write the result | 73 | // Write the result |
| 74 | if (!solve_result.err.ok()) { | 74 | if (!solve_result.err.ok()) { |
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, |
diff --git a/cpp/nissy.h b/cpp/nissy.h index db8ba5f..4b9c1c9 100644 --- a/cpp/nissy.h +++ b/cpp/nissy.h | |||
| @@ -91,8 +91,8 @@ namespace nissy { | |||
| 91 | error check_data(); | 91 | error check_data(); |
| 92 | void unload_data(); | 92 | void unload_data(); |
| 93 | solve_result solve(const cube&, nissflag, unsigned minmoves, | 93 | solve_result solve(const cube&, nissflag, unsigned minmoves, |
| 94 | unsigned maxmoves, unsigned maxsols, int optimal, | 94 | unsigned maxmoves, unsigned maxsols, unsigned optimal, |
| 95 | int threads); | 95 | unsigned threads); |
| 96 | 96 | ||
| 97 | static std::variant<solver, error> get(const std::string&); | 97 | static std::variant<solver, error> get(const std::string&); |
| 98 | private: | 98 | private: |
