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 c0aa77e610366e60f7ecf70db481d8d2cfb66c35
parent 11a966eeb4fcd88e251fb9d77a18d6b67c36dd61
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Wed, 18 Sep 2024 10:15:06 +0200

Renamed gen_48_short -> gendata_h48_short

Diffstat:
Msrc/solvers/h48/gendata_h48.h | 6+++---
Dtest/112_gen_h48short/gen_h48short_tests.c | 88-------------------------------------------------------------------------------
Rtest/112_gen_h48short/00_depth_1.in -> test/112_gendata_h48short/00_depth_1.in | 0
Rtest/112_gen_h48short/00_depth_1.out -> test/112_gendata_h48short/00_depth_1.out | 0
Rtest/112_gen_h48short/01_depth_3.in -> test/112_gendata_h48short/01_depth_3.in | 0
Rtest/112_gen_h48short/01_depth_3.out -> test/112_gendata_h48short/01_depth_3.out | 0
Atest/112_gendata_h48short/gendata_h48short_tests.c | 88+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 91 insertions(+), 91 deletions(-)

diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h @@ -76,7 +76,7 @@ typedef struct { uint64_t *count; } h48k2_dfs_arg_t; -STATIC uint64_t gen_h48short(gendata_h48short_arg_t *); +STATIC uint64_t gendata_h48short(gendata_h48short_arg_t *); STATIC size_t gendata_h48(gendata_h48_arg_t *); STATIC size_t gendata_h48h0k4(gendata_h48_arg_t *); STATIC int64_t gendata_h48h0k4_bfs(h48h0k4_bfs_arg_t *); @@ -96,7 +96,7 @@ STATIC_INLINE void set_h48_pval(uint8_t *, int64_t, uint8_t, uint8_t); STATIC_INLINE uint8_t get_h48_bound(cube_t, uint32_t, uint8_t, uint8_t, uint8_t *); STATIC uint64_t -gen_h48short(gendata_h48short_arg_t *arg) +gendata_h48short(gendata_h48short_arg_t *arg) { uint8_t i, m; int64_t coord; @@ -368,7 +368,7 @@ gendata_h48k2(gendata_h48_arg_t *arg) .selfsim = arg->selfsim, .map = &shortcubes }; - nshort = gen_h48short(&shortarg); + nshort = gendata_h48short(&shortarg); LOG("Cubes in <= %" PRIu8 " moves: %" PRIu64 "\n", shortdepth, nshort); selectedbase = base[arg->h]; diff --git a/test/112_gen_h48short/gen_h48short_tests.c b/test/112_gen_h48short/gen_h48short_tests.c @@ -1,88 +0,0 @@ -#include "../test.h" - -#define COCSEP_CLASSES 3393 -#define INFOSIZE 512 -#define MAXPOS 200 - -typedef struct { - uint64_t n; - uint64_t capacity; - uint64_t randomizer; - uint64_t *table; - uint32_t *info; - uint32_t *cocsepdata; - uint32_t *h48data; - uint64_t selfsim[COCSEP_CLASSES]; - cube_t crep[COCSEP_CLASSES]; -} h48map_t; - -typedef struct { - uint64_t key; - uint64_t val; -} kvpair_t; - -typedef struct { - uint8_t maxdepth; - const uint32_t *cocsepdata; - const cube_t *crep; - const uint64_t *selfsim; - h48map_t *map; -} gendata_h48short_arg_t; - -void h48map_create(h48map_t *, uint64_t, uint64_t); -void h48map_destroy(h48map_t *); -kvpair_t h48map_nextkvpair(h48map_t *, uint64_t *); -size_t gendata_cocsep(void *, uint64_t *, cube_t *); -uint64_t gen_h48short(gendata_h48short_arg_t *); - -char str[STRLENMAX]; - -int compare(const void *x, const void *y) { - uint64_t a = ((kvpair_t *)x)->key; - uint64_t b = ((kvpair_t *)y)->key; - - if (a > b) return 1; - if (a == b) return 0; - return -1; -} - -uint64_t readl(void) { - fgets(str, STRLENMAX, stdin); - return atoll(str); -} - -void run(void) { - char buf[2000000]; - h48map_t map; - uint64_t i, j, capacity, randomizer, selfsim[COCSEP_CLASSES]; - kvpair_t kv, b[MAXPOS]; - gendata_h48short_arg_t arg; - cube_t crep[COCSEP_CLASSES]; - - capacity = readl(); - randomizer = readl(); - arg.maxdepth = readl(); - arg.crep = crep; - arg.selfsim = selfsim; - arg.map = &map; - - h48map_create(&map, capacity, randomizer); - gendata_cocsep(buf, selfsim, crep); - arg.cocsepdata = (uint32_t *)((char *)buf + INFOSIZE); - gen_h48short(&arg); - - i = 0; - for (kv = h48map_nextkvpair(&map, &i), j = 0; - i != map.capacity && j < MAXPOS; - kv = h48map_nextkvpair(&map, &i) - ) { - b[j++] = kv; - } - qsort(b, j, sizeof(kvpair_t), compare); - - printf("%" PRIu64 "\n", map.n); - for (i = 0; i < j; i++) - printf("%" PRIu64 " %" PRIu64 "\n", b[i].key, b[i].val); - - h48map_destroy(&map); -} diff --git a/test/112_gen_h48short/00_depth_1.in b/test/112_gendata_h48short/00_depth_1.in diff --git a/test/112_gen_h48short/00_depth_1.out b/test/112_gendata_h48short/00_depth_1.out diff --git a/test/112_gen_h48short/01_depth_3.in b/test/112_gendata_h48short/01_depth_3.in diff --git a/test/112_gen_h48short/01_depth_3.out b/test/112_gendata_h48short/01_depth_3.out diff --git a/test/112_gendata_h48short/gendata_h48short_tests.c b/test/112_gendata_h48short/gendata_h48short_tests.c @@ -0,0 +1,88 @@ +#include "../test.h" + +#define COCSEP_CLASSES 3393 +#define INFOSIZE 512 +#define MAXPOS 200 + +typedef struct { + uint64_t n; + uint64_t capacity; + uint64_t randomizer; + uint64_t *table; + uint32_t *info; + uint32_t *cocsepdata; + uint32_t *h48data; + uint64_t selfsim[COCSEP_CLASSES]; + cube_t crep[COCSEP_CLASSES]; +} h48map_t; + +typedef struct { + uint64_t key; + uint64_t val; +} kvpair_t; + +typedef struct { + uint8_t maxdepth; + const uint32_t *cocsepdata; + const cube_t *crep; + const uint64_t *selfsim; + h48map_t *map; +} gendata_h48short_arg_t; + +void h48map_create(h48map_t *, uint64_t, uint64_t); +void h48map_destroy(h48map_t *); +kvpair_t h48map_nextkvpair(h48map_t *, uint64_t *); +size_t gendata_cocsep(void *, uint64_t *, cube_t *); +uint64_t gendata_h48short(gendata_h48short_arg_t *); + +char str[STRLENMAX]; + +int compare(const void *x, const void *y) { + uint64_t a = ((kvpair_t *)x)->key; + uint64_t b = ((kvpair_t *)y)->key; + + if (a > b) return 1; + if (a == b) return 0; + return -1; +} + +uint64_t readl(void) { + fgets(str, STRLENMAX, stdin); + return atoll(str); +} + +void run(void) { + char buf[2000000]; + h48map_t map; + uint64_t i, j, capacity, randomizer, selfsim[COCSEP_CLASSES]; + kvpair_t kv, b[MAXPOS]; + gendata_h48short_arg_t arg; + cube_t crep[COCSEP_CLASSES]; + + capacity = readl(); + randomizer = readl(); + arg.maxdepth = readl(); + arg.crep = crep; + arg.selfsim = selfsim; + arg.map = &map; + + h48map_create(&map, capacity, randomizer); + gendata_cocsep(buf, selfsim, crep); + arg.cocsepdata = (uint32_t *)((char *)buf + INFOSIZE); + gendata_h48short(&arg); + + i = 0; + for (kv = h48map_nextkvpair(&map, &i), j = 0; + i != map.capacity && j < MAXPOS; + kv = h48map_nextkvpair(&map, &i) + ) { + b[j++] = kv; + } + qsort(b, j, sizeof(kvpair_t), compare); + + printf("%" PRIu64 "\n", map.n); + for (i = 0; i < j; i++) + printf("%" PRIu64 " %" PRIu64 "\n", b[i].key, b[i].val); + + h48map_destroy(&map); +}