commit 92fe5c67548304af7630ba0dd571b9d95241e412
parent fe1343560ef17a700cdf3110d2d2b6305338c041
Author: Sebastiano Tronto <sebastiano.tronto@gmail.com>
Date: Fri, 24 Dec 2021 15:13:25 +0100
Added -c option for solve
Diffstat:
6 files changed, 43 insertions(+), 11 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -27,6 +27,7 @@ It's more of a personal reminder than anything else.
* for solve -v, solving in different orientation does not give meaningful info,
because I need to transform the alg as I go.
* for solve -v, print certain info like average branching value
+* solve should default to +infity for -s if other bounds are given
### New features
* cleanup: translate an alg to the standard HTM moveset + reorient at the end
diff --git a/doc/nissy.1 b/doc/nissy.1
@@ -6,7 +6,7 @@
.Nd a Rubik's cube solver and FMC assistant
.
.Sh SYNOPSIS
-.Nm Op Fl b
+.Op Fl b
.Nm
.Ar command
.Op options...
@@ -82,6 +82,13 @@ command are the following:
.
.Bl -tag -width Ds
.
+.It Fl a
+Print all solutions: some solutions are filtered out by default for some
+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 m Ar min
Only look for solution that are at least
.Ar min
@@ -92,15 +99,6 @@ Only look for solution that are at most
.Ar MAX
moves long.
.
-.It Fl s Ar n
-Try to find
-.Ar n
-solutions.
-.
-.It Fl a
-Print all solutions: some solutions are filtered out by default for some
-steps, for examples EOs that finish with F\(aq, with this options they are not.
-.
.It Fl n
Allow use of NISS.
.
@@ -110,6 +108,11 @@ Only find solutions that require the minimum number of moves.
.It Fl p
Plain style: do not print the number of moves.
.
+.It Fl s Ar n
+Try to find
+.Ar n
+solutions.
+.
.It Fl t Ar n
Use
.Ar n
diff --git a/nissy b/nissy
Binary files differ.
diff --git a/src/commands.c b/src/commands.c
@@ -128,6 +128,7 @@ solve_parse_args(int c, char **v)
a->opts->verbose = false;
a->opts->all = false;
a->opts->print_number = true;
+ a->opts->count_only = false;
for (i = 0; i < c; i++) {
if (!strcmp(v[i], "-m") && i+1 < c) {
@@ -175,6 +176,8 @@ solve_parse_args(int c, char **v)
a->opts->all = true;
} else if (!strcmp(v[i], "-p")) {
a->opts->print_number = false;
+ } else if (!strcmp(v[i], "-c")) {
+ a->opts->count_only = true;
} else if (!read_step(a, v[i])) {
break;
}
@@ -265,7 +268,11 @@ solve_exec(CommandArgs *args)
c = apply_alg(args->scramble, (Cube){0});
sols = solve(c, args->step, args->opts);
- print_alglist(sols, args->opts->print_number);
+ if (args->opts->count_only)
+ printf("%d\n", sols->len);
+ else
+ print_alglist(sols, args->opts->print_number);
+
free_alglist(sols);
}
diff --git a/src/cubetypes.h b/src/cubetypes.h
@@ -284,6 +284,7 @@ solveoptions
bool verbose;
bool all;
bool print_number;
+ bool count_only;
};
struct
diff --git a/src/steps.c b/src/steps.c
@@ -121,6 +121,25 @@ optimal_light_HTM = {
.ntables = 2,
};
+Step
+eofbfin_eofb = {
+ .shortname = "eofbfin",
+ .name = "Optimal after EO on F/B without breaking EO",
+
+ .final = true,
+ .is_done = is_solved,
+ .estimate = estimate_nxopt31_HTM,
+ .ready = check_eofb,
+ .ready_msg = check_eo_msg,
+ .is_valid = always_valid,
+ .moveset = &moveset_eofb,
+
+ .pre_trans = uf,
+
+ .tables = {&pd_nxopt31_HTM, &pd_corners_HTM},
+ .ntables = 2,
+};
+
/* EO steps **************************/
Step
eoany_HTM = {
@@ -861,6 +880,7 @@ htrfin_htr = {
Step *steps[NSTEPS] = {
&optimal_HTM, /* first is default */
&optimal_light_HTM,
+ &eofbfin_eofb,
&eoany_HTM,
&eofb_HTM,