From 818186b480d7c05e0c58ff89da2180f5b2476434 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 26 Sep 2024 14:59:11 +0200 Subject: Added TOOLARGS and simplified gendata tool(s) --- tools/300_solve_small/solve_small.c | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tools/300_solve_small/solve_small.c (limited to 'tools/300_solve_small') 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 @@ +#include + +#include "../tool.h" + +const char *solver = "h48"; +const char *options = "0;4;20"; +const char *filename = "tables/h48h0k4"; +char *buf; + +char *scrambles[] = { + "R D' R2 D R U2 R' D' R U2 R D R'", /* 12 optimal */ + "RLUD RLUD RLUD", /* 12 optimal */ + NULL +}; + +void run(void) { + int i; + int64_t n; + char sol[100], cube[22]; + + printf("Solved the following scrambles:\n\n"); + for (i = 0; scrambles[i] != NULL; i++) { + printf("%d. %s\n", i+1, scrambles[i]); + fprintf(stderr, "Solving scramble %s\n", scrambles[i]); + if (nissy_frommoves(scrambles[i], cube) == -1) { + fprintf(stderr, "Invalid scramble\n"); + printf("Invalid\n"); + continue; + } + n = nissy_solve( + cube, "h48", options, "", 0, 20, 1, -1, buf, sol); + if (n == 0) { + printf("No solution\n"); + fprintf(stderr, "No solution found\n"); + } else { + printf("Solutions:\n%s\n", sol); + } + } +} + +int main(void) { + + srand(time(NULL)); + nissy_setlogger(log_stderr); + + if (getdata(solver, options, &buf, filename) != 0) + return 1; + + timerun(run, "small solver benchmark"); + + free(buf); + return 0; +} -- cgit v1.3