diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-11-13 17:13:24 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-11-13 17:13:24 +0100 |
| commit | 1a90075f672a442cafa35c1cccbb6cf026c3980e (patch) | |
| tree | 6b1b89477b984df3873806450f955770d0d850d2 /src | |
| parent | e864e23e3ec315d5969281c51f24521cde30792a (diff) | |
| download | nissy-1a90075f672a442cafa35c1cccbb6cf026c3980e.tar.gz nissy-1a90075f672a442cafa35c1cccbb6cf026c3980e.zip | |
Fixed a problem with htr-drud coordinates. The corresponding pruning table also changed, hopefully the new one is correct.
Diffstat (limited to 'src')
| -rw-r--r-- | src/coord.c | 41 | ||||
| -rw-r--r-- | src/cube.c | 19 | ||||
| -rw-r--r-- | src/cube.h | 1 | ||||
| -rw-r--r-- | src/pruning.c | 1 |
4 files changed, 43 insertions, 19 deletions
diff --git a/src/coord.c b/src/coord.c index 059a7a2..3d5e785 100644 --- a/src/coord.c +++ b/src/coord.c | |||
| @@ -327,9 +327,27 @@ antindex_htr_drud(uint64_t ind) | |||
| 327 | /* The returned cube is NOT consistent: corl and cofb can be wrong */ | 327 | /* The returned cube is NOT consistent: corl and cofb can be wrong */ |
| 328 | /* (see cphtr) and eposm can be wrong too (not epose because dr). */ | 328 | /* (see cphtr) and eposm can be wrong too (not epose because dr). */ |
| 329 | Cube ret = {0}; | 329 | Cube ret = {0}; |
| 330 | static bool initialized = false; | ||
| 331 | static int aux[BINOM8ON4], ep[12], ep2[12]; | ||
| 332 | static int eps_solved[4] = {UL, UR, DL, DR}; | ||
| 333 | unsigned int i, j, k; | ||
| 334 | |||
| 335 | if (!initialized) { | ||
| 336 | for (i = 0; i < BINOM8ON4; i++) { | ||
| 337 | for (j = 0; j < 12; j++) | ||
| 338 | ep[j] = ep2[j] = 0; | ||
| 339 | index_to_subset(i, 8, 4, ep); | ||
| 340 | for (j = 0, k = 0; j < 8; j++) | ||
| 341 | ep2[j] = ep[j/2+4*(j%2)] ? eps_solved[k++] : 0; | ||
| 342 | aux[i] = array_ep_to_epos(ep2, eps_solved); | ||
| 343 | } | ||
| 344 | |||
| 345 | initialized = true; | ||
| 346 | } | ||
| 330 | 347 | ||
| 331 | ret = antindex_cphtr(ind / BINOM8ON4); | 348 | ret = antindex_cphtr(ind / BINOM8ON4); |
| 332 | ret.eposs = (ind % BINOM8ON4) * FACTORIAL4; | 349 | ret.epose = 0; |
| 350 | ret.eposs = aux[ind % BINOM8ON4]; | ||
| 333 | 351 | ||
| 334 | return ret; | 352 | return ret; |
| 335 | } | 353 | } |
| @@ -437,8 +455,25 @@ index_drud_eofb(Cube cube) | |||
| 437 | static uint64_t | 455 | static uint64_t |
| 438 | index_htr_drud(Cube cube) | 456 | index_htr_drud(Cube cube) |
| 439 | { | 457 | { |
| 440 | return index_cphtr(cube) * BINOM8ON4 + | 458 | static bool initialized = false; |
| 441 | (cube.eposs / FACTORIAL4) % BINOM8ON4; | 459 | static int aux[BINOM12ON4], ep[12], ep2[12]; |
| 460 | static int eps_solved[4] = {UL, UR, DL, DR}; | ||
| 461 | unsigned int i, j; | ||
| 462 | |||
| 463 | if (!initialized) { | ||
| 464 | for (i = 0; i < BINOM12ON4; i++) { | ||
| 465 | for (j = 0; j < 12; j++) | ||
| 466 | ep[j] = ep2[j] = 0; | ||
| 467 | epos_to_partial_ep(i*24, ep, eps_solved); | ||
| 468 | for (j = 0; j < 8; j++) | ||
| 469 | ep2[j/2 + 4*(j%2)] = ep[j] ? 1 : 0; | ||
| 470 | aux[i] = subset_to_index(ep2, 8, 4); | ||
| 471 | } | ||
| 472 | |||
| 473 | initialized = true; | ||
| 474 | } | ||
| 475 | |||
| 476 | return index_cphtr(cube) * BINOM8ON4 + aux[cube.eposs/24]; | ||
| 442 | } | 477 | } |
| 443 | 478 | ||
| 444 | static uint64_t | 479 | static uint64_t |
| @@ -1,13 +1,8 @@ | |||
| 1 | #include "cube.h" | 1 | #include "cube.h" |
| 2 | 2 | ||
| 3 | /* Local functions **********************************************************/ | 3 | /* Public functions implementation *******************************************/ |
| 4 | |||
| 5 | static int array_ep_to_epos(int *ep, int *eps_solved); | ||
| 6 | static int epos_from_arrays(int *epos, int *ep); | ||
| 7 | |||
| 8 | /* Local functions implementation ********************************************/ | ||
| 9 | 4 | ||
| 10 | static int | 5 | int |
| 11 | array_ep_to_epos(int *ep, int *ss) | 6 | array_ep_to_epos(int *ep, int *ss) |
| 12 | { | 7 | { |
| 13 | int epos[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; | 8 | int epos[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; |
| @@ -26,17 +21,9 @@ array_ep_to_epos(int *ep, int *ss) | |||
| 26 | for (i = 0; i < 4; i++) | 21 | for (i = 0; i < 4; i++) |
| 27 | swap(&epos[ss[i]], &epos[i+8]); | 22 | swap(&epos[ss[i]], &epos[i+8]); |
| 28 | 23 | ||
| 29 | return epos_from_arrays(epos, eps); | 24 | return 24 * subset_to_index(epos, 12, 4) + perm_to_index(eps, 4); |
| 30 | } | 25 | } |
| 31 | 26 | ||
| 32 | static int | ||
| 33 | epos_from_arrays(int *epos, int *ep) | ||
| 34 | { | ||
| 35 | return FACTORIAL4 * subset_to_index(epos,12,4) + perm_to_index(ep,4); | ||
| 36 | } | ||
| 37 | |||
| 38 | /* Public functions implementation *******************************************/ | ||
| 39 | |||
| 40 | Cube | 27 | Cube |
| 41 | arrays_to_cube(CubeArray *arr, PieceFilter f) | 28 | arrays_to_cube(CubeArray *arr, PieceFilter f) |
| 42 | { | 29 | { |
| @@ -8,6 +8,7 @@ | |||
| 8 | #include "utils.h" | 8 | #include "utils.h" |
| 9 | 9 | ||
| 10 | Cube admissible_ep(Cube cube, PieceFilter f); | 10 | Cube admissible_ep(Cube cube, PieceFilter f); |
| 11 | int array_ep_to_epos(int *ep, int *eps_solved); | ||
| 11 | Cube arrays_to_cube(CubeArray *arr, PieceFilter f); | 12 | Cube arrays_to_cube(CubeArray *arr, PieceFilter f); |
| 12 | Cube compose(Cube c2, Cube c1); /* Use c2 as an alg on c1 */ | 13 | Cube compose(Cube c2, Cube c1); /* Use c2 as an alg on c1 */ |
| 13 | Cube compose_filtered(Cube c2, Cube c1, PieceFilter f); | 14 | Cube compose_filtered(Cube c2, Cube c1, PieceFilter f); |
diff --git a/src/pruning.c b/src/pruning.c index ca6f57a..6165e71 100644 --- a/src/pruning.c +++ b/src/pruning.c | |||
| @@ -178,6 +178,7 @@ genptable(PruneData *pd) | |||
| 178 | d+1, pd->n - oldn, pd->n, pd->coord->max); | 178 | d+1, pd->n - oldn, pd->n, pd->coord->max); |
| 179 | oldn = pd->n; | 179 | oldn = pd->n; |
| 180 | } | 180 | } |
| 181 | fprintf(stderr, "Pruning table generated!\n"); | ||
| 181 | 182 | ||
| 182 | if (!write_ptable_file(pd)) | 183 | if (!write_ptable_file(pd)) |
| 183 | fprintf(stderr, "Error writing ptable file\n"); | 184 | fprintf(stderr, "Error writing ptable file\n"); |
