nissy

Where is nissy?
git clone https://git.tronto.net/nissy
Download | Log | Files | Refs | README

commit 0f81a5a70be20a82ee8495f050366a28d0be21c7
parent 4d664cefcc8c5a852629b29d47eb39e628adac57
Author: Sebastiano Tronto <sebastiano.tronto@gmail.com>
Date:   Sat, 25 Dec 2021 20:29:22 +0100

Added the invert and unniss commands

Diffstat:
MTODO.md | 6++++--
Mdoc/nissy.1 | 6++++++
Mnissy | 0
Mnissy.exe | 0
Msrc/commands.c | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/commands.h | 2+-
6 files changed, 62 insertions(+), 3 deletions(-)

diff --git 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 @@ -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 Binary files differ. diff --git a/nissy.exe b/nissy.exe Binary files differ. diff --git 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 ***********************************************************/ @@ -45,6 +48,15 @@ gen_cmd = { }; 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", .usage = "steps", @@ -90,6 +102,15 @@ quit_cmd = { }; 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", .usage = "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, }; @@ -245,6 +268,16 @@ help_parse_args(int c, char **v) } 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) { CommandArgs *a = new_args(); @@ -303,6 +336,17 @@ gen_exec(CommandArgs *args) } 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) { int i; @@ -357,6 +401,13 @@ quit_exec(CommandArgs *args) } static void +unniss_exec(CommandArgs *args) +{ + unniss(args->scramble); + print_alg(args->scramble, false); +} + +static void version_exec(CommandArgs *args) { printf(VERSION"\n"); diff --git 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();