diff options
Diffstat (limited to 'src/solvers/solutions.h')
| -rw-r--r-- | src/solvers/solutions.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/solvers/solutions.h b/src/solvers/solutions.h index 1b5517c..e65f299 100644 --- a/src/solvers/solutions.h +++ b/src/solvers/solutions.h | |||
| @@ -7,7 +7,7 @@ STATIC bool solution_moves_equal( | |||
| 7 | STATIC bool solution_moves_is_duplicate(size_t n, const solution_moves_t[n+1]); | 7 | STATIC bool solution_moves_is_duplicate(size_t n, const solution_moves_t[n+1]); |
| 8 | STATIC bool appendchar(solution_list_t [static 1], char); | 8 | STATIC bool appendchar(solution_list_t [static 1], char); |
| 9 | STATIC int64_t appendsolution(const solution_moves_t [static 1], | 9 | STATIC int64_t appendsolution(const solution_moves_t [static 1], |
| 10 | const solution_settings_t [static 1], solution_list_t [static 1]); | 10 | const solution_settings_t [static 1], solution_list_t [static 1], bool); |
| 11 | STATIC bool solutions_done(const solution_list_t [static 1], | 11 | STATIC bool solutions_done(const solution_list_t [static 1], |
| 12 | const solution_settings_t [static 1], int8_t depth); | 12 | const solution_settings_t [static 1], int8_t depth); |
| 13 | 13 | ||
| @@ -99,13 +99,15 @@ STATIC int64_t | |||
| 99 | appendsolution( | 99 | appendsolution( |
| 100 | const solution_moves_t moves[static 1], | 100 | const solution_moves_t moves[static 1], |
| 101 | const solution_settings_t settings[static 1], | 101 | const solution_settings_t settings[static 1], |
| 102 | solution_list_t list[static 1] | 102 | solution_list_t list[static 1], |
| 103 | bool log | ||
| 103 | ) | 104 | ) |
| 104 | { | 105 | { |
| 105 | int64_t r, strl; | 106 | int64_t r, strl; |
| 106 | int i; | 107 | int i; |
| 107 | uint8_t t; | 108 | uint8_t t; |
| 108 | solution_moves_t tsol[NTRANS]; | 109 | solution_moves_t tsol[NTRANS]; |
| 110 | char *last_start; | ||
| 109 | 111 | ||
| 110 | if (moves->nmoves + moves->npremoves > MAXLEN) | 112 | if (moves->nmoves + moves->npremoves > MAXLEN) |
| 111 | goto appendsolution_error_solution_length; | 113 | goto appendsolution_error_solution_length; |
| @@ -147,6 +149,8 @@ appendsolution( | |||
| 147 | if (solution_moves_is_duplicate(r, tsol)) | 149 | if (solution_moves_is_duplicate(r, tsol)) |
| 148 | continue; | 150 | continue; |
| 149 | 151 | ||
| 152 | last_start = list->buf + list->used; | ||
| 153 | |||
| 150 | /* Write moves on normal */ | 154 | /* Write moves on normal */ |
| 151 | strl = writemoves(tsol[r].nmoves, tsol[r].moves, | 155 | strl = writemoves(tsol[r].nmoves, tsol[r].moves, |
| 152 | list->size - list->used, list->buf + list->used); | 156 | list->size - list->used, list->buf + list->used); |
| @@ -179,6 +183,13 @@ appendsolution( | |||
| 179 | list->shortest_sol = MIN( | 183 | list->shortest_sol = MIN( |
| 180 | list->shortest_sol, tsol[r].nmoves + tsol[r].npremoves); | 184 | list->shortest_sol, tsol[r].nmoves + tsol[r].npremoves); |
| 181 | r++; | 185 | r++; |
| 186 | |||
| 187 | if (log) { | ||
| 188 | list->buf[list->used-1] = '\0'; | ||
| 189 | LOG("Found solution #%" PRIu64 ": %s\n", | ||
| 190 | list->nsols, last_start); | ||
| 191 | list->buf[list->used-1] = '\n'; | ||
| 192 | } | ||
| 182 | } | 193 | } |
| 183 | 194 | ||
| 184 | list->buf[list->used] = '\0'; | 195 | list->buf[list->used] = '\0'; |
