nissy-classic

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

commit 214ef0fe87b48e044681bb831b8ae2fc2fe1a35b
parent db4d88428a1bf20652f11d4cf9b31b7114fdacfb
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Sun, 24 Sep 2023 18:03:44 +0200

Added -L option

Diffstat:
Mdoc/nissy.1 | 2++
Msrc/commands.c | 7+++++--
Msrc/cubetypes.h | 8+++++++-
Msrc/solve.c | 10+++++-----
Msrc/steps.c | 7++++---
5 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/doc/nissy.1 b/doc/nissy.1 @@ -137,6 +137,8 @@ steps, for examples EOs that finish with F\(aq, with this options they are not. . .It Fl c Display only the number of solutions found, not the solutions themselves. +.It Fl L +Look for solutions on both normal and inverse scramble, without NISS (linear). . .It Fl m Ar min Only look for solution that are at least diff --git a/src/commands.c b/src/commands.c @@ -210,7 +210,7 @@ solve_parse_args(int c, char **v) a->opts->max_solutions = 1; a->opts->nthreads = 1; a->opts->optimal = -1; - a->opts->can_niss = false; + a->opts->nisstype = NORMAL; a->opts->verbose = false; a->opts->all = false; a->opts->print_number = true; @@ -272,7 +272,10 @@ solve_parse_args(int c, char **v) a->opts->optimal = val; infinitesols = true; } else if (!strcmp(v[i], "-N")) { - a->opts->can_niss = true; + a->opts->nisstype = NISS; + } else if (!strcmp(v[i], "-L")) { + if (a->opts->nisstype != NISS) + a->opts->nisstype = LINEAR; } else if (!strcmp(v[i], "-i")) { a->scrstdin = true; } else if (!strcmp(v[i], "-v")) { diff --git a/src/cubetypes.h b/src/cubetypes.h @@ -70,6 +70,12 @@ trans bu_mirror, br_mirror, bd_mirror, bl_mirror, } Trans; +typedef enum +niss_type +{ + NORMAL, LINEAR, NISS +} NissType; + /* Typedefs ******************************************************************/ @@ -291,7 +297,7 @@ solveoptions int max_solutions; int nthreads; int optimal; - bool can_niss; + NissType nisstype; bool verbose; bool all; bool print_number; diff --git a/src/solve.c b/src/solve.c @@ -97,7 +97,7 @@ dfs(DfsArg *arg) invert_branch(arg); dfs_branch(arg); - if (arg->opts->can_niss && !arg->niss && niss_makes_sense(arg)) + if (arg->opts->nisstype == NISS && !arg->niss && niss_makes_sense(arg)) dfs_niss(arg); if (sw) @@ -193,7 +193,7 @@ dfs_stop(DfsArg *arg) bool b; lowerbound = arg->step->estimate(arg); - if (arg->opts->can_niss && !arg->niss) + if (arg->opts->nisstype == NISS && !arg->niss) lowerbound = MIN(1, lowerbound); if (arg->current_alg->len + lowerbound > arg->d) { @@ -330,7 +330,7 @@ multidfs(Cube c, Trans tr, Step *s, SolveOptions *opts, AlgList *sols, int d) alg = new_alg(""); append_move(alg, s->moveset->sorted_moves[i], false); append_alg(start, alg); - if (opts->can_niss) { + if (opts->nisstype == NISS || opts->nisstype == LINEAR) { alg->inv[0] = true; append_alg(start, alg); } @@ -458,7 +458,7 @@ solve_2phase(Cube cube, int nthreads) opts1.max_solutions = 20; opts1.nthreads = nthreads; opts1.optimal = 3; - opts1.can_niss = false; + opts1.nisstype = NORMAL; opts1.verbose = false; opts1.all = true; @@ -466,7 +466,7 @@ solve_2phase(Cube cube, int nthreads) opts2.max_moves = 19; opts2.max_solutions = 1; opts2.nthreads = nthreads; - opts2.can_niss = false; + opts2.nisstype = NORMAL; opts2.verbose = false; /* We skip step1 if it is solved on any axis */ diff --git a/src/steps.c b/src/steps.c @@ -1678,9 +1678,10 @@ prepare_step(Step *step, SolveOptions *opts) { int i; - if (step->final && opts->can_niss) { - opts->can_niss = false; - fprintf(stderr, "Step is final, NISS not used (-n ignored)\n"); + if (step->final && opts->nisstype != NORMAL) { + opts->nisstype = NORMAL; + fprintf(stderr, "Step is final, NISS not used" + " (-N and -L ignored)\n"); } for (i = 0; i < step->ntables; i++) {