aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/h48/solve.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-04-25 10:09:22 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-04-25 10:09:22 +0200
commit7faca28009c5efb0ba2b897b34dbdcac47a1a6f3 (patch)
treefd507509d00d2926175c72f4c06b9158c3a331a7 /src/solvers/h48/solve.h
parent17e5a9e1e2b241c67956651f87f40236467fe7d8 (diff)
downloadnissy-core-7faca28009c5efb0ba2b897b34dbdcac47a1a6f3.tar.gz
nissy-core-7faca28009c5efb0ba2b897b34dbdcac47a1a6f3.zip
NISS
Diffstat (limited to 'src/solvers/h48/solve.h')
-rw-r--r--src/solvers/h48/solve.h31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h
index 86c590a..e3ef9b9 100644
--- a/src/solvers/h48/solve.h
+++ b/src/solvers/h48/solve.h
@@ -25,8 +25,8 @@ typedef struct {
25 const unsigned char *h48data; 25 const unsigned char *h48data;
26 const unsigned char *h48data_fallback_h0k4; 26 const unsigned char *h48data_fallback_h0k4;
27 const unsigned char *h48data_fallback_eoesep; 27 const unsigned char *h48data_fallback_eoesep;
28 uint32_t movemask_normal; 28 uint64_t movemask_normal;
29 uint32_t movemask_inverse; 29 uint64_t movemask_inverse;
30 int64_t nodes_visited; 30 int64_t nodes_visited;
31 int64_t table_fallbacks; 31 int64_t table_fallbacks;
32 int64_t table_lookups; 32 int64_t table_lookups;
@@ -72,7 +72,7 @@ solve_h48_stop(dfsarg_solve_h48_t arg[static 1])
72 arg->solution_settings->optimal) 72 arg->solution_settings->optimal)
73 return true; 73 return true;
74 74
75 arg->movemask_normal = arg->movemask_inverse = MM_ALLMOVES; 75 arg->movemask_normal = arg->movemask_inverse = MM18_ALLMOVES;
76 arg->nodes_visited++; 76 arg->nodes_visited++;
77 77
78 /* Preliminary probing using last computed bound, if possible */ 78 /* Preliminary probing using last computed bound, if possible */
@@ -113,7 +113,7 @@ solve_h48_stop(dfsarg_solve_h48_t arg[static 1])
113 if (arg->lb_inverse > target) 113 if (arg->lb_inverse > target)
114 return true; 114 return true;
115 nh = arg->lb_inverse == target; 115 nh = arg->lb_inverse == target;
116 arg->movemask_normal = nh * MM_NOHALFTURNS + (1-nh) * MM_ALLMOVES; 116 arg->movemask_normal = nh * MM18_NOHALFTURNS + (1-nh) * MM18_ALLMOVES;
117 117
118 /* Normal probing */ 118 /* Normal probing */
119 119
@@ -141,7 +141,7 @@ solve_h48_stop(dfsarg_solve_h48_t arg[static 1])
141 if (arg->lb_normal > target) 141 if (arg->lb_normal > target)
142 return true; 142 return true;
143 nh = arg->lb_normal == target; 143 nh = arg->lb_normal == target;
144 arg->movemask_inverse = nh * MM_NOHALFTURNS + (1-nh) * MM_ALLMOVES; 144 arg->movemask_inverse = nh * MM18_NOHALFTURNS + (1-nh) * MM18_ALLMOVES;
145 145
146 return false; 146 return false;
147} 147}
@@ -151,7 +151,7 @@ solve_h48_dfs(dfsarg_solve_h48_t arg[static 1])
151{ 151{
152 int64_t ret, n; 152 int64_t ret, n;
153 uint8_t m, nm, lbn, lbi; 153 uint8_t m, nm, lbn, lbi;
154 uint32_t mm_normal, mm_inverse; 154 uint64_t mm_normal, mm_inverse;
155 bool ulbi, ulbn; 155 bool ulbi, ulbn;
156 cube_t backup_cube, backup_inverse; 156 cube_t backup_cube, backup_inverse;
157 157
@@ -191,7 +191,7 @@ solve_h48_dfs(dfsarg_solve_h48_t arg[static 1])
191 if (popcount_u32(mm_normal) <= popcount_u32(mm_inverse)) { 191 if (popcount_u32(mm_normal) <= popcount_u32(mm_inverse)) {
192 arg->solution_moves->nmoves++; 192 arg->solution_moves->nmoves++;
193 for (m = 0; m < 18; m++) { 193 for (m = 0; m < 18; m++) {
194 if (!(mm_normal & (UINT32_C(1) << (uint32_t)m))) 194 if (!(mm_normal & MM_SINGLE(m)))
195 continue; 195 continue;
196 arg->solution_moves->moves[ 196 arg->solution_moves->moves[
197 arg->solution_moves->nmoves-1] = m; 197 arg->solution_moves->nmoves-1] = m;
@@ -209,7 +209,7 @@ solve_h48_dfs(dfsarg_solve_h48_t arg[static 1])
209 } else { 209 } else {
210 arg->solution_moves->npremoves++; 210 arg->solution_moves->npremoves++;
211 for (m = 0; m < 18; m++) { 211 for (m = 0; m < 18; m++) {
212 if(!(mm_inverse & (UINT32_C(1) << (uint32_t)m))) 212 if(!(mm_inverse & MM_SINGLE(m)))
213 continue; 213 continue;
214 arg->solution_moves->premoves[ 214 arg->solution_moves->premoves[
215 arg->solution_moves->npremoves-1] = m; 215 arg->solution_moves->npremoves-1] = m;
@@ -258,8 +258,8 @@ solve_h48_runthread(void *arg)
258 dfsarg->lb_inverse = 0; 258 dfsarg->lb_inverse = 0;
259 dfsarg->use_lb_normal = false; 259 dfsarg->use_lb_normal = false;
260 dfsarg->use_lb_inverse = false; 260 dfsarg->use_lb_inverse = false;
261 dfsarg->movemask_normal = MM_ALLMOVES; 261 dfsarg->movemask_normal = MM18_ALLMOVES;
262 dfsarg->movemask_inverse = MM_ALLMOVES; 262 dfsarg->movemask_inverse = MM18_ALLMOVES;
263 263
264 solve_h48_dfs(dfsarg); 264 solve_h48_dfs(dfsarg);
265 } 265 }
@@ -278,7 +278,7 @@ solve_h48_maketasks(
278 int r; 278 int r;
279 int64_t appret; 279 int64_t appret;
280 uint8_t m, t; 280 uint8_t m, t;
281 uint32_t mm; 281 uint64_t mm;
282 cube_t backup_cube; 282 cube_t backup_cube;
283 solution_moves_t moves; 283 solution_moves_t moves;
284 284
@@ -308,7 +308,7 @@ solve_h48_maketasks(
308 } 308 }
309 309
310 if (maketasks_arg->nmoves == 0) { 310 if (maketasks_arg->nmoves == 0) {
311 mm = MM_ALLMOVES; 311 mm = MM18_ALLMOVES;
312 } else { 312 } else {
313 m = maketasks_arg->moves[maketasks_arg->nmoves-1]; 313 m = maketasks_arg->moves[maketasks_arg->nmoves-1];
314 mm = allowedmask[movebase(m)]; 314 mm = allowedmask[movebase(m)];
@@ -317,7 +317,7 @@ solve_h48_maketasks(
317 maketasks_arg->nmoves++; 317 maketasks_arg->nmoves++;
318 backup_cube = maketasks_arg->cube; 318 backup_cube = maketasks_arg->cube;
319 for (m = 0; m < 18; m++) { 319 for (m = 0; m < 18; m++) {
320 if (!(mm & (1 << m))) 320 if (!(mm & MM_SINGLE(m)))
321 continue; 321 continue;
322 maketasks_arg->moves[maketasks_arg->nmoves-1] = m; 322 maketasks_arg->moves[maketasks_arg->nmoves-1] = m;
323 maketasks_arg->cube = move(backup_cube, m); 323 maketasks_arg->cube = move(backup_cube, m);
@@ -330,9 +330,8 @@ solve_h48_maketasks(
330 if (maketasks_arg->nmoves == 1) 330 if (maketasks_arg->nmoves == 1)
331 for (t = 0; t < NTRANS; t++) 331 for (t = 0; t < NTRANS; t++)
332 if (solve_arg->solution_settings->tmask & 332 if (solve_arg->solution_settings->tmask &
333 (UINT64_C(1) << (uint64_t)t)) 333 TM_SINGLE(t))
334 mm &= ~(UINT32_C(1) << 334 mm &= ~MM_SINGLE(transform_move(m, t));
335 (uint32_t)transform_move(m, t));
336 } 335 }
337 maketasks_arg->nmoves--; 336 maketasks_arg->nmoves--;
338 maketasks_arg->cube = backup_cube; 337 maketasks_arg->cube = backup_cube;

Generated with cgit - Back to sebastiano.tronto.net