nissy-fmc

A Rubik's cube FMC assistant
git clone https://git.tronto.net/nissy-fmc
Download | Log | Files | Refs | README | LICENSE

commit 36fb1d0fa1b70ee62dc6073d56176e8c81ceddfd
parent 7de88d1bcd420447023b8e74b0aa4f5e8ba1df6b
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Sun, 27 Feb 2022 17:31:42 +0100

Removed some unused code (khuge). Improved optimal solver performance by about 10% using raw transition tables (same for dr step).

Diffstat:
Dnissy | 0
Msrc/pruning.c | 10----------
Msrc/pruning.h | 1-
Msrc/steps.c | 31-------------------------------
Msrc/symcoord.c | 82+++++++------------------------------------------------------------------------
Msrc/symcoord.h | 1-
Msrc/trans.c | 16++++++++--------
Msrc/trans.h | 13+++++++++++++
8 files changed, 28 insertions(+), 126 deletions(-)

diff --git a/nissy b/nissy Binary files differ. diff --git a/src/pruning.c b/src/pruning.c @@ -78,15 +78,6 @@ pd_htrfin_htr = { .moveset = &moveset_htr, }; -/* -PruneData -pd_khuge_HTM = { - .filename = "pt_khuge_HTM", - .coord = &coord_khuge, - .moveset = &moveset_HTM, -}; -*/ - PruneData pd_nxopt31_HTM = { .filename = "pt_nxopt31_HTM", @@ -108,7 +99,6 @@ PruneData * allpd[] = { &pd_drudfin_noE_sym16_drud, &pd_htr_drud, &pd_htrfin_htr, -/* &pd_khuge_HTM,*/ &pd_nxopt31_HTM, NULL }; diff --git a/src/pruning.h b/src/pruning.h @@ -12,7 +12,6 @@ extern PruneData pd_drud_eofb; extern PruneData pd_drudfin_noE_sym16_drud; extern PruneData pd_htr_drud; extern PruneData pd_htrfin_htr; -extern PruneData pd_khuge_HTM; extern PruneData pd_nxopt31_HTM; extern PruneData * allpd[]; diff --git a/src/steps.c b/src/steps.c @@ -27,7 +27,6 @@ static int estimate_dr_eofb(DfsArg *arg); static int estimate_drudfin_drud(DfsArg *arg); static int estimate_htr_drud(DfsArg *arg); static int estimate_htrfin_htr(DfsArg *arg); -/*static int estimate_khuge_HTM(DfsArg *arg);*/ static int estimate_nxopt31_HTM(DfsArg *arg); static int estimate_light_HTM(DfsArg *arg); @@ -54,28 +53,6 @@ static char check_drany_msg[100] = "DR must be solved on at least one axis"; /* Optimal solvers *******************/ -/* This is not used anymore, I'll keep it just in case */ -/* -Step -optimal_khuge_HTM = { - .shortname = "khuge", - .name = "Optimal solve (in HTM) using khuge table", - - .final = true, - .is_done = is_solved, - .estimate = estimate_khuge_HTM, - .ready = check_centers, - .ready_msg = check_centers_msg, - .is_valid = always_valid, - .moveset = &moveset_HTM, - - .pre_trans = uf, - - .tables = {&pd_khuge_HTM, &pd_corners_HTM}, - .ntables = 2, -}; -*/ - Step optimal_HTM = { .shortname = "optimal", @@ -1196,14 +1173,6 @@ estimate_htrfin_htr(DfsArg *arg) return ptableval(&pd_htrfin_htr, arg->cube); } -/* -static int -estimate_khuge_HTM(DfsArg *arg) -{ - return estimate_nxoptlike(arg, &pd_khuge_HTM); -} -*/ - static int estimate_nxopt31_HTM(DfsArg *arg) { diff --git a/src/symcoord.c b/src/symcoord.c @@ -8,19 +8,16 @@ static Cube antindex_cp_sym16(uint64_t ind); static Cube antindex_eofbepos_sym16(uint64_t ind); static Cube antindex_drud_sym16(uint64_t ind); static Cube antindex_drudfin_noE_sym16(uint64_t ind); -/*static Cube antindex_khuge(uint64_t ind);*/ static Cube antindex_nxopt31(uint64_t ind); static uint64_t index_cp_sym16(Cube cube); static uint64_t index_eofbepos_sym16(Cube cube); static uint64_t index_drud_sym16(Cube cube); static uint64_t index_drudfin_noE_sym16(Cube cube); -/*static uint64_t index_khuge(Cube cube);*/ static uint64_t index_nxopt31(Cube cube); static int transfinder_drud_sym16(uint64_t ind, Trans *ret); static int transfinder_drudfin_noE_sym16(uint64_t ind, Trans *ret); -/*static int transfinder_khuge(uint64_t ind, Trans *ret);*/ static int transfinder_nxopt31(uint64_t ind, Trans *ret); static void gensym(SymData *sd); @@ -93,16 +90,6 @@ coord_drudfin_noE_sym16 = { .trans = transfinder_drudfin_noE_sym16, }; -/* -Coordinate -coord_khuge = { - .index = index_khuge, - .cube = antindex_khuge, - .max = POW3TO7 * FACTORIAL4 * CLASSES_EOFBEPOS_16, - .trans = transfinder_khuge, -}; -*/ - Coordinate coord_nxopt31 = { .index = index_nxopt31, @@ -150,20 +137,6 @@ antindex_drudfin_noE_sym16(uint64_t ind) return c1; } -/* -static Cube -antindex_khuge(uint64_t ind) -{ - Cube c; - - c = antindex_eofbepos_sym16(ind/(FACTORIAL4*POW3TO7)); - c.epose = ((c.epose / 24) * 24) + ((ind/POW3TO7) % 24); - c.coud = ind % POW3TO7; - - return c; -} -*/ - static Cube antindex_nxopt31(uint64_t ind) { @@ -186,12 +159,10 @@ static uint64_t index_drud_sym16(Cube cube) { Trans t; - Cube c; t = sd_eofbepos_16.transtorep[coord_eofbepos.index(cube)]; - c = apply_trans(t, cube); - return index_eofbepos_sym16(c) * POW3TO7 + c.coud; + return index_eofbepos_sym16(cube) * POW3TO7 + co_ttable[t][cube.coud]; } static uint64_t @@ -212,34 +183,19 @@ index_eofbepos_sym16(Cube cube) return sd_eofbepos_16.class[coord_eofbepos.index(cube)]; } -/* -static uint64_t -index_khuge(Cube cube) -{ - Trans t; - Cube c; - uint64_t a; - - t = sd_eofbepos_16.transtorep[coord_eofbepos.index(cube)]; - c = apply_trans(t, cube); - a = (index_eofbepos_sym16(c) * 24) + (c.epose % 24); - - return a * POW3TO7 + c.coud; -} -*/ - static uint64_t index_nxopt31(Cube cube) { Trans t; - Cube c; uint64_t a; - + int coud, cp; + t = sd_eofbepos_16.transtorep[coord_eofbepos.index(cube)]; - c = apply_trans(t, cube); - a = (index_eofbepos_sym16(c)*POW3TO7) + c.coud; + coud = co_ttable[t][cube.coud]; + cp = cp_ttable[t][cube.cp]; + a = (index_eofbepos_sym16(cube)*POW3TO7) + coud; - return a * BINOM8ON4 + coord_cpud_separate.index(c); + return a * BINOM8ON4 + coord_cpud_separate.index((Cube){.cp = cp}); } static int @@ -286,30 +242,6 @@ transfinder_drudfin_noE_sym16(uint64_t ind, Trans *ret) return naux[trueind]; } -/* -static int -transfinder_khuge(uint64_t ind, Trans *ret) -{ - uint64_t i, trueind; - int j; - static bool initialized = false; - static int naux[CLASSES_EOFBEPOS_16]; - static Trans retaux[CLASSES_EOFBEPOS_16][NTRANS]; - - if (!initialized) { - for (i = 0; i < CLASSES_EOFBEPOS_16; i++) - naux[i] = selfsims(&sd_eofbepos_16, i, retaux[i]); - - initialized = true; - } - - trueind = ind/(FACTORIAL4*POW3TO7); - for (j = 0; j < naux[trueind]; j++) - ret[j] = retaux[trueind][j]; - return naux[trueind]; -} -*/ - static int transfinder_nxopt31(uint64_t ind, Trans *ret) { diff --git a/src/symcoord.h b/src/symcoord.h @@ -7,7 +7,6 @@ extern Coordinate coord_cp_sym16; extern Coordinate coord_eofbepos_sym16; extern Coordinate coord_drud_sym16; extern Coordinate coord_drudfin_noE_sym16; -extern Coordinate coord_khuge; extern Coordinate coord_nxopt31; void init_symcoord(); diff --git a/src/trans.c b/src/trans.c @@ -44,14 +44,14 @@ static int coud_source[NTRANS]; /* 0=coud, 1=corl, 2=cofb */ static int cofb_source[NTRANS]; static int corl_source[NTRANS]; -static int epose_ttable[NTRANS][FACTORIAL12/FACTORIAL8]; -static int eposs_ttable[NTRANS][FACTORIAL12/FACTORIAL8]; -static int eposm_ttable[NTRANS][FACTORIAL12/FACTORIAL8]; -static int eo_ttable[NTRANS][POW2TO11]; -static int cp_ttable[NTRANS][FACTORIAL8]; -static int co_ttable[NTRANS][POW3TO7]; -static int cpos_ttable[NTRANS][FACTORIAL6]; -static Move moves_ttable[NTRANS][NMOVES]; +int epose_ttable[NTRANS][FACTORIAL12/FACTORIAL8]; +int eposs_ttable[NTRANS][FACTORIAL12/FACTORIAL8]; +int eposm_ttable[NTRANS][FACTORIAL12/FACTORIAL8]; +int eo_ttable[NTRANS][POW2TO11]; +int cp_ttable[NTRANS][FACTORIAL8]; +int co_ttable[NTRANS][POW3TO7]; +int cpos_ttable[NTRANS][FACTORIAL6]; +Move moves_ttable[NTRANS][NMOVES]; /* Local functions implementation ********************************************/ diff --git a/src/trans.h b/src/trans.h @@ -3,6 +3,19 @@ #include "moves.h" +/* + * Tables are exposed to allow faster partial transofrmations in some + * specific cases (in symcoord) + */ +extern int epose_ttable[NTRANS][FACTORIAL12/FACTORIAL8]; +extern int eposs_ttable[NTRANS][FACTORIAL12/FACTORIAL8]; +extern int eposm_ttable[NTRANS][FACTORIAL12/FACTORIAL8]; +extern int eo_ttable[NTRANS][POW2TO11]; +extern int cp_ttable[NTRANS][FACTORIAL8]; +extern int co_ttable[NTRANS][POW3TO7]; +extern int cpos_ttable[NTRANS][FACTORIAL6]; +extern Move moves_ttable[NTRANS][NMOVES]; + Cube apply_trans(Trans t, Cube cube); Trans inverse_trans(Trans t); Alg * rotation_alg(Trans i);