nissy-fmc

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

commit 6df92db4d23dd6e2c3aba48caf1e0ea30265abb2
parent 2f924f942bd6e7126e8f1d8692e475c95bd9fe82
Author: Sebastiano Tronto <sebastiano.tronto@gmail.com>
Date:   Fri, 17 Dec 2021 22:03:33 +0100

some progress

Diffstat:
Mnissy | 0
Aptable_nxopt31_values | 17+++++++++++++++++
Msrc/alg.c | 37+++++++++++++------------------------
Msrc/cube.c | 7++++---
Msrc/solve.c | 5+++--
Msrc/steps.c | 30++++++++++--------------------
Msrc/steps.h | 3+--
Msrc/symcoord.c | 9---------
Msrc/trans.c | 2--
9 files changed, 48 insertions(+), 62 deletions(-)

diff --git a/nissy b/nissy Binary files differ. diff --git a/ptable_nxopt31_values b/ptable_nxopt31_values @@ -0,0 +1,17 @@ +Values for table pt_nxopt31_HTM + 0 1 + 1 6 + 2 29 + 3 164 + 4 1433 + 5 16772 + 6 205033 + 7 2513871 + 8 30329976 + 9 342440769 +10 2815191126 +11 6147967200 +12 524918774 +13 3546 +14 0 +15 0 diff --git a/src/alg.c b/src/alg.c @@ -110,36 +110,25 @@ allowed_next_HTM(Move l2, Move l1, Move m) static int axis(Move m) { - Move i; - - static bool initialized = false; - static int aux[NMOVES]; - - if (!initialized) { - for (i = 0; i < NMOVES; i++) { - if (i == NULLMOVE) - aux[i] = 0; + if (m == NULLMOVE) + return 0; - if (i >= U && i <= B3) - aux[i] = (i-1)/6 + 1; + if (m >= U && m <= B3) + return (m-1)/6 + 1; - if (i >= Uw && i <= Bw3) - aux[i] = (i-1)/6 - 2; + if (m >= Uw && m <= Bw3) + return (m-1)/6 - 2; - if (base_move(i) == E || base_move(i) == y) - aux[i] = 1; + if (base_move(m) == E || base_move(m) == y) + return 1; - if (base_move(i) == M || base_move(i) == x) - aux[i] = 2; + if (base_move(m) == M || base_move(m) == x) + return 2; - if (base_move(i) == S || base_move(i) == z) - aux[i] = 3; - } - - initialized = true; - } + if (base_move(m) == S || base_move(m) == z) + return 3; - return aux[m]; + return -1; } bool diff --git a/src/cube.c b/src/cube.c @@ -526,11 +526,12 @@ what_center_at(Cube cube, Center c) Corner what_corner_at(Cube cube, Corner c) { + int i; + unsigned int ui; + CubeArray *arr; + static bool initialized = false; static Corner aux[FACTORIAL8][8]; - static int i; - static unsigned int ui; - static CubeArray *arr; if (!initialized) { for (ui = 0; ui < FACTORIAL8; ui++) { diff --git a/src/solve.c b/src/solve.c @@ -264,14 +264,15 @@ instance_thread(void *arg) darg.current_alg = new_alg(""); append_move(darg.current_alg, node->alg->move[0], node->alg->inv[0]); - darg.ed = new_estimatedata(); + darg.ed = malloc(sizeof(EstimateData)); + reset_estimatedata(darg.ed); darg.badmoves = 0; darg.badmovesinv = 0; dfs(&darg); free_alg(darg.current_alg); - free_estimatedata(darg.ed); + free(darg.ed); } return NULL; diff --git a/src/steps.c b/src/steps.c @@ -1467,12 +1467,6 @@ copy_estimatedata(EstimateData *src, EstimateData *dst) } void -free_estimatedata(EstimateData *ed) -{ - free(ed); -} - -void invert_estimatedata(EstimateData *ed) { swap(&(ed->normal_ud), &(ed->inverse_ud)); @@ -1480,21 +1474,17 @@ invert_estimatedata(EstimateData *ed) swap(&(ed->normal_rl), &(ed->inverse_rl)); } -EstimateData * -new_estimatedata() +void +reset_estimatedata(EstimateData *ed) { - EstimateData *ret = malloc(sizeof(EstimateData)); - - ret->corners = -1; - ret->normal_ud = -1; - ret->normal_fb = -1; - ret->normal_rl = -1; - ret->inverse_ud = -1; - ret->inverse_fb = -1; - ret->inverse_rl = -1; - ret->oldret = -1; - - return ret; + ed->corners = -1; + ed->normal_ud = -1; + ed->normal_fb = -1; + ed->normal_rl = -1; + ed->inverse_ud = -1; + ed->inverse_fb = -1; + ed->inverse_rl = -1; + ed->oldret = -1; } void diff --git a/src/steps.h b/src/steps.h @@ -8,9 +8,8 @@ extern Step * steps[NSTEPS]; void copy_estimatedata(EstimateData *s, EstimateData *d); -void free_estimatedata(EstimateData *ed); void invert_estimatedata(EstimateData *ed); -EstimateData * new_estimatedata(); +void reset_estimatedata(EstimateData *ed); void prepare_step(Step *step, SolveOptions *opts); #endif diff --git a/src/symcoord.c b/src/symcoord.c @@ -352,16 +352,7 @@ gensym(SymData *sd) for (i = 0; i < sd->coord->max; i++) { if (sd->class[i] == sd->coord->max + 1) { - - /* - * TODO: this is the only unavoidable use of - * antindexes. I also use them in genptable() (see - * pruning.c), but there I can do without (see - * commented functions in that file. - * Removing this would allow for a great simplification - */ c = sd->coord->cube(i); - sd->rep[nreps] = c; for (j = 0; j < sd->ntrans; j++) { d = apply_trans(sd->trans[j], c); diff --git a/src/trans.c b/src/trans.c @@ -25,7 +25,6 @@ static int cpos_mirror[6] = { [F_center] = F_center, [B_center] = B_center }; -/* TODO Is there a more elegant way? */ static char rotation_alg_string[100][NROTATIONS] = { [uf] = "", [ur] = "y", [ub] = "y2", [ul] = "y3", [df] = "z2", [dr] = "y z2", [db] = "x2", [dl] = "y3 z2", @@ -208,7 +207,6 @@ apply_trans(Trans t, Cube cube) Trans inverse_trans(Trans t) { - /* TODO is there a more elegant way? */ static Trans inverse_trans_aux[NTRANS] = { [uf] = uf, [ur] = ul, [ul] = ur, [ub] = ub, [df] = df, [dr] = dr, [dl] = dl, [db] = db,