From 0f81a5a70be20a82ee8495f050366a28d0be21c7 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sat, 25 Dec 2021 20:29:22 +0100 Subject: Added the invert and unniss commands --- TODO.md | 6 ++++-- doc/nissy.1 | 6 ++++++ nissy | Bin 321848 -> 318128 bytes nissy.exe | Bin 783134 -> 783308 bytes src/commands.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/commands.h | 2 +- 6 files changed, 62 insertions(+), 3 deletions(-) diff --git a/TODO.md b/TODO.md index 52ccd30..f3830f1 100644 --- a/TODO.md +++ b/TODO.md @@ -10,7 +10,6 @@ It's more of a personal reminder than anything else. ### Commands that are available in nissy 1.0, but not in this version (yet): * drcorners (solve corners after dr) * search and improve non-optimal subsequences -* **unniss (rewrite A (B) -> B' A)** * **fast non-optimal solver (also needed for scramble)** * **scramble [dr, corners only, edges only, htr, fmc(RUF)...]** * save and edit algs as "variables" @@ -34,7 +33,8 @@ including e.g. solutions that were not shown because -c) * **cleanup: translate an alg to the standard HTM moveset + reorient at the end** * configurability: add an `alias` command, run config file at startup * configure max ram to be used (via config file and/or command line option) -* **invert an alg, transform, rufify etc...** +* transform alg, rufify etc... +* more scramble stuff (scramble FMC with rufify...) * **command notation to list available moves** ## Distribution @@ -76,3 +76,5 @@ including e.g. solutions that were not shown because -c) * sort again functions alphabetically in their files * **more stuff to load at start (or when suitable command is called) rather than when called directly, to avoid nasty problems with threading** +* unniss and inverse_alg work differently (one in place, the other makes + 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 .Ar command is returned. . +.It Nm invert Ar scramble +Invert the given scramble. +. .It Nm print Ar scramble Display a text-only description of the cube obtained after applying .Ar scramble . @@ -149,6 +152,9 @@ for the .Ar solve command. . +.It Nm unniss Ar scramble +Rewrite the scramble without using NISS. +. .It Nm version Display version information. . diff --git a/nissy b/nissy index cd1ee30..177afa4 100755 Binary files a/nissy and b/nissy differ diff --git a/nissy.exe b/nissy.exe index fdf8676..b941199 100755 Binary files a/nissy.exe and b/nissy.exe 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); CommandArgs * gen_parse_args(int c, char **v); CommandArgs * help_parse_args(int c, char **v); CommandArgs * print_parse_args(int c, char **v); +CommandArgs * parse_only_scramble(int c, char **v); CommandArgs * parse_no_arg(int c, char **v); /* Exec functions ************************************************************/ static void gen_exec(CommandArgs *args); +static void invert_exec(CommandArgs *args); static void solve_exec(CommandArgs *args); static void steps_exec(CommandArgs *args); static void commands_exec(CommandArgs *args); static void print_exec(CommandArgs *args); static void help_exec(CommandArgs *args); static void quit_exec(CommandArgs *args); +static void unniss_exec(CommandArgs *args); static void version_exec(CommandArgs *args); /* Local functions ***********************************************************/ @@ -44,6 +47,15 @@ gen_cmd = { .exec = gen_exec }; +Command +invert_cmd = { + .name = "invert", + .usage = "invert SCRAMBLE]", + .description = "Invert a scramble", + .parse_args = parse_only_scramble, + .exec = invert_exec, +}; + Command steps_cmd = { .name = "steps", @@ -89,6 +101,15 @@ quit_cmd = { .exec = quit_exec, }; +Command +unniss_cmd = { + .name = "unniss", + .usage = "unniss SCRAMBLE", + .description = "Rewrite a scramble without NISS", + .parse_args = parse_only_scramble, + .exec = unniss_exec, +}; + Command version_cmd = { .name = "version", @@ -102,10 +123,12 @@ Command *commands[NCOMMANDS] = { &commands_cmd, &gen_cmd, &help_cmd, + &invert_cmd, &print_cmd, &quit_cmd, &solve_cmd, &steps_cmd, + &unniss_cmd, &version_cmd, }; @@ -244,6 +267,16 @@ help_parse_args(int c, char **v) return a; } +CommandArgs * +parse_only_scramble(int c, char **v) +{ + CommandArgs *a = new_args(); + + a->success = read_scramble(c, v, a); + + return a; +} + CommandArgs * parse_no_arg(int c, char **v) { @@ -302,6 +335,17 @@ gen_exec(CommandArgs *args) fprintf(stderr, "Done!\n"); } +static void +invert_exec(CommandArgs *args) +{ + Alg *inv; + + inv = inverse_alg(args->scramble); + print_alg(inv, false); + + free_alg(inv); +} + static void steps_exec(CommandArgs *args) { @@ -356,6 +400,13 @@ quit_exec(CommandArgs *args) exit(0); } +static void +unniss_exec(CommandArgs *args) +{ + unniss(args->scramble); + print_alg(args->scramble, false); +} + static void version_exec(CommandArgs *args) { 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 @@ #include "solve.h" #include "steps.h" -#define NCOMMANDS 10 +#define NCOMMANDS 20 void free_args(CommandArgs *args); CommandArgs * new_args(); -- cgit v1.3