aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano.tronto@gmail.com>2021-12-25 20:29:22 +0100
committerSebastiano Tronto <sebastiano.tronto@gmail.com>2021-12-25 20:29:22 +0100
commit0f81a5a70be20a82ee8495f050366a28d0be21c7 (patch)
tree1d438ad2d3c9fd75ebd10f09d594a4a83fdd3fab
parent4d664cefcc8c5a852629b29d47eb39e628adac57 (diff)
downloadnissy-0f81a5a70be20a82ee8495f050366a28d0be21c7.tar.gz
nissy-0f81a5a70be20a82ee8495f050366a28d0be21c7.zip
Added the invert and unniss commands
-rw-r--r--TODO.md6
-rw-r--r--doc/nissy.16
-rwxr-xr-xnissybin321848 -> 318128 bytes
-rwxr-xr-xnissy.exebin783134 -> 783308 bytes
-rw-r--r--src/commands.c51
-rw-r--r--src/commands.h2
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.
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
62is returned. 62is returned.
63. 63.
64.It Nm invert Ar scramble
65Invert the given scramble.
66.
64.It Nm print Ar scramble 67.It Nm print Ar scramble
65Display a text-only description of the cube obtained after applying 68Display 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
150command. 153command.
151. 154.
155.It Nm unniss Ar scramble
156Rewrite the scramble without using NISS.
157.
152.It Nm version 158.It Nm version
153Display version information. 159Display version information.
154. 160.
diff --git a/nissy b/nissy
index cd1ee30..177afa4 100755
--- a/nissy
+++ b/nissy
Binary files differ
diff --git a/nissy.exe b/nissy.exe
index fdf8676..b941199 100755
--- a/nissy.exe
+++ b/nissy.exe
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);
6CommandArgs * gen_parse_args(int c, char **v); 6CommandArgs * gen_parse_args(int c, char **v);
7CommandArgs * help_parse_args(int c, char **v); 7CommandArgs * help_parse_args(int c, char **v);
8CommandArgs * print_parse_args(int c, char **v); 8CommandArgs * print_parse_args(int c, char **v);
9CommandArgs * parse_only_scramble(int c, char **v);
9CommandArgs * parse_no_arg(int c, char **v); 10CommandArgs * parse_no_arg(int c, char **v);
10 11
11/* Exec functions ************************************************************/ 12/* Exec functions ************************************************************/
12 13
13static void gen_exec(CommandArgs *args); 14static void gen_exec(CommandArgs *args);
15static void invert_exec(CommandArgs *args);
14static void solve_exec(CommandArgs *args); 16static void solve_exec(CommandArgs *args);
15static void steps_exec(CommandArgs *args); 17static void steps_exec(CommandArgs *args);
16static void commands_exec(CommandArgs *args); 18static void commands_exec(CommandArgs *args);
17static void print_exec(CommandArgs *args); 19static void print_exec(CommandArgs *args);
18static void help_exec(CommandArgs *args); 20static void help_exec(CommandArgs *args);
19static void quit_exec(CommandArgs *args); 21static void quit_exec(CommandArgs *args);
22static void unniss_exec(CommandArgs *args);
20static void version_exec(CommandArgs *args); 23static void version_exec(CommandArgs *args);
21 24
22/* Local functions ***********************************************************/ 25/* Local functions ***********************************************************/
@@ -45,6 +48,15 @@ gen_cmd = {
45}; 48};
46 49
47Command 50Command
51invert_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
59Command
48steps_cmd = { 60steps_cmd = {
49 .name = "steps", 61 .name = "steps",
50 .usage = "steps", 62 .usage = "steps",
@@ -90,6 +102,15 @@ quit_cmd = {
90}; 102};
91 103
92Command 104Command
105unniss_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
113Command
93version_cmd = { 114version_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
247CommandArgs * 270CommandArgs *
271parse_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
280CommandArgs *
248parse_no_arg(int c, char **v) 281parse_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
305static void 338static void
339invert_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
349static void
306steps_exec(CommandArgs *args) 350steps_exec(CommandArgs *args)
307{ 351{
308 int i; 352 int i;
@@ -357,6 +401,13 @@ quit_exec(CommandArgs *args)
357} 401}
358 402
359static void 403static void
404unniss_exec(CommandArgs *args)
405{
406 unniss(args->scramble);
407 print_alg(args->scramble, false);
408}
409
410static void
360version_exec(CommandArgs *args) 411version_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
9void free_args(CommandArgs *args); 9void free_args(CommandArgs *args);
10CommandArgs * new_args(); 10CommandArgs * new_args();

Generated with cgit - Back to sebastiano.tronto.net