diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-19 12:28:52 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-19 12:28:52 +0200 |
| commit | 3485be851f4fff1c9c6fe621f0619d2b4103bc06 (patch) | |
| tree | 894197f164a7ef66801ae3a701fb10a3c1e3f5e3 /src/solvers/coord/solve.h | |
| parent | 691da8f06614418ed847bdeefa4e708c372a3ecf (diff) | |
| download | nissy-core-3485be851f4fff1c9c6fe621f0619d2b4103bc06.tar.gz nissy-core-3485be851f4fff1c9c6fe621f0619d2b4103bc06.zip | |
Improved logging, especially for solve
Diffstat (limited to 'src/solvers/coord/solve.h')
| -rw-r--r-- | src/solvers/coord/solve.h | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/solvers/coord/solve.h b/src/solvers/coord/solve.h index b289e3f..072aa27 100644 --- a/src/solvers/coord/solve.h +++ b/src/solvers/coord/solve.h | |||
| @@ -121,7 +121,8 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[static 1]) | |||
| 121 | if (!coord_solution_admissible(arg)) | 121 | if (!coord_solution_admissible(arg)) |
| 122 | return 0; | 122 | return 0; |
| 123 | return appendsolution(arg->solution_moves, | 123 | return appendsolution(arg->solution_moves, |
| 124 | arg->solution_settings, arg->solution_list, true); | 124 | arg->solution_settings, arg->solution_list, true, |
| 125 | arg->coord->name); | ||
| 125 | } | 126 | } |
| 126 | 127 | ||
| 127 | if (solve_coord_dfs_stop(arg)) | 128 | if (solve_coord_dfs_stop(arg)) |
| @@ -220,12 +221,13 @@ solve_coord_dispatch( | |||
| 220 | strlen(coord_and_axis), coord_and_axis, &coord, &axis); | 221 | strlen(coord_and_axis), coord_and_axis, &coord, &axis); |
| 221 | 222 | ||
| 222 | if (coord == NULL) { | 223 | if (coord == NULL) { |
| 223 | LOG("Could not parse coordinate from '%s'\n", coord_and_axis); | 224 | LOG("Error: could not parse coordinate from '%s'\n", |
| 225 | coord_and_axis); | ||
| 224 | return NISSY_ERROR_INVALID_SOLVER; | 226 | return NISSY_ERROR_INVALID_SOLVER; |
| 225 | } | 227 | } |
| 226 | 228 | ||
| 227 | if (axis == UINT8_ERROR) { | 229 | if (axis == UINT8_ERROR) { |
| 228 | LOG("Could not parse axis from '%s'\n", coord_and_axis); | 230 | LOG("Error: could not parse axis from '%s'\n", coord_and_axis); |
| 229 | return NISSY_ERROR_INVALID_SOLVER; | 231 | return NISSY_ERROR_INVALID_SOLVER; |
| 230 | } | 232 | } |
| 231 | 233 | ||
| @@ -316,8 +318,8 @@ solve_coord( | |||
| 316 | }; | 318 | }; |
| 317 | 319 | ||
| 318 | if (coord->coord(c, coord_data) == 0) { | 320 | if (coord->coord(c, coord_data) == 0) { |
| 319 | if (minmoves == 0 && !appendsolution( | 321 | if (minmoves == 0 && !appendsolution(&solution_moves, |
| 320 | &solution_moves, &solution_settings, &solution_list, true)) | 322 | &solution_settings, &solution_list, true, coord->name)) |
| 321 | goto solve_coord_error_buffer; | 323 | goto solve_coord_error_buffer; |
| 322 | goto solve_coord_done; | 324 | goto solve_coord_done; |
| 323 | } | 325 | } |
| @@ -327,18 +329,17 @@ solve_coord( | |||
| 327 | !solutions_done(&solution_list, &solution_settings, d); | 329 | !solutions_done(&solution_list, &solution_settings, d); |
| 328 | d++ | 330 | d++ |
| 329 | ) { | 331 | ) { |
| 330 | if (d >= 10) | 332 | if (d >= 12) |
| 331 | LOG("Found %" PRIu64 " solutions, searching at depth %" | 333 | LOG("[%s solve] Found %" PRIu64 " solutions, " |
| 332 | PRId8 "\n", solution_list.nsols, d); | 334 | "searching at depth %" PRId8 "\n", |
| 335 | coord->name, solution_list.nsols, d); | ||
| 333 | 336 | ||
| 334 | arg.target_depth = d; | 337 | arg.target_depth = d; |
| 335 | solution_moves_reset(arg.solution_moves); | 338 | solution_moves_reset(arg.solution_moves); |
| 336 | ndepth = solve_coord_dfs(&arg); | 339 | ndepth = solve_coord_dfs(&arg); |
| 337 | 340 | ||
| 338 | if (ndepth < 0) { | 341 | if (ndepth < 0) |
| 339 | LOG("Error %" PRId64 "\n", ndepth); | ||
| 340 | return ndepth; | 342 | return ndepth; |
| 341 | } | ||
| 342 | 343 | ||
| 343 | solution_list.nsols += (uint64_t)ndepth; | 344 | solution_list.nsols += (uint64_t)ndepth; |
| 344 | } | 345 | } |
| @@ -347,14 +348,15 @@ solve_coord_done: | |||
| 347 | return (int64_t)solution_list.nsols; | 348 | return (int64_t)solution_list.nsols; |
| 348 | 349 | ||
| 349 | solve_coord_error_data: | 350 | solve_coord_error_data: |
| 350 | LOG("solve_coord: error reading table\n"); | 351 | LOG("[%s solve] Error reading table\n", coord->name); |
| 351 | return NISSY_ERROR_DATA; | 352 | return NISSY_ERROR_DATA; |
| 352 | 353 | ||
| 353 | solve_coord_error_buffer: | 354 | solve_coord_error_buffer: |
| 354 | LOG("Could not append solution to buffer: size too small\n"); | 355 | LOG("[%s solve] Error appending solution to buffer: size too small\n", |
| 356 | coord->name); | ||
| 355 | return NISSY_ERROR_BUFFER_SIZE; | 357 | return NISSY_ERROR_BUFFER_SIZE; |
| 356 | 358 | ||
| 357 | solve_coord_error_unsolvable: | 359 | solve_coord_error_unsolvable: |
| 358 | LOG("Cube not ready for solving %s\n", coord->name); | 360 | LOG("[%s solve] Error: cube not ready\n", coord->name); |
| 359 | return NISSY_ERROR_UNSOLVABLE_CUBE; | 361 | return NISSY_ERROR_UNSOLVABLE_CUBE; |
| 360 | } | 362 | } |
