aboutsummaryrefslogtreecommitdiff
path: root/tools/300_solve_small
diff options
context:
space:
mode:
Diffstat (limited to 'tools/300_solve_small')
-rw-r--r--tools/300_solve_small/solve_small.c53
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
5const char *solver = "h48";
6const char *options = "0;4;20";
7const char *filename = "tables/h48h0k4";
8char *buf;
9
10char *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
16void 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
41int 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}

Generated with cgit - Back to sebastiano.tronto.net