aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/h48
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2026-01-08 14:05:03 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2026-01-08 16:56:07 +0100
commite8ac4ad0e682c21ee2ec24c006b1041e69165df9 (patch)
treeb5713b8447f34fd4a3f28d88671048652a2e7947 /src/solvers/h48
parentcf00cbd127a51a26c9ffeb9941f7343ec551e32a (diff)
downloadnissy-core-e8ac4ad0e682c21ee2ec24c006b1041e69165df9.tar.gz
nissy-core-e8ac4ad0e682c21ee2ec24c006b1041e69165df9.zip
Skip pipeline if target == 0
Diffstat (limited to 'src/solvers/h48')
-rw-r--r--src/solvers/h48/solve.h40
1 files changed, 26 insertions, 14 deletions
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h
index 2abc4c9..830a6b2 100644
--- a/src/solvers/h48/solve.h
+++ b/src/solvers/h48/solve.h
@@ -285,36 +285,48 @@ solve_h48_dfs(dfsarg_solve_h48_t arg[static 1])
285 uint8_t m, nm, nn, ni, target; 285 uint8_t m, nm, nn, ni, target;
286 uint64_t mm_normal, mm_inverse; 286 uint64_t mm_normal, mm_inverse;
287 bool normal; 287 bool normal;
288 cube_t backup_cube, backup_inverse; 288 cube_t cube, backup_cube, backup_inverse;
289 h48_prune_t prune[NMOVES]; 289 h48_prune_t prune[NMOVES];
290 290
291 nn = arg->solution_moves->nmoves; 291 nn = arg->solution_moves->nmoves;
292 ni = arg->solution_moves->npremoves; 292 ni = arg->solution_moves->npremoves;
293 nm = nn + ni; 293 nm = nn + ni;
294 if (equal(arg->cube, SOLVED_CUBE)) {
295 if (arg->target_depth != nm)
296 return 0;
297 wrapthread_mutex_lock(arg->solutions_mutex);
298 ret = appendsolution(arg->solution_moves, H48_STARTING_MOVES,
299 arg->tmask, arg->solution_settings, arg->solution_list);
300 wrapthread_mutex_unlock(arg->solutions_mutex);
301 return ret;
302 }
303 294
304 if (nm + 1 > arg->target_depth || 295 if (equal(arg->cube, SOLVED_CUBE) || /* Solved before target depth */
305 arg->solution_list->nsols >= arg->solution_settings->maxsolutions) 296 arg->solution_list->nsols >= arg->solution_settings->maxsolutions)
306 return 0; 297 return 0;
307 298
308 ret = 0;
309 target = arg->target_depth - (nm + 1); 299 target = arg->target_depth - (nm + 1);
310 backup_cube = arg->cube;
311 backup_inverse = arg->inverse;
312 mm_normal = arg->movemask_normal; 300 mm_normal = arg->movemask_normal;
313 mm_inverse = arg->movemask_inverse; 301 mm_inverse = arg->movemask_inverse;
302 if (target == 0) { /* Last move */
303 arg->solution_moves->nmoves++;
304 for (m = 0; m < NMOVES; m++) {
305 if (!(mm_normal & mm_inverse & MM_SINGLE(m)))
306 continue;
307 cube = move(arg->cube, m);
308 arg->solution_moves->moves[nn] = m;
309 if (!equal(cube, SOLVED_CUBE))
310 continue;
311 wrapthread_mutex_lock(arg->solutions_mutex);
312 ret = appendsolution(arg->solution_moves,
313 H48_STARTING_MOVES, arg->tmask,
314 arg->solution_settings, arg->solution_list);
315 wrapthread_mutex_unlock(arg->solutions_mutex);
316 arg->solution_moves->nmoves--;
317 return ret;
318 }
319 arg->solution_moves->nmoves--;
320 return 0;
321 }
322
323 backup_cube = arg->cube;
324 backup_inverse = arg->inverse;
314 normal = popcount_u32(mm_normal) <= popcount_u32(mm_inverse); 325 normal = popcount_u32(mm_normal) <= popcount_u32(mm_inverse);
315 326
316 h48_prune_pipeline(arg, prune, target, normal); 327 h48_prune_pipeline(arg, prune, target, normal);
317 328
329 ret = 0;
318 if (normal) { 330 if (normal) {
319 arg->solution_moves->nmoves++; 331 arg->solution_moves->nmoves++;
320 for (m = 0; m < NMOVES; m++) { 332 for (m = 0; m < NMOVES; m++) {

Generated with cgit - Back to sebastiano.tronto.net