diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-12-28 20:16:35 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-12-28 20:16:35 +0100 |
| commit | 08468ee2afdae84f37ce745e9eda71a165734b09 (patch) | |
| tree | 16b11f0ea4626fda6245ef728dba9624fe531d38 | |
| parent | b186685932e5fb0be39911cc582aef839789f1a2 (diff) | |
| download | nissy-core-08468ee2afdae84f37ce745e9eda71a165734b09.tar.gz nissy-core-08468ee2afdae84f37ce745e9eda71a165734b09.zip | |
cleanup
| -rw-r--r-- | src/solvers/h48/solve.h | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index 592edf3..c51fa29 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h | |||
| @@ -1,11 +1,5 @@ | |||
| 1 | #define H48_STARTING_MOVES 4 | 1 | #define H48_STARTING_MOVES 4 |
| 2 | 2 | #define H48_STARTING_CUBES 43254 | |
| 3 | #if H48_STARTING_MOVES == 3 | ||
| 4 | #define H48_STARTING_CUBES 3240 /* Number of 3-move sequences */ | ||
| 5 | #elif H48_STARTING_MOVES == 4 | ||
| 6 | #define H48_STARTING_CUBES 43254 /* Number of 4-move sequences */ | ||
| 7 | #endif | ||
| 8 | |||
| 9 | #define H48_SORT_TASKS_MIN_DEPTH 16 | 3 | #define H48_SORT_TASKS_MIN_DEPTH 16 |
| 10 | #define H48_LOG_PROGRESS_MIN_DEPTH 15 | 4 | #define H48_LOG_PROGRESS_MIN_DEPTH 15 |
| 11 | 5 | ||
| @@ -32,8 +26,8 @@ typedef struct { | |||
| 32 | const uint32_t *cocsepdata; | 26 | const uint32_t *cocsepdata; |
| 33 | const unsigned char *h48data; | 27 | const unsigned char *h48data; |
| 34 | const unsigned char *eoesepdata; | 28 | const unsigned char *eoesepdata; |
| 35 | uint64_t movemask_normal; // TODO change to uint32_t ? | 29 | uint64_t movemask_normal; |
| 36 | uint64_t movemask_inverse; // TODO change to uint32_t ? | 30 | uint64_t movemask_inverse; |
| 37 | uint64_t nodes_visited; | 31 | uint64_t nodes_visited; |
| 38 | uint64_t table_fallbacks; | 32 | uint64_t table_fallbacks; |
| 39 | uint64_t table_lookups; | 33 | uint64_t table_lookups; |
| @@ -70,8 +64,8 @@ STATIC long long solve_h48_dispatch(oriented_cube_t, const char *, unsigned, | |||
| 70 | unsigned, unsigned, unsigned, unsigned, unsigned, unsigned long long, | 64 | unsigned, unsigned, unsigned, unsigned, unsigned, unsigned long long, |
| 71 | const unsigned char *, unsigned, char *, | 65 | const unsigned char *, unsigned, char *, |
| 72 | long long [static NISSY_SIZE_SOLVE_STATS], int (*)(void *), void *); | 66 | long long [static NISSY_SIZE_SOLVE_STATS], int (*)(void *), void *); |
| 73 | STATIC_INLINE void h48_prune_pipeline( | 67 | STATIC_INLINE void h48_prune_pipeline(dfsarg_solve_h48_t [static 1], |
| 74 | dfsarg_solve_h48_t [static 1], h48_prune_t [static 18], uint8_t, bool); | 68 | h48_prune_t [static NMOVES], uint8_t, bool); |
| 75 | STATIC_INLINE uint8_t h48_prune_lookup( | 69 | STATIC_INLINE uint8_t h48_prune_lookup( |
| 76 | uint64_t, cube_t, dfsarg_solve_h48_t [static 1]); | 70 | uint64_t, cube_t, dfsarg_solve_h48_t [static 1]); |
| 77 | STATIC_INLINE void h48_prune_restore(const h48_prune_t [static 1], | 71 | STATIC_INLINE void h48_prune_restore(const h48_prune_t [static 1], |
| @@ -139,7 +133,7 @@ h48_prune_lookup( | |||
| 139 | STATIC_INLINE void | 133 | STATIC_INLINE void |
| 140 | h48_prune_pipeline( | 134 | h48_prune_pipeline( |
| 141 | dfsarg_solve_h48_t arg[static 1], | 135 | dfsarg_solve_h48_t arg[static 1], |
| 142 | h48_prune_t prune[static 18], | 136 | h48_prune_t prune[static NMOVES], |
| 143 | uint8_t target, | 137 | uint8_t target, |
| 144 | bool normal | 138 | bool normal |
| 145 | ) | 139 | ) |
| @@ -148,9 +142,9 @@ h48_prune_pipeline( | |||
| 148 | uint8_t m, p; | 142 | uint8_t m, p; |
| 149 | 143 | ||
| 150 | /* Stage 0: initialize the neighbors array */ | 144 | /* Stage 0: initialize the neighbors array */ |
| 151 | memset(prune, 0, 18 * sizeof(h48_prune_t)); | 145 | memset(prune, 0, NMOVES * sizeof(h48_prune_t)); |
| 152 | if (normal) { | 146 | if (normal) { |
| 153 | for (m = 0; m < 18; m++) { | 147 | for (m = 0; m < NMOVES; m++) { |
| 154 | prune[m].pi = m % 3 == 1 ? arg->lb_inverse : 0; | 148 | prune[m].pi = m % 3 == 1 ? arg->lb_inverse : 0; |
| 155 | if (!(arg->movemask_normal & MM_SINGLE(m)) || | 149 | if (!(arg->movemask_normal & MM_SINGLE(m)) || |
| 156 | prune[m].pi > target) { | 150 | prune[m].pi > target) { |
| @@ -163,7 +157,7 @@ h48_prune_pipeline( | |||
| 163 | arg->nodes_visited++; | 157 | arg->nodes_visited++; |
| 164 | } | 158 | } |
| 165 | } else { | 159 | } else { |
| 166 | for (m = 0; m < 18; m++) { | 160 | for (m = 0; m < NMOVES; m++) { |
| 167 | prune[m].pi = m % 3 == 1 ? arg->lb_normal : 0; | 161 | prune[m].pi = m % 3 == 1 ? arg->lb_normal : 0; |
| 168 | if (!(arg->movemask_inverse & MM_SINGLE(m)) || | 162 | if (!(arg->movemask_inverse & MM_SINGLE(m)) || |
| 169 | prune[m].pi > target) { | 163 | prune[m].pi > target) { |
| @@ -178,7 +172,7 @@ h48_prune_pipeline( | |||
| 178 | } | 172 | } |
| 179 | 173 | ||
| 180 | /* Stage 1: cdata and prefetch inverse */ | 174 | /* Stage 1: cdata and prefetch inverse */ |
| 181 | for (m = 0; m < 18; m++) { | 175 | for (m = 0; m < NMOVES; m++) { |
| 182 | if (prune[m].stop) | 176 | if (prune[m].stop) |
| 183 | continue; | 177 | continue; |
| 184 | 178 | ||
| @@ -195,7 +189,7 @@ h48_prune_pipeline( | |||
| 195 | } | 189 | } |
| 196 | 190 | ||
| 197 | /* Stage 2: get pval from inverse, prefetch normal */ | 191 | /* Stage 2: get pval from inverse, prefetch normal */ |
| 198 | for (m = 0; m < 18; m++) { | 192 | for (m = 0; m < NMOVES; m++) { |
| 199 | if (prune[m].stop) | 193 | if (prune[m].stop) |
| 200 | continue; | 194 | continue; |
| 201 | 195 | ||
| @@ -220,7 +214,7 @@ h48_prune_pipeline( | |||
| 220 | } | 214 | } |
| 221 | 215 | ||
| 222 | /* Stage 3: get pval from normal */ | 216 | /* Stage 3: get pval from normal */ |
| 223 | for (m = 0; m < 18; m++) { | 217 | for (m = 0; m < NMOVES; m++) { |
| 224 | if (prune[m].stop) | 218 | if (prune[m].stop) |
| 225 | continue; | 219 | continue; |
| 226 | 220 | ||
| @@ -275,7 +269,7 @@ solve_h48_dfs(dfsarg_solve_h48_t arg[static 1]) | |||
| 275 | uint64_t mm_normal, mm_inverse; | 269 | uint64_t mm_normal, mm_inverse; |
| 276 | bool normal; | 270 | bool normal; |
| 277 | cube_t backup_cube, backup_inverse; | 271 | cube_t backup_cube, backup_inverse; |
| 278 | h48_prune_t prune[18]; | 272 | h48_prune_t prune[NMOVES]; |
| 279 | 273 | ||
| 280 | nn = arg->solution_moves->nmoves; | 274 | nn = arg->solution_moves->nmoves; |
| 281 | ni = arg->solution_moves->npremoves; | 275 | ni = arg->solution_moves->npremoves; |
| @@ -309,7 +303,7 @@ solve_h48_dfs(dfsarg_solve_h48_t arg[static 1]) | |||
| 309 | else | 303 | else |
| 310 | arg->solution_moves->npremoves++; | 304 | arg->solution_moves->npremoves++; |
| 311 | 305 | ||
| 312 | for (m = 0; m < 18; m++) { | 306 | for (m = 0; m < NMOVES; m++) { |
| 313 | if (prune[m].stop) | 307 | if (prune[m].stop) |
| 314 | continue; | 308 | continue; |
| 315 | arg->movemask_normal = mm_normal; | 309 | arg->movemask_normal = mm_normal; |
| @@ -446,7 +440,7 @@ solve_h48_maketasks( | |||
| 446 | 440 | ||
| 447 | mtarg->nmoves++; | 441 | mtarg->nmoves++; |
| 448 | backup_cube = mtarg->cube; | 442 | backup_cube = mtarg->cube; |
| 449 | for (m = 0; m < 18; m++) { | 443 | for (m = 0; m < NMOVES; m++) { |
| 450 | if (!(mm & MM_SINGLE(m))) | 444 | if (!(mm & MM_SINGLE(m))) |
| 451 | continue; | 445 | continue; |
| 452 | 446 | ||
