diff options
Diffstat (limited to 'tools/400_solvetest')
| -rw-r--r-- | tools/400_solvetest/scrambles.h | 62 | ||||
| -rw-r--r-- | tools/400_solvetest/solve_test.c | 38 |
2 files changed, 69 insertions, 31 deletions
diff --git a/tools/400_solvetest/scrambles.h b/tools/400_solvetest/scrambles.h new file mode 100644 index 0000000..59037be --- /dev/null +++ b/tools/400_solvetest/scrambles.h | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | struct { | ||
| 2 | char *scramble; | ||
| 3 | char *solutions; | ||
| 4 | } s[] = { | ||
| 5 | [0] = { | ||
| 6 | .scramble = "R' D R U R' D' R U'", | ||
| 7 | .solutions = | ||
| 8 | "U R' D R U' R' D' R\n" | ||
| 9 | "B' D2 B U' B' D2 B U\n" | ||
| 10 | }, | ||
| 11 | [1] = { | ||
| 12 | .scramble = "R' L U2 R L' B2", | ||
| 13 | .solutions = | ||
| 14 | "B2 R' L U2 R L'\n" | ||
| 15 | "R L' B2 R' L U2\n" | ||
| 16 | "R B2 R' L U2 L'\n" | ||
| 17 | "L' B2 R' L U2 R\n" | ||
| 18 | }, | ||
| 19 | [2] = { | ||
| 20 | .scramble = "R2 U2 R2 U2 R2 U2", | ||
| 21 | .solutions = | ||
| 22 | "U2 R2 U2 R2 U2 R2\n" | ||
| 23 | "D2 L2 U2 L2 D2 R2\n" | ||
| 24 | "U2 L2 D2 R2 D2 L2\n" | ||
| 25 | "D2 R2 D2 L2 U2 L2\n" | ||
| 26 | "R2 U2 R2 U2 R2 U2\n" | ||
| 27 | "L2 D2 R2 D2 L2 U2\n" | ||
| 28 | "R2 D2 L2 U2 L2 D2\n" | ||
| 29 | "L2 U2 L2 D2 R2 D2\n" | ||
| 30 | }, | ||
| 31 | [3] = { | ||
| 32 | .scramble = "R U2 R' U' R U2 L' U R' U' L", /* J-perm */ | ||
| 33 | .solutions = | ||
| 34 | "R2 D' R' D R' B2 L U' L' B2\n" | ||
| 35 | "B2 L U L' B2 R D' R D R2\n" | ||
| 36 | }, | ||
| 37 | [4] = { | ||
| 38 | .scramble = "R' U' F D2 L2 F R2 U2 R2 B D2 L B2" | ||
| 39 | "D' B2 L' R' B D2 B U2 L U2 R' U' F", /* FMC2019 A1 */ | ||
| 40 | .solutions = | ||
| 41 | "D2 F' U2 D2 F' L2 D R2 D F B2 R' L2 F' U' D\n" | ||
| 42 | }, | ||
| 43 | [5] = { | ||
| 44 | .scramble = "L B' D2 R2 L2 B' U2 D2 R L' U F2", /* Taken from 6 */ | ||
| 45 | .solutions = | ||
| 46 | "B2 R2 L2 D F2 B2 R' L F' U2 B L'\n" | ||
| 47 | "F2 U' R' L U2 D2 B R2 L2 D2 B L'\n" | ||
| 48 | }, | ||
| 49 | [6] = { | ||
| 50 | .scramble = "R L' B R L' D R L' F R L' U" | ||
| 51 | "R' L F R L' D R L' B R L' U", /* Random thing */ | ||
| 52 | .solutions = | ||
| 53 | "U' R L' B' D2 F R' L F2 B2 U' F2 R2 L2 U2\n" | ||
| 54 | "U' R L' B' R2 L2 U2 B' U2 D2 R' L D B2 U2\n" | ||
| 55 | "D2 R' L F R' B' R U B U L F' U' F' D\n" | ||
| 56 | "D' R' L B' U2 F R L' F2 B2 D' R2 L2 B2 D2\n" | ||
| 57 | "D' R' L B' D2 R2 L2 B' U2 D2 R L' U F2 D2\n" | ||
| 58 | }, | ||
| 59 | { | ||
| 60 | .scramble = "", /* End-of-list signal */ | ||
| 61 | } | ||
| 62 | }; | ||
diff --git a/tools/400_solvetest/solve_test.c b/tools/400_solvetest/solve_test.c index 14b3e04..9b6c094 100644 --- a/tools/400_solvetest/solve_test.c +++ b/tools/400_solvetest/solve_test.c | |||
| @@ -1,35 +1,12 @@ | |||
| 1 | #include "../tool.h" | 1 | #include "../tool.h" |
| 2 | #include "scrambles.h" | ||
| 2 | 3 | ||
| 3 | #define SOL_BUFFER_LEN 10000 | 4 | #define SOL_BUFFER_LEN 100000 |
| 4 | |||
| 5 | typedef struct { | ||
| 6 | char *scramble; | ||
| 7 | char *solutions; | ||
| 8 | } scramblesol_t; | ||
| 9 | 5 | ||
| 10 | char *solver; | 6 | char *solver; |
| 11 | int64_t size = 0; | 7 | int64_t size = 0; |
| 12 | char *buf; | 8 | char *buf; |
| 13 | 9 | ||
| 14 | scramblesol_t s[] = { | ||
| 15 | [0] = { | ||
| 16 | .scramble = "R' D R U R' D' R U'", | ||
| 17 | .solutions = | ||
| 18 | "U R' D R U' R' D' R\n" | ||
| 19 | "B' D2 B U' B' D2 B U\n" | ||
| 20 | }, | ||
| 21 | [1] = { | ||
| 22 | .scramble = "R' L U2 R L' B2", | ||
| 23 | .solutions = | ||
| 24 | "B2 R' L U2 R L'\n" | ||
| 25 | "R L' B2 R' L U2\n" | ||
| 26 | "R B2 R' L U2 L'\n" | ||
| 27 | "L' B2 R' L U2 R\n" | ||
| 28 | }, | ||
| 29 | { | ||
| 30 | .scramble = "", /* End-of-list signal */ | ||
| 31 | } | ||
| 32 | }; | ||
| 33 | 10 | ||
| 34 | bool check_one(char *actual, char *expected) { | 11 | bool check_one(char *actual, char *expected) { |
| 35 | unsigned i; | 12 | unsigned i; |
| @@ -83,14 +60,13 @@ void run(void) { | |||
| 83 | n = nissy_solve(cube, solver, NISSY_NISSFLAG_NORMAL, | 60 | n = nissy_solve(cube, solver, NISSY_NISSFLAG_NORMAL, |
| 84 | 0, 20, 1, -1, 0, size, buf, SOL_BUFFER_LEN, sol, stats); | 61 | 0, 20, 1, -1, 0, size, buf, SOL_BUFFER_LEN, sol, stats); |
| 85 | if (n == 0) { | 62 | if (n == 0) { |
| 86 | printf("Error! No solution found for scramble %s\n", | 63 | printf("Error: no solution\n"); |
| 87 | s[i].scramble); | ||
| 88 | return; | 64 | return; |
| 89 | } | 65 | } |
| 90 | if (check_one(sol, s[i].solutions)) { | 66 | if (check_one(sol, s[i].solutions)) { |
| 91 | printf("Single solution for scramble %d is correct\n", i); | 67 | printf("Single solution is correct\n"); |
| 92 | } else { | 68 | } else { |
| 93 | printf("Error! Scramble %d: %s\n", i, s[i].scramble); | 69 | printf("Error!\n"); |
| 94 | printf("Found solution(s):\n%s", sol); | 70 | printf("Found solution(s):\n%s", sol); |
| 95 | printf("Valid solution(s):\n%s", s[i].solutions); | 71 | printf("Valid solution(s):\n%s", s[i].solutions); |
| 96 | return; | 72 | return; |
| @@ -105,9 +81,9 @@ void run(void) { | |||
| 105 | n = nissy_solve(cube, solver, NISSY_NISSFLAG_NORMAL, | 81 | n = nissy_solve(cube, solver, NISSY_NISSFLAG_NORMAL, |
| 106 | 0, 20, 100, 0, 0, size, buf, SOL_BUFFER_LEN, sol, stats); | 82 | 0, 20, 100, 0, 0, size, buf, SOL_BUFFER_LEN, sol, stats); |
| 107 | if (check_all(sol, s[i].solutions)) { | 83 | if (check_all(sol, s[i].solutions)) { |
| 108 | printf("All solutions for scramble %d are correct\n", i); | 84 | printf("All solutions are correct\n"); |
| 109 | } else { | 85 | } else { |
| 110 | printf("Error! Scramble %s\n", s[i].scramble); | 86 | printf("Error!\n"); |
| 111 | printf("Found solution(s):\n%s", sol); | 87 | printf("Found solution(s):\n%s", sol); |
| 112 | printf("Valid solution(s):\n%s", s[i].solutions); | 88 | printf("Valid solution(s):\n%s", s[i].solutions); |
| 113 | return; | 89 | return; |
