aboutsummaryrefslogtreecommitdiff
path: root/old/2021-06-17-cachedata/cubetypes.h
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-17-cachedata/cubetypes.h
parent67e1b5e6e6a2c917a2fe58a37a1382c982b1e5c5 (diff)
downloadnissy-3568412f8f230774d0d11d7ed1c897424f95d3ef.tar.gz
nissy-3568412f8f230774d0d11d7ed1c897424f95d3ef.zip
Rewritten from scratch. Welocme nissy 2.0!
Diffstat (limited to 'old/2021-06-17-cachedata/cubetypes.h')
-rw-r--r--old/2021-06-17-cachedata/cubetypes.h232
1 files changed, 232 insertions, 0 deletions
diff --git a/old/2021-06-17-cachedata/cubetypes.h b/old/2021-06-17-cachedata/cubetypes.h
new file mode 100644
index 0000000..4369385
--- /dev/null
+++ b/old/2021-06-17-cachedata/cubetypes.h
@@ -0,0 +1,232 @@
1/* Typedefs ******************************************************************/
2
3typedef enum center Center;
4typedef enum corner Corner;
5typedef enum edge Edge;
6typedef enum move Move;
7typedef enum trans Trans;
8
9typedef struct alg Alg;
10typedef struct alglist AlgList;
11typedef struct alglistnode AlgListNode;
12typedef struct block Block;
13typedef struct cachedata CacheData;
14typedef struct cachenode CacheNode;
15typedef struct cube Cube;
16typedef struct cubearray CubeArray;
17typedef struct dfsdata DfsData;
18typedef struct piecefilter PieceFilter;
19typedef struct prunedata PruneData;
20typedef struct solveoptions SolveOptions;
21typedef struct step Step;
22
23typedef int (*Checker)(Cube);
24typedef uint64_t (*Indexer)(Cube);
25typedef bool (*Moveset)(Move);
26
27
28/* Enums *********************************************************************/
29
30enum
31center
32{
33 U_center, D_center,
34 R_center, L_center,
35 F_center, B_center
36};
37
38enum
39corner
40{
41 UFR, UFL, UBL, UBR,
42 DFR, DFL, DBL, DBR
43};
44
45enum
46edge
47{
48 UF, UL, UB, UR,
49 DF, DL, DB, DR,
50 FR, FL, BL, BR
51};
52
53enum
54move
55{
56 NULLMOVE,
57 U, U2, U3, D, D2, D3,
58 R, R2, R3, L, L2, L3,
59 F, F2, F3, B, B2, B3,
60 Uw, Uw2, Uw3, Dw, Dw2, Dw3,
61 Rw, Rw2, Rw3, Lw, Lw2, Lw3,
62 Fw, Fw2, Fw3, Bw, Bw2, Bw3,
63 M, M2, M3,
64 S, S2, S3,
65 E, E2, E3,
66 x, x2, x3,
67 y, y2, y3,
68 z, z2, z3,
69};
70
71enum
72trans
73{
74 uf, ur, ub, ul,
75 df, dr, db, dl,
76 rf, rd, rb, ru,
77 lf, ld, lb, lu,
78 fu, fr, fd, fl,
79 bu, br, bd, bl,
80 mirror, /* R|L */
81};
82
83
84/* Structs *******************************************************************/
85
86struct
87alg
88{
89 Move * move;
90 bool * inv;
91 int len;
92 int allocated;
93};
94
95struct
96alglist
97{
98 AlgListNode * first;
99 AlgListNode * last;
100 int len;
101};
102
103struct
104alglistnode
105{
106 Alg * alg;
107 AlgListNode * next;
108};
109
110struct
111block
112{
113 bool edge[12];
114 bool corner[8];
115 bool center[6];
116};
117
118struct
119cachedata
120{
121 char * filename;
122 CacheNode ** ctable;
123 bool generated;
124 uint64_t maxind0;
125 int len;
126 int nind;
127 Indexer index[20]; /* Should be enough */
128 Checker check;
129 Moveset moveset;
130};
131
132struct
133cachenode
134{
135 uint64_t * indexval;
136 Alg * sol;
137 CacheNode * next;
138};
139
140struct
141cube
142{
143 uint16_t epose;
144 uint16_t eposs;
145 uint16_t eposm;
146 uint16_t eofb;
147 uint16_t eorl;
148 uint16_t eoud;
149 uint16_t cp;
150 uint16_t coud;
151 uint16_t cofb;
152 uint16_t corl;
153 uint16_t cpos;
154};
155
156struct
157cubearray
158{
159 int * ep;
160 int * eofb;
161 int * eorl;
162 int * eoud;
163 int * cp;
164 int * coud;
165 int * corl;
166 int * cofb;
167 int * cpos;
168};
169
170struct
171dfsdata
172{
173 int d;
174 int m;
175 bool niss;
176 Move last1;
177 Move last2;
178 AlgList * sols;
179 Alg * current_alg;
180 Move sorted_moves[NMOVES];
181 int move_position[NMOVES];
182};
183
184struct
185piecefilter
186{
187 bool epose;
188 bool eposs;
189 bool eposm;
190 bool eofb;
191 bool eorl;
192 bool eoud;
193 bool cp;
194 bool coud;
195 bool cofb;
196 bool corl;
197 bool cpos;
198};
199
200struct
201prunedata
202{
203 char * filename;
204 uint8_t * ptable;
205 uint8_t * reached;
206 bool generated;
207 uint64_t n;
208 uint64_t size;
209 Indexer index;
210 Moveset moveset;
211};
212
213struct
214solveoptions
215{
216 int min_moves;
217 int max_moves;
218 int max_solutions;
219 bool optimal_only;
220 bool can_niss;
221 bool feedback;
222 Trans pre_trans;
223};
224
225struct
226step
227{
228 Checker check;
229 Checker ready;
230 Moveset moveset;
231 CacheData * cd;
232};

Generated with cgit - Back to sebastiano.tronto.net