aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2023-09-24 18:03:44 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2023-09-24 18:03:44 +0200
commit214ef0fe87b48e044681bb831b8ae2fc2fe1a35b (patch)
tree1dc657cd93d9c208bdee41b44f2f32b651177523 /src
parentdb4d88428a1bf20652f11d4cf9b31b7114fdacfb (diff)
downloadnissy-classic-214ef0fe87b48e044681bb831b8ae2fc2fe1a35b.tar.gz
nissy-classic-214ef0fe87b48e044681bb831b8ae2fc2fe1a35b.zip
Added -L option
Diffstat (limited to 'src')
-rw-r--r--src/commands.c7
-rw-r--r--src/cubetypes.h8
-rw-r--r--src/solve.c10
-rw-r--r--src/steps.c7
4 files changed, 21 insertions, 11 deletions
diff --git a/src/commands.c b/src/commands.c
index f01edfd..1e5dd07 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -210,7 +210,7 @@ solve_parse_args(int c, char **v)
210 a->opts->max_solutions = 1; 210 a->opts->max_solutions = 1;
211 a->opts->nthreads = 1; 211 a->opts->nthreads = 1;
212 a->opts->optimal = -1; 212 a->opts->optimal = -1;
213 a->opts->can_niss = false; 213 a->opts->nisstype = NORMAL;
214 a->opts->verbose = false; 214 a->opts->verbose = false;
215 a->opts->all = false; 215 a->opts->all = false;
216 a->opts->print_number = true; 216 a->opts->print_number = true;
@@ -272,7 +272,10 @@ solve_parse_args(int c, char **v)
272 a->opts->optimal = val; 272 a->opts->optimal = val;
273 infinitesols = true; 273 infinitesols = true;
274 } else if (!strcmp(v[i], "-N")) { 274 } else if (!strcmp(v[i], "-N")) {
275 a->opts->can_niss = true; 275 a->opts->nisstype = NISS;
276 } else if (!strcmp(v[i], "-L")) {
277 if (a->opts->nisstype != NISS)
278 a->opts->nisstype = LINEAR;
276 } else if (!strcmp(v[i], "-i")) { 279 } else if (!strcmp(v[i], "-i")) {
277 a->scrstdin = true; 280 a->scrstdin = true;
278 } else if (!strcmp(v[i], "-v")) { 281 } else if (!strcmp(v[i], "-v")) {
diff --git a/src/cubetypes.h b/src/cubetypes.h
index 66839ca..b082518 100644
--- a/src/cubetypes.h
+++ b/src/cubetypes.h
@@ -70,6 +70,12 @@ trans
70 bu_mirror, br_mirror, bd_mirror, bl_mirror, 70 bu_mirror, br_mirror, bd_mirror, bl_mirror,
71} Trans; 71} Trans;
72 72
73typedef enum
74niss_type
75{
76 NORMAL, LINEAR, NISS
77} NissType;
78
73 79
74/* Typedefs ******************************************************************/ 80/* Typedefs ******************************************************************/
75 81
@@ -291,7 +297,7 @@ solveoptions
291 int max_solutions; 297 int max_solutions;
292 int nthreads; 298 int nthreads;
293 int optimal; 299 int optimal;
294 bool can_niss; 300 NissType nisstype;
295 bool verbose; 301 bool verbose;
296 bool all; 302 bool all;
297 bool print_number; 303 bool print_number;
diff --git a/src/solve.c b/src/solve.c
index 44550cc..39437fb 100644
--- a/src/solve.c
+++ b/src/solve.c
@@ -97,7 +97,7 @@ dfs(DfsArg *arg)
97 invert_branch(arg); 97 invert_branch(arg);
98 dfs_branch(arg); 98 dfs_branch(arg);
99 99
100 if (arg->opts->can_niss && !arg->niss && niss_makes_sense(arg)) 100 if (arg->opts->nisstype == NISS && !arg->niss && niss_makes_sense(arg))
101 dfs_niss(arg); 101 dfs_niss(arg);
102 102
103 if (sw) 103 if (sw)
@@ -193,7 +193,7 @@ dfs_stop(DfsArg *arg)
193 bool b; 193 bool b;
194 194
195 lowerbound = arg->step->estimate(arg); 195 lowerbound = arg->step->estimate(arg);
196 if (arg->opts->can_niss && !arg->niss) 196 if (arg->opts->nisstype == NISS && !arg->niss)
197 lowerbound = MIN(1, lowerbound); 197 lowerbound = MIN(1, lowerbound);
198 198
199 if (arg->current_alg->len + lowerbound > arg->d) { 199 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)
330 alg = new_alg(""); 330 alg = new_alg("");
331 append_move(alg, s->moveset->sorted_moves[i], false); 331 append_move(alg, s->moveset->sorted_moves[i], false);
332 append_alg(start, alg); 332 append_alg(start, alg);
333 if (opts->can_niss) { 333 if (opts->nisstype == NISS || opts->nisstype == LINEAR) {
334 alg->inv[0] = true; 334 alg->inv[0] = true;
335 append_alg(start, alg); 335 append_alg(start, alg);
336 } 336 }
@@ -458,7 +458,7 @@ solve_2phase(Cube cube, int nthreads)
458 opts1.max_solutions = 20; 458 opts1.max_solutions = 20;
459 opts1.nthreads = nthreads; 459 opts1.nthreads = nthreads;
460 opts1.optimal = 3; 460 opts1.optimal = 3;
461 opts1.can_niss = false; 461 opts1.nisstype = NORMAL;
462 opts1.verbose = false; 462 opts1.verbose = false;
463 opts1.all = true; 463 opts1.all = true;
464 464
@@ -466,7 +466,7 @@ solve_2phase(Cube cube, int nthreads)
466 opts2.max_moves = 19; 466 opts2.max_moves = 19;
467 opts2.max_solutions = 1; 467 opts2.max_solutions = 1;
468 opts2.nthreads = nthreads; 468 opts2.nthreads = nthreads;
469 opts2.can_niss = false; 469 opts2.nisstype = NORMAL;
470 opts2.verbose = false; 470 opts2.verbose = false;
471 471
472 /* We skip step1 if it is solved on any axis */ 472 /* We skip step1 if it is solved on any axis */
diff --git a/src/steps.c b/src/steps.c
index bdcbd2a..6754d22 100644
--- a/src/steps.c
+++ b/src/steps.c
@@ -1678,9 +1678,10 @@ prepare_step(Step *step, SolveOptions *opts)
1678{ 1678{
1679 int i; 1679 int i;
1680 1680
1681 if (step->final && opts->can_niss) { 1681 if (step->final && opts->nisstype != NORMAL) {
1682 opts->can_niss = false; 1682 opts->nisstype = NORMAL;
1683 fprintf(stderr, "Step is final, NISS not used (-n ignored)\n"); 1683 fprintf(stderr, "Step is final, NISS not used"
1684 " (-N and -L ignored)\n");
1684 } 1685 }
1685 1686
1686 for (i = 0; i < step->ntables; i++) { 1687 for (i = 0; i < step->ntables; i++) {

Generated with cgit - Back to sebastiano.tronto.net