aboutsummaryrefslogtreecommitdiff
path: root/adhoc
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--adhoc/README3
-rwxr-xr-xadhoc/compile.sh15
-rw-r--r--adhoc/cornersdrhtr.c128
-rwxr-xr-xadhoc/runbin0 -> 322392 bytes
4 files changed, 146 insertions, 0 deletions
diff --git a/adhoc/README b/adhoc/README
new file mode 100644
index 0000000..8f72c6e
--- /dev/null
+++ b/adhoc/README
@@ -0,0 +1,3 @@
1This folder contains some ad-hoc code that is not included in the main nissy
2program. You probably don't need it, but it may be worth looking into if you
3are trying to extend nissy by writing your own steps or other functions.
diff --git a/adhoc/compile.sh b/adhoc/compile.sh
new file mode 100755
index 0000000..aa541c7
--- /dev/null
+++ b/adhoc/compile.sh
@@ -0,0 +1,15 @@
1#/!bin/sh
2
3mkdir build
4cd build
5cp -R ../../src ./
6rm src/shell.c
7cp ../$1 src/
8cp ../../Makefile ./
9make
10cp nissy ../run
11rm src/*
12rmdir src
13rm *
14cd ..
15rmdir build
diff --git a/adhoc/cornersdrhtr.c b/adhoc/cornersdrhtr.c
new file mode 100644
index 0000000..2a5a6e6
--- /dev/null
+++ b/adhoc/cornersdrhtr.c
@@ -0,0 +1,128 @@
1#include "commands.h"
2
3/* Some of the following functions are new, some are copied from steps.c */
4bool
5allowed(Move m)
6{
7 return base_move(m) == U || m == R2 || m == F2;
8}
9
10bool
11allowed_next(Move l2, Move l1, Move m)
12{
13 return base_move(m) != base_move(l1);
14}
15
16bool
17check_cornershtr(Cube c)
18{
19 return coord_cornershtr.index(c) == 0;
20}
21
22bool
23check_coud_and_dbl(Cube c)
24{
25 return c.coud == 0 && what_corner_at(c, DBL) == DBL;
26}
27
28static int
29estimate_cornershtr_HTM(DfsArg *arg)
30{
31 return ptableval(&pd_cornershtr_HTM, arg->cube);
32}
33
34static bool
35validate_singlecw_ending(Alg *alg)
36{
37 int i;
38 bool nor, inv;
39 Move l2 = NULLMOVE, l1 = NULLMOVE, l2i = NULLMOVE, l1i = NULLMOVE;
40
41 for (i = 0; i < alg->len; i++) {
42 if (alg->inv[i]) {
43 l2i = l1i;
44 l1i = alg->move[i];
45 } else {
46 l2 = l1;
47 l1 = alg->move[i];
48 }
49 }
50
51 nor = l1 ==base_move(l1) && (!commute(l1, l2) ||l2 ==base_move(l2));
52 inv = l1i==base_move(l1i) && (!commute(l1i,l2i)||l2i==base_move(l2i));
53
54 return nor && inv;
55}
56
57int
58main()
59{
60 Moveset moveset_UR2F2 = {
61 .allowed = allowed,
62 .allowed_next = allowed_next,
63 };
64
65 init_moveset(&moveset_UR2F2);
66
67 /*
68 * This step is the same as cornershtr_HTM in steps.c, except for
69 * the ready() function (which is not relevant anyway, it is there
70 * more for testing than anything else) and the moveset.
71 */
72 Step step = {
73 .final = false,
74 .is_done = check_cornershtr,
75 .estimate = estimate_cornershtr_HTM,
76 .ready = check_coud_and_dbl,
77 .is_valid = validate_singlecw_ending,
78 .moveset = &moveset_UR2F2,
79
80 .pre_trans = uf,
81
82 .tables = {&pd_cornershtr_HTM},
83 .ntables = 1,
84 };
85
86 SolveOptions opts = {
87 .min_moves = 0,
88 .max_moves = 20,
89 .max_solutions = 1,
90 .nthreads = 4,
91 .optimal = 0,
92 .can_niss = false,
93 .verbose = false,
94 .all = false,
95 .print_number = false,
96 .count_only = false
97 };
98
99 init_symcoord();
100
101 bool cphtr_state_done[BINOM8ON4*6];
102 for (unsigned long int i = 0; i < BINOM8ON4*6; i++)
103 cphtr_state_done[i] = false;
104
105 for (unsigned long int i = 0; i < FACTORIAL8; i++) {
106 AlgList *sols;
107 Cube c = {0};
108 c.cp = i; /* inconsistent state because of side CO */
109
110 if (what_corner_at(c, DBL) != DBL ||
111 cphtr_state_done[coord_cphtr.index(c)])
112 continue;
113
114 fprintf(stderr, "Doing cp %ld (cphtr state %ld)\n",
115 i, coord_cphtr.index(c));
116
117 cphtr_state_done[coord_cphtr.index(c)] = true;
118 /* Comment next two lines to get non-reduced list */
119 Cube mirror = apply_trans(ur_mirror, c);
120 cphtr_state_done[coord_cphtr.index(mirror)] = true;
121
122 sols = solve(c, &step, &opts);
123 printf("%.2d\t", sols->first->alg->len);
124 print_alglist(sols, opts.print_number);
125 }
126
127 return 0;
128}
diff --git a/adhoc/run b/adhoc/run
new file mode 100755
index 0000000..27541c2
--- /dev/null
+++ b/adhoc/run
Binary files differ

Generated with cgit - Back to sebastiano.tronto.net