diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-11-11 21:37:34 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-11-11 21:37:34 +0100 |
| commit | 3568412f8f230774d0d11d7ed1c897424f95d3ef (patch) | |
| tree | 77223792d8c925a9b1fc32b3f4341e943b5f8209 /old/2021-06-23-realizing-bad-tables/main.c | |
| parent | 67e1b5e6e6a2c917a2fe58a37a1382c982b1e5c5 (diff) | |
| download | nissy-3568412f8f230774d0d11d7ed1c897424f95d3ef.tar.gz nissy-3568412f8f230774d0d11d7ed1c897424f95d3ef.zip | |
Rewritten from scratch. Welocme nissy 2.0!
Diffstat (limited to '')
| -rw-r--r-- | old/2021-06-23-realizing-bad-tables/main.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/old/2021-06-23-realizing-bad-tables/main.c b/old/2021-06-23-realizing-bad-tables/main.c new file mode 100644 index 0000000..e0e049a --- /dev/null +++ b/old/2021-06-23-realizing-bad-tables/main.c | |||
| @@ -0,0 +1,70 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | #include "cube.h" | ||
| 3 | #include "steps.h" | ||
| 4 | |||
| 5 | int main() { | ||
| 6 | Alg *algo; | ||
| 7 | AlgList *sols; | ||
| 8 | Cube cube; | ||
| 9 | SolveOptions opts; | ||
| 10 | char line[1000]; | ||
| 11 | int i, ns = 3; | ||
| 12 | /* int nrand = 10000, sum1, sum2, sum3;*/ | ||
| 13 | |||
| 14 | Step *stps[20] = {&corners_HTM, &eofb_HTM, &optimal_HTM}; | ||
| 15 | char sss[30][30] = {"Corners", "EO on F/B", "Optimal solution"}; | ||
| 16 | |||
| 17 | opts = (SolveOptions) { | ||
| 18 | .min_moves = 0, | ||
| 19 | .max_moves = 20, | ||
| 20 | .optimal_only = true, | ||
| 21 | .max_solutions = 1, | ||
| 22 | .can_niss = false, | ||
| 23 | .feedback = true, | ||
| 24 | .pre_trans = uf | ||
| 25 | }; | ||
| 26 | |||
| 27 | init(); | ||
| 28 | |||
| 29 | print_ptable(&pd_corners_HTM); | ||
| 30 | |||
| 31 | /* | ||
| 32 | srand(time(NULL)); | ||
| 33 | sum1 = 0; | ||
| 34 | sum2 = 0; | ||
| 35 | sum3 = 0; | ||
| 36 | for (i = 0; i < nrand; i++) { | ||
| 37 | cube = random_cube(); | ||
| 38 | sum1 += corners_HTM.check(cube, 20); | ||
| 39 | sum2 += cornershtr_HTM.check(cube, 20); | ||
| 40 | sum3 += optimal_HTM.check(cube, 20); | ||
| 41 | } | ||
| 42 | printf("Average corners pruning: %lf\n", ((double)sum1) / ((double) nrand)); | ||
| 43 | printf("Average corners htr pruning: %lf\n", ((double)sum2) / ((double) nrand)); | ||
| 44 | printf("Average optimal pruning: %lf\n", ((double)sum3) / ((double) nrand)); | ||
| 45 | */ | ||
| 46 | |||
| 47 | printf("Welcome to nissy 2.0! Insert a scramble:\n"); | ||
| 48 | |||
| 49 | if (fgets(line, 1000, stdin) != NULL) { | ||
| 50 | algo = new_alg(line); | ||
| 51 | cube = apply_alg(algo, (Cube){0}); | ||
| 52 | |||
| 53 | print_cube(cube); | ||
| 54 | printf("Index: %lu\n", pd_cornershtr_HTM.index(cube)); | ||
| 55 | |||
| 56 | for (i = 0; i < ns; i++) { | ||
| 57 | if (stps[i]->check == NULL) | ||
| 58 | fprintf(stderr, "Check function for step %d is null\n", i); | ||
| 59 | printf("Check: %d\n", stps[i]->check(cube, 20)); | ||
| 60 | sols = solve(cube, *stps[i], &opts); | ||
| 61 | printf("%s: %d solutions found:\n", sss[i], sols->len); | ||
| 62 | print_alglist(sols, true); | ||
| 63 | free_alglist(sols); | ||
| 64 | } | ||
| 65 | free_alg(algo); | ||
| 66 | } | ||
| 67 | |||
| 68 | return 0; | ||
| 69 | } | ||
| 70 | |||
