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 fde8dfa9df8df1e3d42a9a8840836e33817cd498
parent 6ec2e7d5413eda0671a20a0069aa8d89d8117c0a
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Sun, 26 May 2024 22:13:47 +0200

Added tests for selfsim

Diffstat:
Atest/101_cocsep_selfsim/00_all.in | 2++
Atest/101_cocsep_selfsim/00_all.out | 2++
Atest/101_cocsep_selfsim/cocsep_selfsim_tests.c | 40++++++++++++++++++++++++++++++++++++++++
3 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/test/101_cocsep_selfsim/00_all.in b/test/101_cocsep_selfsim/00_all.in @@ -0,0 +1,2 @@ +UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 +UF0 UB0 DB0 DF0 FR0 UL0 DL0 BR0 DR0 FL0 BL0 UR0 DFR2 UBL0 DFL0 UBR2 UFL0 UFR1 DBR1 DBL0 diff --git a/test/101_cocsep_selfsim/00_all.out b/test/101_cocsep_selfsim/00_all.out @@ -0,0 +1,2 @@ +0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 +0 1 2 3 24 25 26 27 diff --git a/test/101_cocsep_selfsim/cocsep_selfsim_tests.c b/test/101_cocsep_selfsim/cocsep_selfsim_tests.c @@ -0,0 +1,40 @@ +/* + * This test is tricky, we only have two cases for now: the solved cube + * and the cube that is one quarter-turn-move off (all such cases are + * equivalent due to symmetry). Adding more tests requires figuring out + * by hand which one is the first position in its class to be reached. + * Note that the .out file need a space before each newline. + */ +#include "../test.h" + +#define COCSEP_CLASSES 3393U + +size_t gendata_cocsep(void *, uint64_t *, cube_fast_t *); +int64_t coord_fast_cocsep(cube_fast_t); + +int main(void) { + char str[STRLENMAX]; + uint32_t buf[300000], data; + int64_t coord, coclass; + uint64_t selfsim[COCSEP_CLASSES], sim, t; + cube_fast_t fast, rep[COCSEP_CLASSES]; + + gendata_cocsep(buf, selfsim, rep); + + /* All cases in the same test so we do not generate data many times */ + + while (fgets(str, STRLENMAX, stdin) != NULL) { + fast = cubetofast(readcube("H48", str)); + coord = coord_fast_cocsep(fast); + data = buf[coord]; + coclass = (data & (0xFFFU << 16U)) >> 16U; + sim = selfsim[coclass]; + for (t = 0; t < 48 && sim; t++, sim >>= 1ULL) { + if (sim & 1ULL) + printf("%" PRId64 " ", t); + } + printf("\n"); + } + + return 0; +}