diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-12-24 15:13:25 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-12-24 15:13:25 +0100 |
| commit | 92fe5c67548304af7630ba0dd571b9d95241e412 (patch) | |
| tree | 4f394f944bdb05a28a36ae0442d9d2418cb5fa3c | |
| parent | fe1343560ef17a700cdf3110d2d2b6305338c041 (diff) | |
| download | nissy-92fe5c67548304af7630ba0dd571b9d95241e412.tar.gz nissy-92fe5c67548304af7630ba0dd571b9d95241e412.zip | |
Added -c option for solve
Diffstat (limited to '')
| -rw-r--r-- | TODO.md | 1 | ||||
| -rw-r--r-- | doc/nissy.1 | 23 | ||||
| -rwxr-xr-x | nissy | bin | 320968 -> 321192 bytes | |||
| -rw-r--r-- | src/commands.c | 9 | ||||
| -rw-r--r-- | src/cubetypes.h | 1 | ||||
| -rw-r--r-- | src/steps.c | 20 |
6 files changed, 43 insertions, 11 deletions
| @@ -27,6 +27,7 @@ It's more of a personal reminder than anything else. | |||
| 27 | * for solve -v, solving in different orientation does not give meaningful info, | 27 | * for solve -v, solving in different orientation does not give meaningful info, |
| 28 | because I need to transform the alg as I go. | 28 | because I need to transform the alg as I go. |
| 29 | * for solve -v, print certain info like average branching value | 29 | * for solve -v, print certain info like average branching value |
| 30 | * solve should default to +infity for -s if other bounds are given | ||
| 30 | 31 | ||
| 31 | ### New features | 32 | ### New features |
| 32 | * cleanup: translate an alg to the standard HTM moveset + reorient at the end | 33 | * cleanup: translate an alg to the standard HTM moveset + reorient at the end |
diff --git a/doc/nissy.1 b/doc/nissy.1 index 0e2e5cb..8f92b01 100644 --- a/doc/nissy.1 +++ b/doc/nissy.1 | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | .Nd a Rubik's cube solver and FMC assistant | 6 | .Nd a Rubik's cube solver and FMC assistant |
| 7 | . | 7 | . |
| 8 | .Sh SYNOPSIS | 8 | .Sh SYNOPSIS |
| 9 | .Nm Op Fl b | 9 | .Op Fl b |
| 10 | .Nm | 10 | .Nm |
| 11 | .Ar command | 11 | .Ar command |
| 12 | .Op options... | 12 | .Op options... |
| @@ -82,6 +82,13 @@ command are the following: | |||
| 82 | . | 82 | . |
| 83 | .Bl -tag -width Ds | 83 | .Bl -tag -width Ds |
| 84 | . | 84 | . |
| 85 | .It Fl a | ||
| 86 | Print all solutions: some solutions are filtered out by default for some | ||
| 87 | steps, for examples EOs that finish with F\(aq, with this options they are not. | ||
| 88 | . | ||
| 89 | .It Fl c | ||
| 90 | Display only the number of solutions found, not the solutions themselves. | ||
| 91 | . | ||
| 85 | .It Fl m Ar min | 92 | .It Fl m Ar min |
| 86 | Only look for solution that are at least | 93 | Only look for solution that are at least |
| 87 | .Ar min | 94 | .Ar min |
| @@ -92,15 +99,6 @@ Only look for solution that are at most | |||
| 92 | .Ar MAX | 99 | .Ar MAX |
| 93 | moves long. | 100 | moves long. |
| 94 | . | 101 | . |
| 95 | .It Fl s Ar n | ||
| 96 | Try to find | ||
| 97 | .Ar n | ||
| 98 | solutions. | ||
| 99 | . | ||
| 100 | .It Fl a | ||
| 101 | Print all solutions: some solutions are filtered out by default for some | ||
| 102 | steps, for examples EOs that finish with F\(aq, with this options they are not. | ||
| 103 | . | ||
| 104 | .It Fl n | 102 | .It Fl n |
| 105 | Allow use of NISS. | 103 | Allow use of NISS. |
| 106 | . | 104 | . |
| @@ -110,6 +108,11 @@ Only find solutions that require the minimum number of moves. | |||
| 110 | .It Fl p | 108 | .It Fl p |
| 111 | Plain style: do not print the number of moves. | 109 | Plain style: do not print the number of moves. |
| 112 | . | 110 | . |
| 111 | .It Fl s Ar n | ||
| 112 | Try to find | ||
| 113 | .Ar n | ||
| 114 | solutions. | ||
| 115 | . | ||
| 113 | .It Fl t Ar n | 116 | .It Fl t Ar n |
| 114 | Use | 117 | Use |
| 115 | .Ar n | 118 | .Ar n |
| Binary files differ | |||
diff --git a/src/commands.c b/src/commands.c index 01671ee..193ee97 100644 --- a/src/commands.c +++ b/src/commands.c | |||
| @@ -128,6 +128,7 @@ solve_parse_args(int c, char **v) | |||
| 128 | a->opts->verbose = false; | 128 | a->opts->verbose = false; |
| 129 | a->opts->all = false; | 129 | a->opts->all = false; |
| 130 | a->opts->print_number = true; | 130 | a->opts->print_number = true; |
| 131 | a->opts->count_only = false; | ||
| 131 | 132 | ||
| 132 | for (i = 0; i < c; i++) { | 133 | for (i = 0; i < c; i++) { |
| 133 | if (!strcmp(v[i], "-m") && i+1 < c) { | 134 | if (!strcmp(v[i], "-m") && i+1 < c) { |
| @@ -175,6 +176,8 @@ solve_parse_args(int c, char **v) | |||
| 175 | a->opts->all = true; | 176 | a->opts->all = true; |
| 176 | } else if (!strcmp(v[i], "-p")) { | 177 | } else if (!strcmp(v[i], "-p")) { |
| 177 | a->opts->print_number = false; | 178 | a->opts->print_number = false; |
| 179 | } else if (!strcmp(v[i], "-c")) { | ||
| 180 | a->opts->count_only = true; | ||
| 178 | } else if (!read_step(a, v[i])) { | 181 | } else if (!read_step(a, v[i])) { |
| 179 | break; | 182 | break; |
| 180 | } | 183 | } |
| @@ -265,7 +268,11 @@ solve_exec(CommandArgs *args) | |||
| 265 | c = apply_alg(args->scramble, (Cube){0}); | 268 | c = apply_alg(args->scramble, (Cube){0}); |
| 266 | sols = solve(c, args->step, args->opts); | 269 | sols = solve(c, args->step, args->opts); |
| 267 | 270 | ||
| 268 | print_alglist(sols, args->opts->print_number); | 271 | if (args->opts->count_only) |
| 272 | printf("%d\n", sols->len); | ||
| 273 | else | ||
| 274 | print_alglist(sols, args->opts->print_number); | ||
| 275 | |||
| 269 | free_alglist(sols); | 276 | free_alglist(sols); |
| 270 | } | 277 | } |
| 271 | 278 | ||
diff --git a/src/cubetypes.h b/src/cubetypes.h index 7563abb..6d8af21 100644 --- a/src/cubetypes.h +++ b/src/cubetypes.h | |||
| @@ -284,6 +284,7 @@ solveoptions | |||
| 284 | bool verbose; | 284 | bool verbose; |
| 285 | bool all; | 285 | bool all; |
| 286 | bool print_number; | 286 | bool print_number; |
| 287 | bool count_only; | ||
| 287 | }; | 288 | }; |
| 288 | 289 | ||
| 289 | struct | 290 | struct |
diff --git a/src/steps.c b/src/steps.c index ae3f9fd..79f609b 100644 --- a/src/steps.c +++ b/src/steps.c | |||
| @@ -121,6 +121,25 @@ optimal_light_HTM = { | |||
| 121 | .ntables = 2, | 121 | .ntables = 2, |
| 122 | }; | 122 | }; |
| 123 | 123 | ||
| 124 | Step | ||
| 125 | eofbfin_eofb = { | ||
| 126 | .shortname = "eofbfin", | ||
| 127 | .name = "Optimal after EO on F/B without breaking EO", | ||
| 128 | |||
| 129 | .final = true, | ||
| 130 | .is_done = is_solved, | ||
| 131 | .estimate = estimate_nxopt31_HTM, | ||
| 132 | .ready = check_eofb, | ||
| 133 | .ready_msg = check_eo_msg, | ||
| 134 | .is_valid = always_valid, | ||
| 135 | .moveset = &moveset_eofb, | ||
| 136 | |||
| 137 | .pre_trans = uf, | ||
| 138 | |||
| 139 | .tables = {&pd_nxopt31_HTM, &pd_corners_HTM}, | ||
| 140 | .ntables = 2, | ||
| 141 | }; | ||
| 142 | |||
| 124 | /* EO steps **************************/ | 143 | /* EO steps **************************/ |
| 125 | Step | 144 | Step |
| 126 | eoany_HTM = { | 145 | eoany_HTM = { |
| @@ -861,6 +880,7 @@ htrfin_htr = { | |||
| 861 | Step *steps[NSTEPS] = { | 880 | Step *steps[NSTEPS] = { |
| 862 | &optimal_HTM, /* first is default */ | 881 | &optimal_HTM, /* first is default */ |
| 863 | &optimal_light_HTM, | 882 | &optimal_light_HTM, |
| 883 | &eofbfin_eofb, | ||
| 864 | 884 | ||
| 865 | &eoany_HTM, | 885 | &eoany_HTM, |
| 866 | &eofb_HTM, | 886 | &eofb_HTM, |
