commit 1a90075f672a442cafa35c1cccbb6cf026c3980e
parent e864e23e3ec315d5969281c51f24521cde30792a
Author: Sebastiano Tronto <sebastiano.tronto@gmail.com>
Date: Sat, 13 Nov 2021 17:13:24 +0100
Fixed a problem with htr-drud coordinates. The corresponding pruning table also changed, hopefully the new one is correct.
Diffstat:
7 files changed, 44 insertions(+), 20 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,6 +1,6 @@
# See LICENSE file for copyright and license details.
-VERSION = 2.0beta1
+VERSION = 2.0beta2
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man
diff --git a/nissy-2.0beta1.tar.gz b/nissy-2.0beta1.tar.gz
Binary files differ.
diff --git a/nissy-2.0beta2.tar.gz b/nissy-2.0beta2.tar.gz
Binary files differ.
diff --git a/src/coord.c b/src/coord.c
@@ -327,9 +327,27 @@ antindex_htr_drud(uint64_t ind)
/* The returned cube is NOT consistent: corl and cofb can be wrong */
/* (see cphtr) and eposm can be wrong too (not epose because dr). */
Cube ret = {0};
+ static bool initialized = false;
+ static int aux[BINOM8ON4], ep[12], ep2[12];
+ static int eps_solved[4] = {UL, UR, DL, DR};
+ unsigned int i, j, k;
+
+ if (!initialized) {
+ for (i = 0; i < BINOM8ON4; i++) {
+ for (j = 0; j < 12; j++)
+ ep[j] = ep2[j] = 0;
+ index_to_subset(i, 8, 4, ep);
+ for (j = 0, k = 0; j < 8; j++)
+ ep2[j] = ep[j/2+4*(j%2)] ? eps_solved[k++] : 0;
+ aux[i] = array_ep_to_epos(ep2, eps_solved);
+ }
+
+ initialized = true;
+ }
ret = antindex_cphtr(ind / BINOM8ON4);
- ret.eposs = (ind % BINOM8ON4) * FACTORIAL4;
+ ret.epose = 0;
+ ret.eposs = aux[ind % BINOM8ON4];
return ret;
}
@@ -437,8 +455,25 @@ index_drud_eofb(Cube cube)
static uint64_t
index_htr_drud(Cube cube)
{
- return index_cphtr(cube) * BINOM8ON4 +
- (cube.eposs / FACTORIAL4) % BINOM8ON4;
+ static bool initialized = false;
+ static int aux[BINOM12ON4], ep[12], ep2[12];
+ static int eps_solved[4] = {UL, UR, DL, DR};
+ unsigned int i, j;
+
+ if (!initialized) {
+ for (i = 0; i < BINOM12ON4; i++) {
+ for (j = 0; j < 12; j++)
+ ep[j] = ep2[j] = 0;
+ epos_to_partial_ep(i*24, ep, eps_solved);
+ for (j = 0; j < 8; j++)
+ ep2[j/2 + 4*(j%2)] = ep[j] ? 1 : 0;
+ aux[i] = subset_to_index(ep2, 8, 4);
+ }
+
+ initialized = true;
+ }
+
+ return index_cphtr(cube) * BINOM8ON4 + aux[cube.eposs/24];
}
static uint64_t
diff --git a/src/cube.c b/src/cube.c
@@ -1,13 +1,8 @@
#include "cube.h"
-/* Local functions **********************************************************/
-
-static int array_ep_to_epos(int *ep, int *eps_solved);
-static int epos_from_arrays(int *epos, int *ep);
-
-/* Local functions implementation ********************************************/
+/* Public functions implementation *******************************************/
-static int
+int
array_ep_to_epos(int *ep, int *ss)
{
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)
for (i = 0; i < 4; i++)
swap(&epos[ss[i]], &epos[i+8]);
- return epos_from_arrays(epos, eps);
+ return 24 * subset_to_index(epos, 12, 4) + perm_to_index(eps, 4);
}
-static int
-epos_from_arrays(int *epos, int *ep)
-{
- return FACTORIAL4 * subset_to_index(epos,12,4) + perm_to_index(ep,4);
-}
-
-/* Public functions implementation *******************************************/
-
Cube
arrays_to_cube(CubeArray *arr, PieceFilter f)
{
diff --git a/src/cube.h b/src/cube.h
@@ -8,6 +8,7 @@
#include "utils.h"
Cube admissible_ep(Cube cube, PieceFilter f);
+int array_ep_to_epos(int *ep, int *eps_solved);
Cube arrays_to_cube(CubeArray *arr, PieceFilter f);
Cube compose(Cube c2, Cube c1); /* Use c2 as an alg on c1 */
Cube compose_filtered(Cube c2, Cube c1, PieceFilter f);
diff --git a/src/pruning.c b/src/pruning.c
@@ -178,6 +178,7 @@ genptable(PruneData *pd)
d+1, pd->n - oldn, pd->n, pd->coord->max);
oldn = pd->n;
}
+ fprintf(stderr, "Pruning table generated!\n");
if (!write_ptable_file(pd))
fprintf(stderr, "Error writing ptable file\n");