aboutsummaryrefslogtreecommitdiff
path: root/old/2021-06-15-before-separating-steps/main.c
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano.tronto@gmail.com>2021-11-11 21:37:34 +0100
committerSebastiano Tronto <sebastiano.tronto@gmail.com>2021-11-11 21:37:34 +0100
commit3568412f8f230774d0d11d7ed1c897424f95d3ef (patch)
tree77223792d8c925a9b1fc32b3f4341e943b5f8209 /old/2021-06-15-before-separating-steps/main.c
parent67e1b5e6e6a2c917a2fe58a37a1382c982b1e5c5 (diff)
downloadnissy-3568412f8f230774d0d11d7ed1c897424f95d3ef.tar.gz
nissy-3568412f8f230774d0d11d7ed1c897424f95d3ef.zip
Rewritten from scratch. Welocme nissy 2.0!
Diffstat (limited to 'old/2021-06-15-before-separating-steps/main.c')
-rw-r--r--old/2021-06-15-before-separating-steps/main.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/old/2021-06-15-before-separating-steps/main.c b/old/2021-06-15-before-separating-steps/main.c
new file mode 100644
index 0000000..ff726b5
--- /dev/null
+++ b/old/2021-06-15-before-separating-steps/main.c
@@ -0,0 +1,60 @@
1#include <stdio.h>
2#include "cube.h"
3
4int main() {
5 Alg *algo;
6 AlgList *sols;
7 Cube cube;
8 SolveOptions opts;
9 char line[1000];
10 int i, ns = 2, nrand = 100000, sum1, sum2;
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 sum1 = 0;
34 sum2 = 0;
35 for (i = 0; i < nrand; i++) {
36 sum1 += optimal_HTM.check(random_cube());
37 sum2 += corners_HTM.check(random_cube());
38 }
39 printf("Average optimal pruning: %lf\n", ((double)sum1) / ((double) nrand));
40 printf("Average corners pruning: %lf\n", ((double)sum2) / ((double) nrand));
41
42 printf("Welcome to nissy 2.0! Insert a scramble:\n");
43
44 if (fgets(line, 1000, stdin) != NULL) {
45 algo = new_alg(line);
46 cube = apply_alg(algo, (Cube){0});
47
48 for (i = 0; i < ns; i++) {
49 if (stps[i]->check == NULL)
50 fprintf(stderr, "Check function for step %d is null\n", i);
51 sols = solve(cube, *stps[i], &opts);
52 printf("%s: %d solutions found:\n", sss[i], sols->len);
53 print_alglist(sols, true);
54 free_alglist(sols);
55 }
56 free(algo);
57 }
58
59 return 0;
60}

Generated with cgit - Back to sebastiano.tronto.net