diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-12-15 16:07:12 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-12-15 16:07:12 +0100 |
| commit | de70dc746f16607e2110f2c6acee8ed8ba2507f8 (patch) | |
| tree | dc1a7d31e71812e103576a33de12e79461d581db /tools/400_solvetest/solve_test.c | |
| parent | 6008855b28763f297f4379dfcdc23eacb303ee45 (diff) | |
| download | nissy-core-de70dc746f16607e2110f2c6acee8ed8ba2507f8.tar.gz nissy-core-de70dc746f16607e2110f2c6acee8ed8ba2507f8.zip | |
Added more scrambles, found bug
Diffstat (limited to 'tools/400_solvetest/solve_test.c')
| -rw-r--r-- | tools/400_solvetest/solve_test.c | 38 |
1 files changed, 7 insertions, 31 deletions
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; |
