diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-01 09:33:26 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-01 09:33:26 +0200 |
| commit | b0053277e385bee23336d1fe6b69a12f49f9172f (patch) | |
| tree | 531e44cd6f8e807c991d0a46692140667939fbe3 /src/solvers/h48 | |
| parent | b6c1ff6cfdfe0f4ce602fe83e54c3112a1c95690 (diff) | |
| download | nissy-core-b0053277e385bee23336d1fe6b69a12f49f9172f.tar.gz nissy-core-b0053277e385bee23336d1fe6b69a12f49f9172f.zip | |
simplified allowedmoves logic
Diffstat (limited to 'src/solvers/h48')
| -rw-r--r-- | src/solvers/h48/gendata_h48.h | 4 | ||||
| -rw-r--r-- | src/solvers/h48/solve.h | 21 |
2 files changed, 18 insertions, 7 deletions
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h index 959264d..b6647ed 100644 --- a/src/solvers/h48/gendata_h48.h +++ b/src/solvers/h48/gendata_h48.h | |||
| @@ -526,7 +526,7 @@ gendata_h48k2_dfs(h48k2_dfs_arg_t arg[static 1]) | |||
| 526 | /* Depth d+3 */ | 526 | /* Depth d+3 */ |
| 527 | for (m[2] = 0; m[2] < 18; m[2]++) { | 527 | for (m[2] = 0; m[2] < 18; m[2]++) { |
| 528 | markarg.depth = d+3; | 528 | markarg.depth = d+3; |
| 529 | if (!allowednextmove(3, m)) { | 529 | if (!allowednextmove(m[1], m[2])) { |
| 530 | m[2] += 2; | 530 | m[2] += 2; |
| 531 | continue; | 531 | continue; |
| 532 | } | 532 | } |
| @@ -541,7 +541,7 @@ gendata_h48k2_dfs(h48k2_dfs_arg_t arg[static 1]) | |||
| 541 | /* Depth d+4 */ | 541 | /* Depth d+4 */ |
| 542 | for (m[3] = 0; m[3] < 18; m[3]++) { | 542 | for (m[3] = 0; m[3] < 18; m[3]++) { |
| 543 | markarg.depth = d+4; | 543 | markarg.depth = d+4; |
| 544 | if (!allowednextmove(4, m)) { | 544 | if (!allowednextmove(m[2], m[3])) { |
| 545 | m[3] += 2; | 545 | m[3] += 2; |
| 546 | continue; | 546 | continue; |
| 547 | } | 547 | } |
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index dcec5a4..fc7631f 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h | |||
| @@ -176,10 +176,16 @@ solve_h48_dfs(dfsarg_solve_h48_t arg[static 1]) | |||
| 176 | ulbi = arg->use_lb_inverse; | 176 | ulbi = arg->use_lb_inverse; |
| 177 | 177 | ||
| 178 | ret = 0; | 178 | ret = 0; |
| 179 | mm_normal = allowednextmove_mask(arg->solution_moves->nmoves, | 179 | mm_normal = arg->movemask_normal; |
| 180 | arg->solution_moves->moves) & arg->movemask_normal; | 180 | if (arg->solution_moves->nmoves > 0) { |
| 181 | mm_inverse = allowednextmove_mask(arg->solution_moves->npremoves, | 181 | m = arg->solution_moves->moves[arg->solution_moves->nmoves-1]; |
| 182 | arg->solution_moves->premoves) & arg->movemask_inverse; | 182 | mm_normal &= allowedmask[movebase(m)]; |
| 183 | } | ||
| 184 | mm_inverse = arg->movemask_inverse; | ||
| 185 | if (arg->solution_moves->npremoves > 0) { | ||
| 186 | m = arg->solution_moves->premoves[arg->solution_moves->npremoves-1]; | ||
| 187 | mm_inverse &= allowedmask[movebase(m)]; | ||
| 188 | } | ||
| 183 | if (popcount_u32(mm_normal) <= popcount_u32(mm_inverse)) { | 189 | if (popcount_u32(mm_normal) <= popcount_u32(mm_inverse)) { |
| 184 | arg->solution_moves->nmoves++; | 190 | arg->solution_moves->nmoves++; |
| 185 | for (m = 0; m < 18; m++) { | 191 | for (m = 0; m < 18; m++) { |
| @@ -299,7 +305,12 @@ solve_h48_maketasks( | |||
| 299 | return NISSY_OK; | 305 | return NISSY_OK; |
| 300 | } | 306 | } |
| 301 | 307 | ||
| 302 | mm = allowednextmove_mask(maketasks_arg->nmoves, maketasks_arg->moves); | 308 | if (maketasks_arg->nmoves == 0) { |
| 309 | mm = MM_ALLMOVES; | ||
| 310 | } else { | ||
| 311 | m = maketasks_arg->moves[maketasks_arg->nmoves-1]; | ||
| 312 | mm = allowedmask[movebase(m)]; | ||
| 313 | } | ||
| 303 | 314 | ||
| 304 | maketasks_arg->nmoves++; | 315 | maketasks_arg->nmoves++; |
| 305 | backup_cube = maketasks_arg->cube; | 316 | backup_cube = maketasks_arg->cube; |
