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 | |
| parent | b6c1ff6cfdfe0f4ce602fe83e54c3112a1c95690 (diff) | |
| download | nissy-core-b0053277e385bee23336d1fe6b69a12f49f9172f.tar.gz nissy-core-b0053277e385bee23336d1fe6b69a12f49f9172f.zip | |
simplified allowedmoves logic
Diffstat (limited to 'src/solvers')
| -rw-r--r-- | src/solvers/coord/solve.h | 14 | ||||
| -rw-r--r-- | src/solvers/h48/gendata_h48.h | 4 | ||||
| -rw-r--r-- | src/solvers/h48/solve.h | 21 | ||||
| -rw-r--r-- | src/solvers/solutions.h | 2 |
4 files changed, 31 insertions, 10 deletions
diff --git a/src/solvers/coord/solve.h b/src/solvers/coord/solve.h index c3fbd02..fa4134a 100644 --- a/src/solvers/coord/solve.h +++ b/src/solvers/coord/solve.h | |||
| @@ -135,7 +135,12 @@ 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 | mm = allowednextmove_mask(l, arg->solution_moves->moves); | 138 | if (l == 0) { |
| 139 | mm = MM_ALLMOVES; | ||
| 140 | } else { | ||
| 141 | m = arg->solution_moves->moves[l-1]; | ||
| 142 | mm = allowedmask[movebase(m)]; | ||
| 143 | } | ||
| 139 | arg->solution_moves->nmoves++; | 144 | arg->solution_moves->nmoves++; |
| 140 | arg->lastisnormal = true; | 145 | arg->lastisnormal = true; |
| 141 | 146 | ||
| @@ -160,7 +165,12 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[static 1]) | |||
| 160 | 165 | ||
| 161 | if (coord_continue_oninverse(arg)) { | 166 | if (coord_continue_oninverse(arg)) { |
| 162 | l = arg->solution_moves->npremoves; | 167 | l = arg->solution_moves->npremoves; |
| 163 | mm = allowednextmove_mask(l, arg->solution_moves->premoves); | 168 | if (l == 0) { |
| 169 | mm = MM_ALLMOVES; | ||
| 170 | } else { | ||
| 171 | m = arg->solution_moves->premoves[l-1]; | ||
| 172 | mm = allowedmask[movebase(m)]; | ||
| 173 | } | ||
| 164 | arg->solution_moves->npremoves++; | 174 | arg->solution_moves->npremoves++; |
| 165 | arg->lastisnormal = false; | 175 | arg->lastisnormal = false; |
| 166 | 176 | ||
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; |
diff --git a/src/solvers/solutions.h b/src/solvers/solutions.h index bbff9cf..1b5517c 100644 --- a/src/solvers/solutions.h +++ b/src/solvers/solutions.h | |||
| @@ -128,7 +128,7 @@ appendsolution( | |||
| 128 | 128 | ||
| 129 | /* | 129 | /* |
| 130 | This is a bit ugly: we have to sort now and then again | 130 | This is a bit ugly: we have to sort now and then again |
| 131 | later, because the allowednext check would fail with | 131 | later, because the allowedmoves check would fail with |
| 132 | improperly sorted parallel moves, but then transforming | 132 | improperly sorted parallel moves, but then transforming |
| 133 | could swap the pairs the wrong way around. | 133 | could swap the pairs the wrong way around. |
| 134 | TODO: maybe fix this | 134 | TODO: maybe fix this |
