aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/solutions.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-04-19 12:28:52 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-04-19 12:28:52 +0200
commit3485be851f4fff1c9c6fe621f0619d2b4103bc06 (patch)
tree894197f164a7ef66801ae3a701fb10a3c1e3f5e3 /src/solvers/solutions.h
parent691da8f06614418ed847bdeefa4e708c372a3ecf (diff)
downloadnissy-core-3485be851f4fff1c9c6fe621f0619d2b4103bc06.tar.gz
nissy-core-3485be851f4fff1c9c6fe621f0619d2b4103bc06.zip
Improved logging, especially for solve
Diffstat (limited to 'src/solvers/solutions.h')
-rw-r--r--src/solvers/solutions.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/solvers/solutions.h b/src/solvers/solutions.h
index 95c1d1a..c9a1313 100644
--- a/src/solvers/solutions.h
+++ b/src/solvers/solutions.h
@@ -7,7 +7,8 @@ STATIC bool solution_moves_equal(
7STATIC bool solution_moves_is_duplicate(size_t n, const solution_moves_t[n+1]); 7STATIC bool solution_moves_is_duplicate(size_t n, const solution_moves_t[n+1]);
8STATIC bool appendchar(solution_list_t [static 1], char); 8STATIC bool appendchar(solution_list_t [static 1], char);
9STATIC int64_t appendsolution(const solution_moves_t [static 1], 9STATIC int64_t appendsolution(const solution_moves_t [static 1],
10 const solution_settings_t [static 1], solution_list_t [static 1], bool); 10 const solution_settings_t [static 1], solution_list_t [static 1], bool,
11 const char *);
11STATIC bool solutions_done(const solution_list_t [static 1], 12STATIC bool solutions_done(const solution_list_t [static 1],
12 const solution_settings_t [static 1], int8_t depth); 13 const solution_settings_t [static 1], int8_t depth);
13 14
@@ -34,7 +35,7 @@ STATIC bool
34solution_list_init(solution_list_t sols[static 1], size_t n, char buf[n]) 35solution_list_init(solution_list_t sols[static 1], size_t n, char buf[n])
35{ 36{
36 if (n == 0) { 37 if (n == 0) {
37 LOG("Cannot use solution buffer with size 0\n"); 38 LOG("Error: cannot use solution buffer with size 0\n");
38 return false; 39 return false;
39 } 40 }
40 41
@@ -98,7 +99,8 @@ appendsolution(
98 const solution_moves_t moves[static 1], 99 const solution_moves_t moves[static 1],
99 const solution_settings_t settings[static 1], 100 const solution_settings_t settings[static 1],
100 solution_list_t list[static 1], 101 solution_list_t list[static 1],
101 bool log 102 bool log,
103 const char *solver_name
102) 104)
103{ 105{
104 int64_t r, strl; 106 int64_t r, strl;
@@ -184,8 +186,8 @@ appendsolution(
184 186
185 if (log) { 187 if (log) {
186 list->buf[list->used-1] = '\0'; 188 list->buf[list->used-1] = '\0';
187 LOG("Found solution #%" PRIu64 ": %s\n", 189 LOG("[%s solve] Found solution #%" PRIu64 ": %s\n",
188 list->nsols, last_start); 190 solver_name, list->nsols, last_start);
189 list->buf[list->used-1] = '\n'; 191 list->buf[list->used-1] = '\n';
190 } 192 }
191 } 193 }
@@ -194,14 +196,14 @@ appendsolution(
194 return r; 196 return r;
195 197
196appendsolution_error_buffer: 198appendsolution_error_buffer:
197 LOG("Could not append solution to buffer: size too small\n"); 199 LOG("[%s solve] Error: buffer too small\n", solver_name);
198 list->buf[0] = '\0'; 200 list->buf[0] = '\0';
199 return NISSY_ERROR_BUFFER_SIZE; 201 return NISSY_ERROR_BUFFER_SIZE;
200 202
201appendsolution_error_solution_length: 203appendsolution_error_solution_length:
202 LOG("Error: solution is too long (%" PRIu8 ").\n" 204 LOG("[%s solve] Error: solution is too long (%" PRIu8 ").\n"
203 "This is a bug, please report it.\n", 205 "This is a bug, please report it.\n",
204 moves->nmoves + moves->npremoves); 206 solver_name, moves->nmoves + moves->npremoves);
205 list->buf[0] = '\0'; 207 list->buf[0] = '\0';
206 return NISSY_ERROR_UNKNOWN; 208 return NISSY_ERROR_UNKNOWN;
207} 209}

Generated with cgit - Back to sebastiano.tronto.net