diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-12-25 20:29:22 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-12-25 20:29:22 +0100 |
| commit | 0f81a5a70be20a82ee8495f050366a28d0be21c7 (patch) | |
| tree | 1d438ad2d3c9fd75ebd10f09d594a4a83fdd3fab | |
| parent | 4d664cefcc8c5a852629b29d47eb39e628adac57 (diff) | |
| download | nissy-0f81a5a70be20a82ee8495f050366a28d0be21c7.tar.gz nissy-0f81a5a70be20a82ee8495f050366a28d0be21c7.zip | |
Added the invert and unniss commands
| -rw-r--r-- | TODO.md | 6 | ||||
| -rw-r--r-- | doc/nissy.1 | 6 | ||||
| -rwxr-xr-x | nissy | bin | 321848 -> 318128 bytes | |||
| -rwxr-xr-x | nissy.exe | bin | 783134 -> 783308 bytes | |||
| -rw-r--r-- | src/commands.c | 51 | ||||
| -rw-r--r-- | src/commands.h | 2 |
6 files changed, 62 insertions, 3 deletions
| @@ -10,7 +10,6 @@ It's more of a personal reminder than anything else. | |||
| 10 | ### Commands that are available in nissy 1.0, but not in this version (yet): | 10 | ### Commands that are available in nissy 1.0, but not in this version (yet): |
| 11 | * drcorners (solve corners after dr) | 11 | * drcorners (solve corners after dr) |
| 12 | * search and improve non-optimal subsequences | 12 | * search and improve non-optimal subsequences |
| 13 | * **unniss (rewrite A (B) -> B' A)** | ||
| 14 | * **fast non-optimal solver (also needed for scramble)** | 13 | * **fast non-optimal solver (also needed for scramble)** |
| 15 | * **scramble [dr, corners only, edges only, htr, fmc(RUF)...]** | 14 | * **scramble [dr, corners only, edges only, htr, fmc(RUF)...]** |
| 16 | * save and edit algs as "variables" | 15 | * save and edit algs as "variables" |
| @@ -34,7 +33,8 @@ including e.g. solutions that were not shown because -c) | |||
| 34 | * **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** |
| 35 | * configurability: add an `alias` command, run config file at startup | 34 | * configurability: add an `alias` command, run config file at startup |
| 36 | * configure max ram to be used (via config file and/or command line option) | 35 | * configure max ram to be used (via config file and/or command line option) |
| 37 | * **invert an alg, transform, rufify etc...** | 36 | * transform alg, rufify etc... |
| 37 | * more scramble stuff (scramble FMC with rufify...) | ||
| 38 | * **command notation to list available moves** | 38 | * **command notation to list available moves** |
| 39 | 39 | ||
| 40 | ## Distribution | 40 | ## Distribution |
| @@ -76,3 +76,5 @@ including e.g. solutions that were not shown because -c) | |||
| 76 | * sort again functions alphabetically in their files | 76 | * sort again functions alphabetically in their files |
| 77 | * **more stuff to load at start (or when suitable command is called) rather | 77 | * **more stuff to load at start (or when suitable command is called) rather |
| 78 | than when called directly, to avoid nasty problems with threading** | 78 | than when called directly, to avoid nasty problems with threading** |
| 79 | * unniss and inverse_alg work differently (one in place, the other makes | ||
| 80 | a copy and returns). | ||
diff --git a/doc/nissy.1 b/doc/nissy.1 index 12dd638..fea5ddb 100644 --- a/doc/nissy.1 +++ b/doc/nissy.1 | |||
| @@ -61,6 +61,9 @@ relative to | |||
| 61 | .Ar command | 61 | .Ar command |
| 62 | is returned. | 62 | is returned. |
| 63 | . | 63 | . |
| 64 | .It Nm invert Ar scramble | ||
| 65 | Invert the given scramble. | ||
| 66 | . | ||
| 64 | .It Nm print Ar scramble | 67 | .It Nm print Ar scramble |
| 65 | Display a text-only description of the cube obtained after applying | 68 | Display a text-only description of the cube obtained after applying |
| 66 | .Ar scramble . | 69 | .Ar scramble . |
| @@ -149,6 +152,9 @@ for the | |||
| 149 | .Ar solve | 152 | .Ar solve |
| 150 | command. | 153 | command. |
| 151 | . | 154 | . |
| 155 | .It Nm unniss Ar scramble | ||
| 156 | Rewrite the scramble without using NISS. | ||
| 157 | . | ||
| 152 | .It Nm version | 158 | .It Nm version |
| 153 | Display version information. | 159 | Display version information. |
| 154 | . | 160 | . |
| Binary files differ | |||
| Binary files differ | |||
diff --git a/src/commands.c b/src/commands.c index 85b62ac..7d30c88 100644 --- a/src/commands.c +++ b/src/commands.c | |||
| @@ -6,17 +6,20 @@ CommandArgs * solve_parse_args(int c, char **v); | |||
| 6 | CommandArgs * gen_parse_args(int c, char **v); | 6 | CommandArgs * gen_parse_args(int c, char **v); |
| 7 | CommandArgs * help_parse_args(int c, char **v); | 7 | CommandArgs * help_parse_args(int c, char **v); |
| 8 | CommandArgs * print_parse_args(int c, char **v); | 8 | CommandArgs * print_parse_args(int c, char **v); |
| 9 | CommandArgs * parse_only_scramble(int c, char **v); | ||
| 9 | CommandArgs * parse_no_arg(int c, char **v); | 10 | CommandArgs * parse_no_arg(int c, char **v); |
| 10 | 11 | ||
| 11 | /* Exec functions ************************************************************/ | 12 | /* Exec functions ************************************************************/ |
| 12 | 13 | ||
| 13 | static void gen_exec(CommandArgs *args); | 14 | static void gen_exec(CommandArgs *args); |
| 15 | static void invert_exec(CommandArgs *args); | ||
| 14 | static void solve_exec(CommandArgs *args); | 16 | static void solve_exec(CommandArgs *args); |
| 15 | static void steps_exec(CommandArgs *args); | 17 | static void steps_exec(CommandArgs *args); |
| 16 | static void commands_exec(CommandArgs *args); | 18 | static void commands_exec(CommandArgs *args); |
| 17 | static void print_exec(CommandArgs *args); | 19 | static void print_exec(CommandArgs *args); |
| 18 | static void help_exec(CommandArgs *args); | 20 | static void help_exec(CommandArgs *args); |
| 19 | static void quit_exec(CommandArgs *args); | 21 | static void quit_exec(CommandArgs *args); |
| 22 | static void unniss_exec(CommandArgs *args); | ||
| 20 | static void version_exec(CommandArgs *args); | 23 | static void version_exec(CommandArgs *args); |
| 21 | 24 | ||
| 22 | /* Local functions ***********************************************************/ | 25 | /* Local functions ***********************************************************/ |
| @@ -45,6 +48,15 @@ gen_cmd = { | |||
| 45 | }; | 48 | }; |
| 46 | 49 | ||
| 47 | Command | 50 | Command |
| 51 | invert_cmd = { | ||
| 52 | .name = "invert", | ||
| 53 | .usage = "invert SCRAMBLE]", | ||
| 54 | .description = "Invert a scramble", | ||
| 55 | .parse_args = parse_only_scramble, | ||
| 56 | .exec = invert_exec, | ||
| 57 | }; | ||
| 58 | |||
| 59 | Command | ||
| 48 | steps_cmd = { | 60 | steps_cmd = { |
| 49 | .name = "steps", | 61 | .name = "steps", |
| 50 | .usage = "steps", | 62 | .usage = "steps", |
| @@ -90,6 +102,15 @@ quit_cmd = { | |||
| 90 | }; | 102 | }; |
| 91 | 103 | ||
| 92 | Command | 104 | Command |
| 105 | unniss_cmd = { | ||
| 106 | .name = "unniss", | ||
| 107 | .usage = "unniss SCRAMBLE", | ||
| 108 | .description = "Rewrite a scramble without NISS", | ||
| 109 | .parse_args = parse_only_scramble, | ||
| 110 | .exec = unniss_exec, | ||
| 111 | }; | ||
| 112 | |||
| 113 | Command | ||
| 93 | version_cmd = { | 114 | version_cmd = { |
| 94 | .name = "version", | 115 | .name = "version", |
| 95 | .usage = "version", | 116 | .usage = "version", |
| @@ -102,10 +123,12 @@ Command *commands[NCOMMANDS] = { | |||
| 102 | &commands_cmd, | 123 | &commands_cmd, |
| 103 | &gen_cmd, | 124 | &gen_cmd, |
| 104 | &help_cmd, | 125 | &help_cmd, |
| 126 | &invert_cmd, | ||
| 105 | &print_cmd, | 127 | &print_cmd, |
| 106 | &quit_cmd, | 128 | &quit_cmd, |
| 107 | &solve_cmd, | 129 | &solve_cmd, |
| 108 | &steps_cmd, | 130 | &steps_cmd, |
| 131 | &unniss_cmd, | ||
| 109 | &version_cmd, | 132 | &version_cmd, |
| 110 | }; | 133 | }; |
| 111 | 134 | ||
| @@ -245,6 +268,16 @@ help_parse_args(int c, char **v) | |||
| 245 | } | 268 | } |
| 246 | 269 | ||
| 247 | CommandArgs * | 270 | CommandArgs * |
| 271 | parse_only_scramble(int c, char **v) | ||
| 272 | { | ||
| 273 | CommandArgs *a = new_args(); | ||
| 274 | |||
| 275 | a->success = read_scramble(c, v, a); | ||
| 276 | |||
| 277 | return a; | ||
| 278 | } | ||
| 279 | |||
| 280 | CommandArgs * | ||
| 248 | parse_no_arg(int c, char **v) | 281 | parse_no_arg(int c, char **v) |
| 249 | { | 282 | { |
| 250 | CommandArgs *a = new_args(); | 283 | CommandArgs *a = new_args(); |
| @@ -303,6 +336,17 @@ gen_exec(CommandArgs *args) | |||
| 303 | } | 336 | } |
| 304 | 337 | ||
| 305 | static void | 338 | static void |
| 339 | invert_exec(CommandArgs *args) | ||
| 340 | { | ||
| 341 | Alg *inv; | ||
| 342 | |||
| 343 | inv = inverse_alg(args->scramble); | ||
| 344 | print_alg(inv, false); | ||
| 345 | |||
| 346 | free_alg(inv); | ||
| 347 | } | ||
| 348 | |||
| 349 | static void | ||
| 306 | steps_exec(CommandArgs *args) | 350 | steps_exec(CommandArgs *args) |
| 307 | { | 351 | { |
| 308 | int i; | 352 | int i; |
| @@ -357,6 +401,13 @@ quit_exec(CommandArgs *args) | |||
| 357 | } | 401 | } |
| 358 | 402 | ||
| 359 | static void | 403 | static void |
| 404 | unniss_exec(CommandArgs *args) | ||
| 405 | { | ||
| 406 | unniss(args->scramble); | ||
| 407 | print_alg(args->scramble, false); | ||
| 408 | } | ||
| 409 | |||
| 410 | static void | ||
| 360 | version_exec(CommandArgs *args) | 411 | version_exec(CommandArgs *args) |
| 361 | { | 412 | { |
| 362 | printf(VERSION"\n"); | 413 | printf(VERSION"\n"); |
diff --git a/src/commands.h b/src/commands.h index 938a0bd..7773827 100644 --- a/src/commands.h +++ b/src/commands.h | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | #include "solve.h" | 4 | #include "solve.h" |
| 5 | #include "steps.h" | 5 | #include "steps.h" |
| 6 | 6 | ||
| 7 | #define NCOMMANDS 10 | 7 | #define NCOMMANDS 20 |
| 8 | 8 | ||
| 9 | void free_args(CommandArgs *args); | 9 | void free_args(CommandArgs *args); |
| 10 | CommandArgs * new_args(); | 10 | CommandArgs * new_args(); |
