diff options
Diffstat (limited to 'tools/300_solve_small')
| -rw-r--r-- | tools/300_solve_small/solve_small.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/tools/300_solve_small/solve_small.c b/tools/300_solve_small/solve_small.c index ade949a..5400436 100644 --- a/tools/300_solve_small/solve_small.c +++ b/tools/300_solve_small/solve_small.c | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | #include "../tool.h" | 1 | #include "../tool.h" |
| 2 | 2 | ||
| 3 | #define SOL_BUFFER_LEN 1000 | ||
| 4 | |||
| 3 | const char *solver = "h48h0k4"; | 5 | const char *solver = "h48h0k4"; |
| 6 | int64_t size = 0; | ||
| 4 | char *buf; | 7 | char *buf; |
| 5 | 8 | ||
| 6 | char *scrambles[] = { | 9 | char *scrambles[] = { |
| @@ -14,25 +17,22 @@ char *scrambles[] = { | |||
| 14 | void run(void) { | 17 | void run(void) { |
| 15 | int i; | 18 | int i; |
| 16 | int64_t n; | 19 | int64_t n; |
| 17 | char sol[100], cube[22]; | 20 | char sol[SOL_BUFFER_LEN], cube[22]; |
| 18 | 21 | ||
| 19 | printf("Solved the following scrambles:\n\n"); | 22 | printf("Solved the following scrambles:\n\n"); |
| 20 | for (i = 0; scrambles[i] != NULL; i++) { | 23 | for (i = 0; scrambles[i] != NULL; i++) { |
| 21 | printf("%d. %s\n", i+1, scrambles[i]); | 24 | printf("%d. %s\n", i+1, scrambles[i]); |
| 22 | fprintf(stderr, "Solving scramble %s\n", scrambles[i]); | 25 | printf("Solving scramble %s\n", scrambles[i]); |
| 23 | if (nissy_frommoves(scrambles[i], cube) == -1) { | 26 | if (nissy_frommoves(scrambles[i], cube) == -1) { |
| 24 | fprintf(stderr, "Invalid scramble\n"); | 27 | printf("Invalid scramble\n"); |
| 25 | printf("Invalid\n"); | ||
| 26 | continue; | 28 | continue; |
| 27 | } | 29 | } |
| 28 | n = nissy_solve( | 30 | n = nissy_solve(cube, solver, NISSY_NISSFLAG_NORMAL, |
| 29 | cube, solver, "", 0, 20, 1, -1, buf, sol); | 31 | 0, 20, 1, -1, size, buf, SOL_BUFFER_LEN, sol); |
| 30 | if (n == 0) { | 32 | if (n == 0) |
| 31 | printf("No solution\n"); | 33 | printf("No solution found\n"); |
| 32 | fprintf(stderr, "No solution found\n"); | 34 | else |
| 33 | } else { | ||
| 34 | printf("Solutions:\n%s\n", sol); | 35 | printf("Solutions:\n%s\n", sol); |
| 35 | } | ||
| 36 | } | 36 | } |
| 37 | } | 37 | } |
| 38 | 38 | ||
| @@ -46,6 +46,8 @@ int main(void) { | |||
| 46 | if (getdata(solver, &buf, filename) != 0) | 46 | if (getdata(solver, &buf, filename) != 0) |
| 47 | return 1; | 47 | return 1; |
| 48 | 48 | ||
| 49 | size = nissy_datasize(solver); | ||
| 50 | |||
| 49 | timerun(run); | 51 | timerun(run); |
| 50 | 52 | ||
| 51 | free(buf); | 53 | free(buf); |
