aboutsummaryrefslogtreecommitdiff
path: root/src/solvers
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-08-30 08:37:47 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-08-30 08:37:47 +0200
commitf485257cf50082a0d639dafe7b2e5dcd37866bb4 (patch)
tree4a4982c0085822f1ba4052d574ef8698a951da63 /src/solvers
parenta7444e9ab414e1eb73451a806289a3f7c4f02047 (diff)
parent0d958f66cf44e431bfa92a81c73a9bf3046f0aac (diff)
downloadnissy-core-f485257cf50082a0d639dafe7b2e5dcd37866bb4.tar.gz
nissy-core-f485257cf50082a0d639dafe7b2e5dcd37866bb4.zip
Merge branch 'master' of tronto.net:h48
Diffstat (limited to 'src/solvers')
-rw-r--r--src/solvers/h48/gendata_cocsep.h2
-rw-r--r--src/solvers/h48/gendata_h48.h25
2 files changed, 13 insertions, 14 deletions
diff --git a/src/solvers/h48/gendata_cocsep.h b/src/solvers/h48/gendata_cocsep.h
index 0f96da9..b7d28e1 100644
--- a/src/solvers/h48/gendata_cocsep.h
+++ b/src/solvers/h48/gendata_cocsep.h
@@ -135,7 +135,7 @@ gendata_cocsep_dfs(cocsep_dfs_arg_t *arg)
135 return cc; 135 return cc;
136 } 136 }
137 137
138 memcpy(&nextarg, arg, sizeof(cocsep_dfs_arg_t)); 138 nextarg = *arg;
139 nextarg.depth++; 139 nextarg.depth++;
140 for (m = 0, cc = 0; m < 18; m++) { 140 for (m = 0, cc = 0; m < 18; m++) {
141 nextarg.cube = move(arg->cube, m); 141 nextarg.cube = move(arg->cube, m);
diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h
index fbb8b35..2fd76ee 100644
--- a/src/solvers/h48/gendata_h48.h
+++ b/src/solvers/h48/gendata_h48.h
@@ -333,7 +333,7 @@ gendata_h48k2(gendata_h48_arg_t *arg)
333 .base = base[arg->h], 333 .base = base[arg->h],
334 .depth = shortdepth, 334 .depth = shortdepth,
335 .shortdepth = shortdepth, 335 .shortdepth = shortdepth,
336 .maxdepth = arg->maxdepth, 336 .maxdepth = _min(arg->maxdepth, base[arg->h]+2),
337 .cocsepdata = arg->cocsepdata, 337 .cocsepdata = arg->cocsepdata,
338 .h48data = arg->h48data, 338 .h48data = arg->h48data,
339 .selfsim = arg->selfsim, 339 .selfsim = arg->selfsim,
@@ -358,7 +358,7 @@ int jj = 0;
358 gendata_h48k2_dfs(&dfsarg); 358 gendata_h48k2_dfs(&dfsarg);
359 ) 359 )
360#endif 360#endif
361if ((++jj) % 1000 == 0) LOG("Done %d distance 8 cubes\n", jj); 361if ((++jj) % 100000 == 0) LOG("Done %d distance 8 cubes\n", jj);
362 } 362 }
363 363
364 h48map_destroy(&shortcubes); 364 h48map_destroy(&shortcubes);
@@ -377,30 +377,29 @@ gendata_h48k2_return_size:
377_static void 377_static void
378gendata_h48k2_dfs(h48k2_dfs_arg_t *arg) 378gendata_h48k2_dfs(h48k2_dfs_arg_t *arg)
379{ 379{
380 bool toodeep, backtracked;
380 uint8_t nmoves, oldval, newval; 381 uint8_t nmoves, oldval, newval;
381 uint64_t val; 382 uint64_t mval;
382 int64_t coord, fullcoord; 383 int64_t coord, fullcoord;
383 h48k2_dfs_arg_t nextarg; 384 h48k2_dfs_arg_t nextarg;
384 uint8_t m; 385 uint8_t m;
385 386
386 fullcoord = coord_h48(arg->cube, arg->cocsepdata, 11); 387 fullcoord = coord_h48(arg->cube, arg->cocsepdata, 11);
387 coord = fullcoord >> (int64_t)(11 - arg->h); 388 coord = fullcoord >> (int64_t)(11 - arg->h);
389 mval = h48map_value(arg->shortcubes, fullcoord);
388 390
389 val = h48map_value(arg->shortcubes, fullcoord); 391 oldval = get_esep_pval(arg->h48data, coord, arg->k);
392 newval = arg->depth >= arg->base ? arg->depth - arg->base : 0;
393 set_esep_pval(arg->h48data, coord, arg->k, _min(oldval, newval));
390 394
391 if (arg->depth >= arg->base && arg->depth <= arg->base + 2) { 395 backtracked = mval <= arg->shortdepth && arg->depth != arg->shortdepth;
392 oldval = get_esep_pval(arg->h48data, coord, arg->k); 396 toodeep = arg->depth >= arg->maxdepth;
393 newval = _min(oldval, arg->depth - arg->base); 397 if (backtracked || toodeep)
394 set_esep_pval(arg->h48data, coord, arg->k, newval);
395 }
396
397 if ((arg->depth > arg->shortdepth && val != MAP_UNSET_VAL) ||
398 (arg->depth >= arg->maxdepth || arg->depth >= arg->base + 2))
399 return; 398 return;
400 399
401 /* TODO: avoid copy, change arg and undo changes after recursion */ 400 /* TODO: avoid copy, change arg and undo changes after recursion */
402 nextarg = *arg; 401 nextarg = *arg;
403 nextarg.depth = arg->depth + 1; 402 nextarg.depth++;
404 nmoves = nextarg.depth - arg->shortdepth; 403 nmoves = nextarg.depth - arg->shortdepth;
405 for (m = 0; m < 18; m++) { 404 for (m = 0; m < 18; m++) {
406 nextarg.moves[nmoves - 1] = m; 405 nextarg.moves[nmoves - 1] = m;

Generated with cgit - Back to sebastiano.tronto.net