nissy-classic

Stable branch of nissy
git clone https://git.tronto.net/nissy-classic
Download | Log | Files | Refs | README | LICENSE

commit b5a692702643c8f3e77765ca38677e076bce2b59
parent 36fb1d0fa1b70ee62dc6073d56176e8c81ceddfd
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Wed,  2 Mar 2022 19:48:10 +0100

Added dr and htr scrambles

Diffstat:
MTODO.md | 4----
Mdoc/nissy.1 | 4++++
Msrc/commands.c | 73+++++++++++++++++++++++++++++++++++++++++++++++++------------------------
Msrc/cube.c | 2++
Msrc/solve.c | 8+++++++-
5 files changed, 62 insertions(+), 29 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -56,10 +56,6 @@ including e.g. solutions that were not shown because -c) ## Technical stuff ### Memory management -* Optimization: allow coordinates do define how moves and trans are applied on - them; if not then just move the cube normally. - This can speedup things, for example in computing coordinates (no need to apply - trans_to_rep) and of course in optimal solver. * free pruning table after solve is done? if I do this I need to deafault to a small table for < 8 moves solutions or smth * improve multi-threading when solving multiple scrambles diff --git a/doc/nissy.1 b/doc/nissy.1 @@ -92,6 +92,8 @@ can be specified to be one of the following: .Bl -tag -width Ds .It Ar corners Scramble with solved edges (only cornes are scrambled). +.It Ar dr +Scramble with solved DR on U/D. .It Ar edges Scramble with solved corners (only edges are scrambled). .It Ar eo @@ -99,6 +101,8 @@ Scramble with solved EO on F/B axis. .It Ar fmc Scramble the full cube and the resulting scramble starts and ends with the moves R\(aq U\(aq F. +.It Ar htr +Scramble with HTR solved. .El . .It Nm solve Ar step Oo Ar options Oc Ar scramble diff --git a/src/commands.c b/src/commands.c @@ -169,7 +169,7 @@ Command *commands[] = { /* Other constants ***********************************************************/ -char *scrtypes[20] = { "eo", "corners", "edges", "fmc", NULL }; +char *scrtypes[20] = { "eo", "corners", "edges", "fmc", "dr", "htr", NULL }; /* Arg parsing functions implementation **************************************/ @@ -401,6 +401,7 @@ scramble_exec(CommandArgs *args) Cube cube; Alg *scr, *ruf, *aux; int i, j, eo, ep, co, cp, a[12]; + uint64_t ui, uj; init_all_movesets(); init_symcoord(); @@ -408,32 +409,56 @@ scramble_exec(CommandArgs *args) srand(time(NULL)); for (i = 0; i < args->n; i++) { - eo = rand() % POW2TO11; - ep = rand() % FACTORIAL12; - co = rand() % POW3TO7; - cp = rand() % FACTORIAL8; - - if (!strcmp(args->scrtype, "eo")) { - eo = 0; - } else if (!strcmp(args->scrtype, "corners")) { - eo = 0; - ep = 0; - index_to_perm(cp, 8, a); - if (perm_sign(a, 8) == 1) { - swap(&a[0], &a[1]); - cp = perm_to_index(a, 8); - } - } else if (!strcmp(args->scrtype, "edges")) { - co = 0; - cp = 0; - index_to_perm(ep, 12, a); - if (perm_sign(a, 12) == 1) { - swap(&a[0], &a[1]); - ep = perm_to_index(a, 12); + + if (!strcmp(args->scrtype, "dr")) { + /* Warning: cube is inconsistent because of side CO * + * and EO on U/D. But solve_2phase only solves drfin * + * in this case, so it should be ok. * + * TODO: check this properly * + * Moreover we again need to fix parity after * + * generating epose manually */ + do { + ui = rand() % coord_drudfin_noE_sym16.max; + uj = rand() % FACTORIAL4; + cube = coord_drudfin_noE_sym16.cube(ui); + cube.epose += uj; + } while (!is_admissible(cube)); + } else if (!strcmp(args->scrtype, "htr")) { + /* antindex_htrfin() returns a consistent * + * cube, except possibly for parity */ + do { + ui = rand() % coord_htrfin.max; + cube = coord_htrfin.cube(ui); + } while (!is_admissible(cube)); + } else { + eo = rand() % POW2TO11; + ep = rand() % FACTORIAL12; + co = rand() % POW3TO7; + cp = rand() % FACTORIAL8; + + if (!strcmp(args->scrtype, "eo")) { + eo = 0; + } else if (!strcmp(args->scrtype, "corners")) { + eo = 0; + ep = 0; + index_to_perm(cp, 8, a); + if (perm_sign(a, 8) == 1) { + swap(&a[0], &a[1]); + cp = perm_to_index(a, 8); + } + } else if (!strcmp(args->scrtype, "edges")) { + co = 0; + cp = 0; + index_to_perm(ep, 12, a); + if (perm_sign(a, 12) == 1) { + swap(&a[0], &a[1]); + ep = perm_to_index(a, 12); + } } + cube = fourval_to_cube(eo, ep, co, cp); } - cube = fourval_to_cube(eo, ep, co, cp); + /* TODO: can be optimized for htr and dr using htrfin, drfin */ scr = solve_2phase(cube, 1); if (!strcmp(args->scrtype, "fmc")) { diff --git a/src/cube.c b/src/cube.c @@ -413,6 +413,8 @@ is_admissible(Cube cube) { perm_sign(a->cp, 8) + perm_sign(a->cpos, 6); + free_cubearray(a, pf_all); + return perm && parity % 2 == 0; } diff --git a/src/solve.c b/src/solve.c @@ -466,7 +466,13 @@ solve_2phase(Cube cube, int nthreads) opts2.can_niss = false; opts2.verbose = false; - sols1 = solve(cube, &drany_HTM, &opts1); + /* We skip step1 if it is solved on any axis */ + if (drany_HTM.is_done(cube)) { + sols1 = new_alglist(); + append_alg(sols1, new_alg("")); + } else { + sols1 = solve(cube, &drany_HTM, &opts1); + } bestalg = new_alg(""); bestlen = 999; for (i = sols1->first; i != NULL; i = i->next) {