aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/coord
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/coord
parent691da8f06614418ed847bdeefa4e708c372a3ecf (diff)
downloadnissy-core-3485be851f4fff1c9c6fe621f0619d2b4103bc06.tar.gz
nissy-core-3485be851f4fff1c9c6fe621f0619d2b4103bc06.zip
Improved logging, especially for solve
Diffstat (limited to 'src/solvers/coord')
-rw-r--r--src/solvers/coord/gendata.h9
-rw-r--r--src/solvers/coord/solve.h30
-rw-r--r--src/solvers/coord/utils.h2
3 files changed, 22 insertions, 19 deletions
diff --git a/src/solvers/coord/gendata.h b/src/solvers/coord/gendata.h
index 6abb5eb..ae7b39e 100644
--- a/src/solvers/coord/gendata.h
+++ b/src/solvers/coord/gendata.h
@@ -22,7 +22,7 @@ gendata_coord_dispatch(const char *coordstr, void *buf)
22 parse_coord_and_axis(strlen(coordstr), coordstr, &coord, NULL); 22 parse_coord_and_axis(strlen(coordstr), coordstr, &coord, NULL);
23 23
24 if (coord == NULL) { 24 if (coord == NULL) {
25 LOG("Could not parse coordinate '%s'\n", coordstr); 25 LOG("Error: could not parse coordinate '%s'\n", coordstr);
26 return NISSY_ERROR_INVALID_SOLVER; 26 return NISSY_ERROR_INVALID_SOLVER;
27 } 27 }
28 28
@@ -82,7 +82,7 @@ gendata_coord_return_size:
82 return ninfo * INFOSIZE + coord_dsize + tablesize; 82 return ninfo * INFOSIZE + coord_dsize + tablesize;
83 83
84gendata_coord_error: 84gendata_coord_error:
85 LOG("An unexpected error occurred when generating the data.\n"); 85 LOG("Unexpected error generating coordinate data\n");
86 return 0; 86 return 0;
87} 87}
88 88
@@ -136,8 +136,9 @@ genptable_coord(
136 } 136 }
137 tot += t; 137 tot += t;
138 info.distribution[d] = t; 138 info.distribution[d] = t;
139 LOG("Depth %" PRIu64 ": found %" PRIu64 " (%" PRIu64 " of %" 139 LOG("[%s gendata] Depth %" PRIu64 ": found %" PRIu64 " (%"
140 PRIu64 ")\n", d, t, tot, coord->max); 140 PRIu64 " of %" PRIu64 ")\n",
141 coord->name, d, t, tot, coord->max);
141 } 142 }
142 info.maxvalue = d-1; 143 info.maxvalue = d-1;
143 144
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
349solve_coord_error_data: 350solve_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
353solve_coord_error_buffer: 354solve_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
357solve_coord_error_unsolvable: 359solve_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}
diff --git a/src/solvers/coord/utils.h b/src/solvers/coord/utils.h
index 5407de3..ef3f817 100644
--- a/src/solvers/coord/utils.h
+++ b/src/solvers/coord/utils.h
@@ -59,7 +59,7 @@ dataid_coord(const char *ca, char dataid[static NISSY_SIZE_DATAID])
59 parse_coord_and_axis(strlen(ca), ca, &c, NULL); 59 parse_coord_and_axis(strlen(ca), ca, &c, NULL);
60 60
61 if (c == NULL) { 61 if (c == NULL) {
62 LOG("dataid_coord: cannot parse coordinate from '%s'\n", ca); 62 LOG("Error: cannot parse coordinate from '%s'\n", ca);
63 return NISSY_ERROR_INVALID_SOLVER; 63 return NISSY_ERROR_INVALID_SOLVER;
64 } 64 }
65 65

Generated with cgit - Back to sebastiano.tronto.net