aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md7
-rwxr-xr-xcompile.sh1
-rw-r--r--docs/scramble.txt22
-rwxr-xr-xnissybin518520 -> 520584 bytes
-rwxr-xr-xsrc/compile.sh1
-rw-r--r--src/main.c48
6 files changed, 65 insertions, 14 deletions
diff --git a/README.md b/README.md
index 581f36c..1278b31 100644
--- a/README.md
+++ b/README.md
@@ -25,13 +25,12 @@ compiler to use the [C99 standard](https://en.wikipedia.org/wiki/C99). For
25example, on a Linux system with GCC installed: 25example, on a Linux system with GCC installed:
26 26
27``` 27```
28cd path/to/nissy/src 28cd path/to/nissy
29gcc -O3 -std=c99 -o ../nissy *.c 29gcc -O3 -std=c99 -o nissy ./src/*.c
30cd ..
31./nissy 30./nissy
32``` 31```
33 32
34You can also use the script compile.sh in the src folder, which executes that 33You can also use the script compile.sh, which executes that
35gcc line (with a few extra options). 34gcc line (with a few extra options).
36 35
37## Tips 36## Tips
diff --git a/compile.sh b/compile.sh
new file mode 100755
index 0000000..4e14a0b
--- /dev/null
+++ b/compile.sh
@@ -0,0 +1 @@
gcc -Wall -Wextra -O3 -std=c99 -o nissy -g ./src/*.c
diff --git a/docs/scramble.txt b/docs/scramble.txt
new file mode 100644
index 0000000..dad8ba7
--- /dev/null
+++ b/docs/scramble.txt
@@ -0,0 +1,22 @@
1
2HELP PAGE FOR COMMAND scramble
3
4SYNTAX
5scramble [OPTIONS]
6
7DESCRIPTION
8Produces a random-state scramble. There are options to get a corners-only,
9edges-only or dr-state scramble.
10
11OPTIONS
12c Scrambles corners only (edges are solved).
13e Scrambles edges only (corners are solved).
14dr DR-state scramble. The DR is always on the U/D axis.
15
16
17EXAMPLES
18scramble
19 Gives a random-state scramble
20scramble dr
21 Gives a random-DR-state scramble
22
diff --git a/nissy b/nissy
index 2ff6c82..2265a77 100755
--- a/nissy
+++ b/nissy
Binary files differ
diff --git a/src/compile.sh b/src/compile.sh
deleted file mode 100755
index 49d655e..0000000
--- a/src/compile.sh
+++ /dev/null
@@ -1 +0,0 @@
1gcc -Wall -Wextra -O3 -std=c99 -o ../nissy -g *.c
diff --git a/src/main.c b/src/main.c
index 125e4ec..d68f4af 100644
--- a/src/main.c
+++ b/src/main.c
@@ -12,8 +12,8 @@
12char *commands[][10] = { 12char *commands[][10] = {
13 {"help", "[COMMAND]", 13 {"help", "[COMMAND]",
14 "Print this help, or a help page for COMMAND."}, 14 "Print this help, or a help page for COMMAND."},
15 {"scramble", "", 15 {"scramble", "[OPTIONS]",
16 "Prints a random-state scramble"}, 16 "Prints a random-state scramble."},
17 {"save", "[MOVES|@ID|$ID]", 17 {"save", "[MOVES|@ID|$ID]",
18 "Save or copy a scramble."}, 18 "Save or copy a scramble."},
19 {"change", "$ID1 [MOVES|$ID2|@ID2]", 19 {"change", "$ID1 [MOVES|$ID2|@ID2]",
@@ -124,7 +124,7 @@ void help_cmd(int n, char cmdtok[][100]) {
124 if (n == 1) { 124 if (n == 1) {
125 printf("\n"); 125 printf("\n");
126 for (int i = 0; commands[i][0][0]; i++) 126 for (int i = 0; commands[i][0][0]; i++)
127 printf("%-10s%-20s%s\n", commands[i][0], commands[i][1], commands[i][2]); 127 printf("%-10s%-25s%s\n", commands[i][0], commands[i][1], commands[i][2]);
128 printf("\n"); 128 printf("\n");
129 printf("Type \'help\' followed by a command for a detailed help page.\n"); 129 printf("Type \'help\' followed by a command for a detailed help page.\n");
130 printf("Type \'help nissy\' for a general user guide.\n"); 130 printf("Type \'help nissy\' for a general user guide.\n");
@@ -145,24 +145,54 @@ void help_cmd(int n, char cmdtok[][100]) {
145} 145}
146 146
147void scramble_cmd(int n, char cmdtok[][100]) { 147void scramble_cmd(int n, char cmdtok[][100]) {
148 if (n > 1 || cmdtok[0][0] != 's') { /* Second case avoids warning */ 148 int c = 0, e = 0, dr = 0;
149
150 if (n > 2 || cmdtok[0][0] != 's') { /* Second case avoids warning */
149 printf("scramble: wrong syntax\n"); 151 printf("scramble: wrong syntax\n");
150 return; 152 return;
153 } else if (n == 2) {
154 if (!strcmp(cmdtok[1], "c")) {
155 c = 1;
156 } else if (!strcmp(cmdtok[1], "e")) {
157 e = 1;
158 } else if (!strcmp(cmdtok[1], "dr")) {
159 dr = 1;
160 } else {
161 printf("scramble: wrong syntax\n");
162 return;
163 }
151 } 164 }
152 165
166 int scram[2][30];
167
153 srand(time(NULL)); 168 srand(time(NULL));
154 int eofb = rand() % pow2to11; 169 int eofb = rand() % pow2to11;
155 int coud = rand() % pow3to7; 170 int coud = rand() % pow3to7;
156 int ep = rand() % factorial12; 171 int ep = rand() % factorial12;
157 int cp = rand() % factorial8; 172 int cp = rand() % factorial8;
158 while (perm_sign_int(ep, 12) != perm_sign_int(cp, 8)) 173
159 ep = (ep+1) % factorial12; 174 if (c) {
175 eofb = ep = 0;
176 } else if (e) {
177 coud = cp = 0;
178 } else if (dr) {
179 eofb = coud = 0;
180 int epud = rand() % factorial8;
181 int epe = rand() % factorial4;
182 int ep_arr[12];
183 epud_int_to_array(epud, ep_arr);
184 epe_int_to_array(epe, ep_arr);
185 ep = ep_array_to_int(ep_arr);
186 while (perm_sign_int(ep, 12) != perm_sign_int(cp, 8))
187 cp = (cp+1) % factorial8;
188 } else {
189 while (perm_sign_int(ep, 12) != perm_sign_int(cp, 8))
190 cp = (cp+1) % factorial8;
191 }
160 192
193 reach_state(eofb, coud, ep, cp, scram);
161 /* Debug */ 194 /* Debug */
162 /* printf("State: %d %d %d %d\n", eofb, coud, ep, cp); */ 195 /* printf("State: %d %d %d %d\n", eofb, coud, ep, cp); */
163
164 int scram[2][30];
165 reach_state(eofb, coud, ep, cp, scram);
166 print_results(1, scram); 196 print_results(1, scram);
167} 197}
168 198

Generated with cgit - Back to sebastiano.tronto.net