diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/cube_transform_with_switch.h | 6 | ||||
| -rw-r--r-- | src/solve_h48.h | 73 |
2 files changed, 52 insertions, 27 deletions
diff --git a/src/cube_transform_with_switch.h b/src/cube_transform_with_switch.h index 45e1d64..18c1c8c 100644 --- a/src/cube_transform_with_switch.h +++ b/src/cube_transform_with_switch.h | |||
| @@ -118,7 +118,7 @@ transform_edges(cube_t c, uint8_t t) | |||
| 118 | case _trans_BLm: | 118 | case _trans_BLm: |
| 119 | return _trans_edges_mirrored(BLm, c); | 119 | return _trans_edges_mirrored(BLm, c); |
| 120 | default: | 120 | default: |
| 121 | LOG("transform error, unknown transformation\n"); | 121 | LOG("transform error, unknown transformation %" PRIu8 "\n", t); |
| 122 | return zero; | 122 | return zero; |
| 123 | } | 123 | } |
| 124 | } | 124 | } |
| @@ -224,7 +224,7 @@ transform_corners(cube_t c, uint8_t t) | |||
| 224 | case _trans_BLm: | 224 | case _trans_BLm: |
| 225 | return _trans_corners_mirrored(BLm, c); | 225 | return _trans_corners_mirrored(BLm, c); |
| 226 | default: | 226 | default: |
| 227 | LOG("transform error, unknown transformation\n"); | 227 | LOG("transform error, unknown transformation %" PRIu8 "\n", t); |
| 228 | return zero; | 228 | return zero; |
| 229 | } | 229 | } |
| 230 | } | 230 | } |
| @@ -330,7 +330,7 @@ transform(cube_t c, uint8_t t) | |||
| 330 | case _trans_BLm: | 330 | case _trans_BLm: |
| 331 | return _trans_mirrored(BLm, c); | 331 | return _trans_mirrored(BLm, c); |
| 332 | default: | 332 | default: |
| 333 | LOG("transform error, unknown transformation\n"); | 333 | LOG("transform error, unknown transformation %" PRIu8 "\n", t); |
| 334 | return zero; | 334 | return zero; |
| 335 | } | 335 | } |
| 336 | } | 336 | } |
diff --git a/src/solve_h48.h b/src/solve_h48.h index c7cc91c..ad77156 100644 --- a/src/solve_h48.h +++ b/src/solve_h48.h | |||
| @@ -30,7 +30,7 @@ | |||
| 30 | typedef struct { | 30 | typedef struct { |
| 31 | uint64_t n; | 31 | uint64_t n; |
| 32 | uint64_t capacity; | 32 | uint64_t capacity; |
| 33 | uint64_t mod; | 33 | uint64_t randomizer; |
| 34 | uint64_t *table; | 34 | uint64_t *table; |
| 35 | } h48map_t; | 35 | } h48map_t; |
| 36 | 36 | ||
| @@ -112,7 +112,8 @@ _static_inline void set_esep_pval(uint32_t *, int64_t, uint8_t); | |||
| 112 | 112 | ||
| 113 | _static size_t gendata_cocsep(void *, uint64_t *, cube_t *); | 113 | _static size_t gendata_cocsep(void *, uint64_t *, cube_t *); |
| 114 | _static uint32_t gendata_cocsep_dfs(dfsarg_cocsep_t *); | 114 | _static uint32_t gendata_cocsep_dfs(dfsarg_cocsep_t *); |
| 115 | _static int64_t gen_h48map_short(uint8_t, const uint32_t *, h48map_t *); | 115 | _static uint64_t gen_h48short( |
| 116 | uint8_t, const uint32_t *, const cube_t *, const uint64_t *, h48map_t *); | ||
| 116 | _static size_t gendata_h48h0k4(void *, uint8_t); | 117 | _static size_t gendata_h48h0k4(void *, uint8_t); |
| 117 | _static int64_t gendata_h48h0k4_bfs(bfsarg_esep_t *); | 118 | _static int64_t gendata_h48h0k4_bfs(bfsarg_esep_t *); |
| 118 | _static int64_t gendata_h48h0k4_bfs_fromdone(bfsarg_esep_t *); | 119 | _static int64_t gendata_h48h0k4_bfs_fromdone(bfsarg_esep_t *); |
| @@ -123,16 +124,17 @@ _static_inline int8_t get_h48_cdata(cube_t, uint32_t *, uint32_t *); | |||
| 123 | _static_inline int8_t get_h48_bound(cube_t, uint32_t, uint8_t, uint32_t *); | 124 | _static_inline int8_t get_h48_bound(cube_t, uint32_t, uint8_t, uint32_t *); |
| 124 | _static_inline bool solve_h48_stop(dfsarg_solveh48_t *); | 125 | _static_inline bool solve_h48_stop(dfsarg_solveh48_t *); |
| 125 | _static int64_t solve_h48_dfs(dfsarg_solveh48_t *); | 126 | _static int64_t solve_h48_dfs(dfsarg_solveh48_t *); |
| 126 | _static int64_t solve_h48(cube_t, int8_t, int8_t, int8_t, uint8_t, const void *, char *); | 127 | _static int64_t solve_h48( |
| 128 | cube_t, int8_t, int8_t, int8_t, uint8_t, const void *, char *); | ||
| 127 | 129 | ||
| 128 | _static int64_t solve_h48stats_dfs(dfsarg_solveh48stats_t *); | 130 | _static int64_t solve_h48stats_dfs(dfsarg_solveh48stats_t *); |
| 129 | _static int64_t solve_h48stats(cube_t, int8_t, const void *, char [static 12]); | 131 | _static int64_t solve_h48stats(cube_t, int8_t, const void *, char [static 12]); |
| 130 | 132 | ||
| 131 | _static void | 133 | _static void |
| 132 | h48map_create(h48map_t *map, uint64_t capacity, uint64_t mod) | 134 | h48map_create(h48map_t *map, uint64_t capacity, uint64_t randomizer) |
| 133 | { | 135 | { |
| 134 | map->capacity = capacity; | 136 | map->capacity = capacity; |
| 135 | map->mod = mod; | 137 | map->randomizer = randomizer; |
| 136 | 138 | ||
| 137 | map->table = malloc(map->capacity * sizeof(int64_t)); | 139 | map->table = malloc(map->capacity * sizeof(int64_t)); |
| 138 | h48map_clear(map); | 140 | h48map_clear(map); |
| @@ -156,7 +158,7 @@ h48map_lookup(h48map_t *map, uint64_t x) | |||
| 156 | { | 158 | { |
| 157 | uint64_t hash, i; | 159 | uint64_t hash, i; |
| 158 | 160 | ||
| 159 | hash = ((x % map->capacity) * map->mod) % map->capacity; | 161 | hash = ((x % map->capacity) * map->randomizer) % map->capacity; |
| 160 | for (i = hash; | 162 | for (i = hash; |
| 161 | map->table[i] != MAP_UNSET && (map->table[i] & MAP_KEYMASK) != x; | 163 | map->table[i] != MAP_UNSET && (map->table[i] & MAP_KEYMASK) != x; |
| 162 | i = (i+1) % map->capacity | 164 | i = (i+1) % map->capacity |
| @@ -384,32 +386,55 @@ gendata_cocsep_dfs(dfsarg_cocsep_t *arg) | |||
| 384 | return cc; | 386 | return cc; |
| 385 | } | 387 | } |
| 386 | 388 | ||
| 387 | _static int64_t | 389 | _static uint64_t |
| 388 | gen_h48map_short(uint8_t n, const uint32_t *cocsepdata, h48map_t *map) | 390 | gen_h48short( |
| 389 | { | 391 | uint8_t n, |
| 390 | /* | 392 | const uint32_t *cocsepdata, |
| 391 | uint8_t i, j, m; | 393 | const cube_t *crep, |
| 392 | int64_t coord; | 394 | const uint64_t *selfsim, |
| 393 | cube_t cube, d; | 395 | h48map_t *map |
| 396 | ) { | ||
| 397 | uint8_t i, m, t; | ||
| 398 | int64_t coord, cc; | ||
| 399 | uint64_t j, oldn, sim; | ||
| 400 | kvpair_t kv; | ||
| 401 | cube_t cube, d, e; | ||
| 394 | 402 | ||
| 395 | cube = solvedcube(); | 403 | cube = solvedcube(); |
| 396 | coord = coord_h48(cube, cocsepdata, 11); | 404 | coord = coord_h48(cube, cocsepdata, 11); |
| 405 | h48map_insertmin(map, coord, 0); | ||
| 406 | oldn = 0; | ||
| 407 | LOG("Short h48: generating depth 0\nfound %" PRIu8 "\n", map->n-oldn); | ||
| 397 | for (i = 0; i < n; i++) { | 408 | for (i = 0; i < n; i++) { |
| 398 | for (j = 0; (coord = h48map_next(map, &j)) != -1; ) { | 409 | LOG("Short h48: generating depth %" PRIu8 "\n", i+1); |
| 399 | cube = invcoord_h48(coord, cocsepdata, 11); | 410 | j = 0; |
| 411 | oldn = map->n; | ||
| 412 | for (kv = h48map_nextkvpair(map, &j); | ||
| 413 | j != map->capacity; | ||
| 414 | kv = h48map_nextkvpair(map, &j) | ||
| 415 | ) { | ||
| 416 | if (kv.val != i) | ||
| 417 | continue; | ||
| 418 | cube = invcoord_h48(kv.key, crep, 11); | ||
| 400 | for (m = 0; m < 18; m++) { | 419 | for (m = 0; m < 18; m++) { |
| 401 | d = move(cube, m); | 420 | d = move(cube, m); |
| 402 | TODO | 421 | coord = coord_h48(d, cocsepdata, 11); |
| 422 | h48map_insertmin(map, coord, i+1); | ||
| 423 | cc = coord / H48_ESIZE(11); | ||
| 424 | sim = selfsim[cc] >> UINT64_C(1); | ||
| 425 | for (t = 1; t < 48 && sim; t++) { | ||
| 426 | /* TODO: optimize by using transform_edges, | ||
| 427 | corner coordinate is kept */ | ||
| 428 | e = transform(d, t); | ||
| 429 | coord = coord_h48(e, cocsepdata, 11); | ||
| 430 | h48map_insertmin(map, coord, i+1); | ||
| 431 | } | ||
| 403 | } | 432 | } |
| 404 | } | 433 | } |
| 434 | LOG("found %" PRIu8 "\n", map->n-oldn); | ||
| 405 | } | 435 | } |
| 406 | */ | ||
| 407 | } | ||
| 408 | 436 | ||
| 409 | _static int64_t | 437 | return map->n; |
| 410 | gen_h48set_short_dfs(dfsarg_genh48set_t *arg) | ||
| 411 | { | ||
| 412 | /* TODO */ | ||
| 413 | } | 438 | } |
| 414 | 439 | ||
| 415 | /* | 440 | /* |
| @@ -511,7 +536,7 @@ gendata_h48h0k4_bfs_fromdone(bfsarg_esep_t *arg) | |||
| 511 | cc += x != arg->depth; | 536 | cc += x != arg->depth; |
| 512 | cocsep_coord = j / H48_ESIZE(0); | 537 | cocsep_coord = j / H48_ESIZE(0); |
| 513 | sim = arg->selfsim[cocsep_coord] >> UINT64_C(1); | 538 | sim = arg->selfsim[cocsep_coord] >> UINT64_C(1); |
| 514 | for (t = 1; t < 48 && sim; t++, sim >>= UINT64_C(1)) { | 539 | for (t = 1; t < 48 && sim; t++) { |
| 515 | /* TODO: use only selfsim */ | 540 | /* TODO: use only selfsim */ |
| 516 | transd = transform(moved, t); | 541 | transd = transform(moved, t); |
| 517 | k = coord_h48(transd, arg->cocsepdata, 0); | 542 | k = coord_h48(transd, arg->cocsepdata, 0); |
| @@ -553,7 +578,7 @@ neighbor_found: | |||
| 553 | cc++; | 578 | cc++; |
| 554 | cocsep_coord = i / H48_ESIZE(0); | 579 | cocsep_coord = i / H48_ESIZE(0); |
| 555 | sim = arg->selfsim[cocsep_coord] >> 1; | 580 | sim = arg->selfsim[cocsep_coord] >> 1; |
| 556 | for (t = 1; t < 48 && sim; t++, sim >>= 1) { | 581 | for (t = 1; t < 48 && sim; t++) { |
| 557 | /* TODO: use only selfsim */ | 582 | /* TODO: use only selfsim */ |
| 558 | transd = transform(cube, t); | 583 | transd = transform(cube, t); |
| 559 | j = coord_h48(transd, arg->cocsepdata, 0); | 584 | j = coord_h48(transd, arg->cocsepdata, 0); |
