diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-26 14:59:11 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-26 15:00:16 +0200 |
| commit | 818186b480d7c05e0c58ff89da2180f5b2476434 (patch) | |
| tree | 0f6e4919d4001775a4820dffd29448dbd20c00db /tools/300_solve_small | |
| parent | bb09e52a7481718ae1fe324d16b99970450908f8 (diff) | |
| download | nissy-core-818186b480d7c05e0c58ff89da2180f5b2476434.tar.gz nissy-core-818186b480d7c05e0c58ff89da2180f5b2476434.zip | |
Added TOOLARGS and simplified gendata tool(s)
Diffstat (limited to 'tools/300_solve_small')
| -rw-r--r-- | tools/300_solve_small/solve_small.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tools/300_solve_small/solve_small.c b/tools/300_solve_small/solve_small.c new file mode 100644 index 0000000..4d07728 --- /dev/null +++ b/tools/300_solve_small/solve_small.c | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | #include <pthread.h> | ||
| 2 | |||
| 3 | #include "../tool.h" | ||
| 4 | |||
| 5 | const char *solver = "h48"; | ||
| 6 | const char *options = "0;4;20"; | ||
| 7 | const char *filename = "tables/h48h0k4"; | ||
| 8 | char *buf; | ||
| 9 | |||
| 10 | char *scrambles[] = { | ||
| 11 | "R D' R2 D R U2 R' D' R U2 R D R'", /* 12 optimal */ | ||
| 12 | "RLUD RLUD RLUD", /* 12 optimal */ | ||
| 13 | NULL | ||
| 14 | }; | ||
| 15 | |||
| 16 | void run(void) { | ||
| 17 | int i; | ||
| 18 | int64_t n; | ||
| 19 | char sol[100], cube[22]; | ||
| 20 | |||
| 21 | printf("Solved the following scrambles:\n\n"); | ||
| 22 | for (i = 0; scrambles[i] != NULL; i++) { | ||
| 23 | printf("%d. %s\n", i+1, scrambles[i]); | ||
| 24 | fprintf(stderr, "Solving scramble %s\n", scrambles[i]); | ||
| 25 | if (nissy_frommoves(scrambles[i], cube) == -1) { | ||
| 26 | fprintf(stderr, "Invalid scramble\n"); | ||
| 27 | printf("Invalid\n"); | ||
| 28 | continue; | ||
| 29 | } | ||
| 30 | n = nissy_solve( | ||
| 31 | cube, "h48", options, "", 0, 20, 1, -1, buf, sol); | ||
| 32 | if (n == 0) { | ||
| 33 | printf("No solution\n"); | ||
| 34 | fprintf(stderr, "No solution found\n"); | ||
| 35 | } else { | ||
| 36 | printf("Solutions:\n%s\n", sol); | ||
| 37 | } | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | int main(void) { | ||
| 42 | |||
| 43 | srand(time(NULL)); | ||
| 44 | nissy_setlogger(log_stderr); | ||
| 45 | |||
| 46 | if (getdata(solver, options, &buf, filename) != 0) | ||
| 47 | return 1; | ||
| 48 | |||
| 49 | timerun(run, "small solver benchmark"); | ||
| 50 | |||
| 51 | free(buf); | ||
| 52 | return 0; | ||
| 53 | } | ||
