diff options
Diffstat (limited to '')
| -rw-r--r-- | old/2021-06-14-oldalg/main.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/old/2021-06-14-oldalg/main.c b/old/2021-06-14-oldalg/main.c new file mode 100644 index 0000000..445eefc --- /dev/null +++ b/old/2021-06-14-oldalg/main.c | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | #include "cube.h" | ||
| 3 | |||
| 4 | int main() { | ||
| 5 | Alg *algo; | ||
| 6 | AlgList *sols; | ||
| 7 | Cube cube; | ||
| 8 | SolveOptions opts; | ||
| 9 | char line[1000]; | ||
| 10 | int i, ns = 2, nrand = 100000, sum; | ||
| 11 | |||
| 12 | Step *stps[20] = {&drud_HTM, &optimal_HTM}; | ||
| 13 | char sss[30][30] = {"DR on U/D", "Optimal solution"}; | ||
| 14 | |||
| 15 | opts = (SolveOptions) { | ||
| 16 | .min_moves = 0, | ||
| 17 | .max_moves = 20, | ||
| 18 | .optimal_only = true, | ||
| 19 | .max_solutions = 1, | ||
| 20 | .can_niss = false, | ||
| 21 | .feedback = true | ||
| 22 | }; | ||
| 23 | |||
| 24 | init(); | ||
| 25 | |||
| 26 | /* | ||
| 27 | print_ptable(&pd_drud_HTM); | ||
| 28 | print_ptable(&pd_ep_HTM); | ||
| 29 | print_ptable(&pd_corners_HTM); | ||
| 30 | */ | ||
| 31 | |||
| 32 | srand(time(NULL)); | ||
| 33 | sum = 0; | ||
| 34 | for (i = 0; i < nrand; i++) | ||
| 35 | sum += optimal_HTM.check(random_cube()); | ||
| 36 | printf("Average pruning value: %lf\n", ((double)sum) / ((double) nrand)); | ||
| 37 | |||
| 38 | printf("Welcome to nissy 2.0! Insert a scramble:\n"); | ||
| 39 | |||
| 40 | if (fgets(line, 1000, stdin) != NULL) { | ||
| 41 | algo = new_alg(line); | ||
| 42 | cube = apply_alg(algo, (Cube){0}); | ||
| 43 | |||
| 44 | for (i = 0; i < ns; i++) { | ||
| 45 | if (stps[i]->check == NULL) | ||
| 46 | fprintf(stderr, "Check function for step %d is null\n", i); | ||
| 47 | sols = solve(cube, *stps[i], &opts); | ||
| 48 | printf("%s: %d solutions found:\n", sss[i], sols->len); | ||
| 49 | print_alglist(sols, true); | ||
| 50 | free_alglist(sols); | ||
| 51 | } | ||
| 52 | free(algo); | ||
| 53 | } | ||
| 54 | |||
| 55 | return 0; | ||
| 56 | } | ||
