h48

A prototype for an optimal Rubik's cube solver, work in progress.
git clone https://git.tronto.net/h48
Download | Log | Files | Refs | README | LICENSE

commit 3d060c348fdfff074a9b902d56f539664789d831
parent 67c35b638c04ab7a860aac0c166936e9481633c9
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Mon, 15 Jul 2024 11:15:35 +0200

Solved bug in cocsep generation

Diffstat:
MTODO.txt | 30+++++++++---------------------
Msrc/solve_h48.h | 29++---------------------------
Mtest/103_cocsep_selfsim_distribution/00_all.out | 22+++++++++++-----------
Mtest/111_gendata_h48_h0/00_h_0.out | 4++--
4 files changed, 24 insertions(+), 61 deletions(-)

diff --git a/TODO.txt b/TODO.txt @@ -1,30 +1,14 @@ -Bug in cocsepdata - - Add tests for ttrep - - check that ttrep indeed brings to representative - - Fix? - - Once fixed, fix other tests - - maybe add longtest, e.g. as a tool? - - Clean up mixed bfs fromdone / fromnew, use as new for h0k4 +Bug in esep table generation - Re-do stats - -Check stats for all tables using H48stats solver + - Add long-running test for h0k4 (maybe as a tool?) - try DFS for h0 solver - - compare results, the bfs method could be wrong - - if faster: remove bfs - - if slower: why do I get different results with the new bfs? + - use dfs for computing big table, save distance %3 until the last two steps, + then clean the table and double loop over moves to fill the value + - dfs for tables with h=1 to 10? -Bug in esep table generation - Fails for UFRUFU, try command ./run solve -solver H48 -options "2;20" -n 1 -M 10 -cube \ "$(./run frommoves -moves "UFRUFU")" - - Fundamental error in how tables are generated, each coordinate has too - many representative. I need to use the big table with the full coordinate - first (h=11, ~241 billion positions, 60Gb with k=2). From this the smaller - tables can be easily deduced. - - Investigate the possibility of computing smaller tables directly in some - other way, even if slow. - - use dfs for computing big table, save distance %3 until the last two steps, - then clean the table and double loop over moves to fill the value Solver - cleanup h48 solver @@ -118,6 +102,10 @@ switch. Here NISS may be useful. * see if vcube's method to flip all corners is better * find a better way for computing the inverse? * Transform with big table: make static cube actually static (how?) +* Use selfsim: in generating some tables, it is in thery possible to only check + the few transformations that give self-similarity instead of all 48. + The performance drop is almost insignificant, but I would like to figure out + the mistake I made previously. ## Improvements and other things diff --git a/src/solve_h48.h b/src/solve_h48.h @@ -422,16 +422,10 @@ gendata_h48h0k4_return_size: _static int64_t gendata_h48h0k4_bfs(bfsarg_esep_t *arg) { -/* -TODO: the new method gives a slightly different answer. If the new -method is correct, then the old bfs method is wrong. Which one is it? -Try also DFS and compare results (it could be faster). -*/ if (2 * arg->done < (int64_t)ESEP_MAX(0)) return gendata_h48h0k4_bfs_fromdone(arg); else return gendata_h48h0k4_bfs_fromnew(arg); -// return gendata_h48h0k4_bfs_fromnew(arg); } _static int64_t @@ -464,22 +458,7 @@ gendata_h48h0k4_bfs_fromdone(bfsarg_esep_t *arg) cocsep_coord = j / H48_ESIZE(0); sim = arg->selfsim[cocsep_coord] >> UINT64_C(1); for (t = 1; t < 48 && sim; t++, sim >>= UINT64_C(1)) { - if (!(sim & UINT64_C(1))) { - transd = transform(moved, t); - k = coord_h48(transd, arg->cocsepdata, 0); - if (k != j) { -/* -LOG("t=%" PRId64 ", tinv=%" PRIu8 "\n", t, inverse_trans(t)); -int64_t ccm = coord_cocsep(moved); -int64_t repm = coord_cocsep(arg->crep[j/H48_ESIZE(0)]); -LOG("moved: full %" PRId64 ", cocsep %" PRId64 ", rep %" PRId64 ", ttrep %" PRId32 "\n", j, ccm, repm, TTREP(arg->cocsepdata[ccm])); -int64_t cct = coord_cocsep(transd); -int64_t rept = coord_cocsep(arg->crep[k/H48_ESIZE(0)]); -LOG("moved: full %" PRId64 ", cocsep %" PRId64 ", rep %" PRId64 ", ttrep %" PRId32 "\n", j, cct, rept, TTREP(arg->cocsepdata[cct])); -*/ - } - continue; - } + /* TODO: use only selfsim */ transd = transform(moved, t); k = coord_h48(transd, arg->cocsepdata, 0); x = get_esep_pval(arg->buf32, k); @@ -512,10 +491,7 @@ gendata_h48h0k4_bfs_fromnew(bfsarg_esep_t *arg) j = coord_h48(moved, arg->cocsepdata, 0); x = get_esep_pval(arg->buf32, j); if (x < arg->depth) -{ -if (x < arg->depth -1) LOG("WAT %" PRIu8 " while scanning %" PRIu8 "\n",x, arg->depth); goto neighbor_found; -} } continue; neighbor_found: @@ -524,8 +500,7 @@ neighbor_found: cocsep_coord = i / H48_ESIZE(0); sim = arg->selfsim[cocsep_coord] >> 1; for (t = 1; t < 48 && sim; t++, sim >>= 1) { - if (!(sim & 1)) - continue; + /* TODO: use only selfsim */ transd = transform(cube, t); j = coord_h48(transd, arg->cocsepdata, 0); x = get_esep_pval(arg->buf32, j); diff --git a/test/103_cocsep_selfsim_distribution/00_all.out b/test/103_cocsep_selfsim_distribution/00_all.out @@ -1,12 +1,12 @@ 373 self-similar positions out of 3393 -Size number of groups -1 3020 -2 311 -3 8 -4 35 -6 9 -8 6 -12 1 -16 1 -24 1 -48 1 +Size number of groups +1 3020 +2 311 +3 8 +4 35 +6 9 +8 6 +12 1 +16 1 +24 1 +48 1 diff --git a/test/111_gendata_h48_h0/00_h_0.out b/test/111_gendata_h48_h0/00_h_0.out @@ -19,5 +19,5 @@ h48: 1: 1 2: 4 3: 34 -4: 329 -5: 3587 +4: 331 +5: 3612