From e18f8e4eefadd733d985e99e2710111afa5a710a Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Tue, 15 Mar 2022 15:54:39 +0100 Subject: Prepare for big changes in coordinates --- src/cubetypes.h | 6 +++++- src/moves.c | 22 +++++++++++----------- src/moves.h | 15 +++++++++++++++ src/pruning.c | 4 ++-- src/symcoord.c | 32 ++++++++++++++++---------------- src/trans.h | 2 +- 6 files changed, 50 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/cubetypes.h b/src/cubetypes.h index 14e490a..518c727 100644 --- a/src/cubetypes.h +++ b/src/cubetypes.h @@ -95,6 +95,8 @@ typedef struct threaddatagenpt ThreadDataGenpt; typedef Cube (*AntiIndexer) (uint64_t); typedef bool (*Checker) (Cube); +typedef uint64_t (*CoordMover) (Move, uint64_t); +typedef uint64_t (*CoordTransformer) (Trans, uint64_t); typedef int (*Estimator) (DfsArg *); typedef bool (*Validator) (Alg *); typedef void (*Exec) (CommandArgs *); @@ -168,7 +170,9 @@ coordinate Indexer index; AntiIndexer cube; uint64_t max; - TransFinder trans; + TransFinder transfind; + CoordMover move; + CoordTransformer transform; }; struct diff --git a/src/moves.c b/src/moves.c index 7c33db4..02880ca 100644 --- a/src/moves.c +++ b/src/moves.c @@ -138,17 +138,17 @@ static char equiv_alg_string[100][NMOVES] = { }; /* Transition tables, to be loaded up at the beginning */ -static int epose_mtable[NMOVES][FACTORIAL12/FACTORIAL8]; -static int eposs_mtable[NMOVES][FACTORIAL12/FACTORIAL8]; -static int eposm_mtable[NMOVES][FACTORIAL12/FACTORIAL8]; -static int eofb_mtable[NMOVES][POW2TO11]; -static int eorl_mtable[NMOVES][POW2TO11]; -static int eoud_mtable[NMOVES][POW2TO11]; -static int cp_mtable[NMOVES][FACTORIAL8]; -static int coud_mtable[NMOVES][POW3TO7]; -static int cofb_mtable[NMOVES][POW3TO7]; -static int corl_mtable[NMOVES][POW3TO7]; -static int cpos_mtable[NMOVES][FACTORIAL6]; +int epose_mtable[NMOVES][FACTORIAL12/FACTORIAL8]; +int eposs_mtable[NMOVES][FACTORIAL12/FACTORIAL8]; +int eposm_mtable[NMOVES][FACTORIAL12/FACTORIAL8]; +int eofb_mtable[NMOVES][POW2TO11]; +int eorl_mtable[NMOVES][POW2TO11]; +int eoud_mtable[NMOVES][POW2TO11]; +int cp_mtable[NMOVES][FACTORIAL8]; +int coud_mtable[NMOVES][POW3TO7]; +int cofb_mtable[NMOVES][POW3TO7]; +int corl_mtable[NMOVES][POW3TO7]; +int cpos_mtable[NMOVES][FACTORIAL6]; /* Local functions implementation ********************************************/ diff --git a/src/moves.h b/src/moves.h index e7881a4..14ae087 100644 --- a/src/moves.h +++ b/src/moves.h @@ -5,6 +5,21 @@ #include "cube.h" #include "env.h" +/* + * Tables are exposed to allow for faster moves in some cases. + */ +extern int epose_mtable[NMOVES][FACTORIAL12/FACTORIAL8]; +extern int eposs_mtable[NMOVES][FACTORIAL12/FACTORIAL8]; +extern int eposm_mtable[NMOVES][FACTORIAL12/FACTORIAL8]; +extern int eofb_mtable[NMOVES][POW2TO11]; +extern int eorl_mtable[NMOVES][POW2TO11]; +extern int eoud_mtable[NMOVES][POW2TO11]; +extern int cp_mtable[NMOVES][FACTORIAL8]; +extern int coud_mtable[NMOVES][POW3TO7]; +extern int cofb_mtable[NMOVES][POW3TO7]; +extern int corl_mtable[NMOVES][POW3TO7]; +extern int cpos_mtable[NMOVES][FACTORIAL6]; + Cube apply_alg(Alg *alg, Cube cube); Cube apply_alg_generic(Alg *alg, Cube c, PieceFilter f, bool a); Cube apply_move(Move m, Cube cube); diff --git a/src/pruning.c b/src/pruning.c index c66f8d6..2dea797 100644 --- a/src/pruning.c +++ b/src/pruning.c @@ -263,12 +263,12 @@ genptable_fixnasty(PruneData *pd, int d) Cube c, cc; Trans t[NTRANS]; - if (pd->coord->trans == NULL) + if (pd->coord->transfind == NULL) return; for (i = 0; i < pd->coord->max; i++) { if (ptableval_index(pd, i) == d) { - n = pd->coord->trans(i, t); + n = pd->coord->transfind(i, t); if (n == 1) continue; diff --git a/src/symcoord.c b/src/symcoord.c index c4349f5..38e13c6 100644 --- a/src/symcoord.c +++ b/src/symcoord.c @@ -64,38 +64,38 @@ SymData * all_sd[] = { Coordinate coord_eofbepos_sym16 = { - .index = index_eofbepos_sym16, - .cube = antindex_eofbepos_sym16, + .index = index_eofbepos_sym16, + .cube = antindex_eofbepos_sym16, }; Coordinate coord_cp_sym16 = { - .index = index_cp_sym16, - .cube = antindex_cp_sym16, + .index = index_cp_sym16, + .cube = antindex_cp_sym16, }; Coordinate coord_drud_sym16 = { - .index = index_drud_sym16, - .cube = antindex_drud_sym16, - .max = POW3TO7 * CLASSES_EOFBEPOS_16, - .trans = transfinder_drud_sym16, + .index = index_drud_sym16, + .cube = antindex_drud_sym16, + .max = POW3TO7 * CLASSES_EOFBEPOS_16, + .transfind = transfinder_drud_sym16, }; Coordinate coord_drudfin_noE_sym16 = { - .index = index_drudfin_noE_sym16, - .cube = antindex_drudfin_noE_sym16, - .max = FACTORIAL8 * CLASSES_CP_16, - .trans = transfinder_drudfin_noE_sym16, + .index = index_drudfin_noE_sym16, + .cube = antindex_drudfin_noE_sym16, + .max = FACTORIAL8 * CLASSES_CP_16, + .transfind = transfinder_drudfin_noE_sym16, }; Coordinate coord_nxopt31 = { - .index = index_nxopt31, - .cube = antindex_nxopt31, - .max = POW3TO7 * BINOM8ON4 * CLASSES_EOFBEPOS_16 , - .trans = transfinder_nxopt31, + .index = index_nxopt31, + .cube = antindex_nxopt31, + .max = POW3TO7 * BINOM8ON4 * CLASSES_EOFBEPOS_16, + .transfind = transfinder_nxopt31, }; /* Functions *****************************************************************/ diff --git a/src/trans.h b/src/trans.h index 13d17d8..51df12f 100644 --- a/src/trans.h +++ b/src/trans.h @@ -4,7 +4,7 @@ #include "moves.h" /* - * Tables are exposed to allow faster partial transofrmations in some + * Tables are exposed to allow faster partial transformations in some * specific cases (in symcoord) */ extern int epose_ttable[NTRANS][FACTORIAL12/FACTORIAL8]; -- cgit v1.3