aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/coord/solve.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/solvers/coord/solve.h')
-rw-r--r--src/solvers/coord/solve.h27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/solvers/coord/solve.h b/src/solvers/coord/solve.h
index fa4134a..8806d17 100644
--- a/src/solvers/coord/solve.h
+++ b/src/solvers/coord/solve.h
@@ -135,11 +135,10 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[static 1])
135 ret = 0; 135 ret = 0;
136 if (coord_continue_onnormal(arg)) { 136 if (coord_continue_onnormal(arg)) {
137 l = arg->solution_moves->nmoves; 137 l = arg->solution_moves->nmoves;
138 if (l == 0) { 138 mm = arg->coord->moves_mask;
139 mm = MM_ALLMOVES; 139 if (l != 0) {
140 } else {
141 m = arg->solution_moves->moves[l-1]; 140 m = arg->solution_moves->moves[l-1];
142 mm = allowedmask[movebase(m)]; 141 mm &= allowedmask[movebase(m)];
143 } 142 }
144 arg->solution_moves->nmoves++; 143 arg->solution_moves->nmoves++;
145 arg->lastisnormal = true; 144 arg->lastisnormal = true;
@@ -165,11 +164,10 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[static 1])
165 164
166 if (coord_continue_oninverse(arg)) { 165 if (coord_continue_oninverse(arg)) {
167 l = arg->solution_moves->npremoves; 166 l = arg->solution_moves->npremoves;
168 if (l == 0) { 167 mm = arg->coord->moves_mask;
169 mm = MM_ALLMOVES; 168 if (l != 0) {
170 } else {
171 m = arg->solution_moves->premoves[l-1]; 169 m = arg->solution_moves->premoves[l-1];
172 mm = allowedmask[movebase(m)]; 170 mm &= allowedmask[movebase(m)];
173 } 171 }
174 arg->solution_moves->npremoves++; 172 arg->solution_moves->npremoves++;
175 arg->lastisnormal = false; 173 arg->lastisnormal = false;
@@ -264,6 +262,12 @@ solve_coord(
264 solution_settings_t solution_settings; 262 solution_settings_t solution_settings;
265 solution_list_t solution_list; 263 solution_list_t solution_list;
266 264
265 t = coord->axistrans[axis];
266 c = transform(cube, t);
267
268 if (!coord->is_solvable(c))
269 goto solve_coord_error_unsolvable;
270
267 if (!solution_list_init(&solution_list, solutions_size, sols)) 271 if (!solution_list_init(&solution_list, solutions_size, sols))
268 goto solve_coord_error_buffer; 272 goto solve_coord_error_buffer;
269 273
@@ -280,9 +284,6 @@ solve_coord(
280 ptable = (uint8_t *)data + info.next + INFOSIZE; 284 ptable = (uint8_t *)data + info.next + INFOSIZE;
281 } 285 }
282 286
283 t = coord->axistrans[axis];
284 c = transform(cube, t);
285
286 solution_moves_reset(&solution_moves); 287 solution_moves_reset(&solution_moves);
287 288
288 solution_settings = (solution_settings_t) { 289 solution_settings = (solution_settings_t) {
@@ -351,4 +352,8 @@ solve_coord_error_data:
351solve_coord_error_buffer: 352solve_coord_error_buffer:
352 LOG("Could not append solution to buffer: size too small\n"); 353 LOG("Could not append solution to buffer: size too small\n");
353 return NISSY_ERROR_BUFFER_SIZE; 354 return NISSY_ERROR_BUFFER_SIZE;
355
356solve_coord_error_unsolvable:
357 LOG("Cube not ready for solving %s\n", coord->name);
358 return NISSY_ERROR_UNSOLVABLE_CUBE;
354} 359}

Generated with cgit - Back to sebastiano.tronto.net