aboutsummaryrefslogtreecommitdiff
path: root/old/2021-11-10-beforeremovingchecker/cubetypes.h
diff options
context:
space:
mode:
Diffstat (limited to 'old/2021-11-10-beforeremovingchecker/cubetypes.h')
-rw-r--r--old/2021-11-10-beforeremovingchecker/cubetypes.h298
1 files changed, 298 insertions, 0 deletions
diff --git a/old/2021-11-10-beforeremovingchecker/cubetypes.h b/old/2021-11-10-beforeremovingchecker/cubetypes.h
new file mode 100644
index 0000000..38a6f8d
--- /dev/null
+++ b/old/2021-11-10-beforeremovingchecker/cubetypes.h
@@ -0,0 +1,298 @@
1#ifndef CUBETYPES_H
2#define CUBETYPES_H
3
4#include <stdbool.h>
5#include <stdint.h>
6
7#define NMOVES 55 /* Actually 55, but one is NULLMOVE */
8#define NTRANS 48
9#define NROTATIONS 24
10
11
12/* Typedefs ******************************************************************/
13
14typedef enum center Center;
15typedef enum corner Corner;
16typedef enum edge Edge;
17typedef enum move Move;
18typedef enum trans Trans;
19
20typedef struct alg Alg;
21typedef struct alglist AlgList;
22typedef struct alglistnode AlgListNode;
23typedef struct block Block;
24typedef struct command Command;
25typedef struct commandargs CommandArgs;
26typedef struct coordinate Coordinate;
27typedef struct cube Cube;
28typedef struct cubearray CubeArray;
29typedef struct cubetarget CubeTarget;
30typedef struct dfsdata DfsData;
31typedef struct piecefilter PieceFilter;
32typedef struct prunedata PruneData;
33typedef struct solveoptions SolveOptions;
34typedef struct step Step;
35typedef struct symdata SymData;
36
37typedef Cube (*AntiIndexer) (uint64_t);
38typedef bool (*Checker) (Cube);
39typedef int (*Estimator) (CubeTarget);
40typedef bool (*Validator) (Alg *);
41typedef void (*Exec) (CommandArgs *);
42typedef uint64_t (*Indexer) (Cube);
43typedef bool (*Moveset) (Move);
44typedef CommandArgs * (*ArgParser) (int, char **);
45typedef Trans (*TransDetector) (Cube);
46
47
48/* Enums *********************************************************************/
49
50enum
51center
52{
53 U_center, D_center,
54 R_center, L_center,
55 F_center, B_center
56};
57
58enum
59corner
60{
61 UFR, UFL, UBL, UBR,
62 DFR, DFL, DBL, DBR
63};
64
65enum
66edge
67{
68 UF, UL, UB, UR,
69 DF, DL, DB, DR,
70 FR, FL, BL, BR
71};
72
73enum
74move
75{
76 NULLMOVE,
77 U, U2, U3, D, D2, D3,
78 R, R2, R3, L, L2, L3,
79 F, F2, F3, B, B2, B3,
80 Uw, Uw2, Uw3, Dw, Dw2, Dw3,
81 Rw, Rw2, Rw3, Lw, Lw2, Lw3,
82 Fw, Fw2, Fw3, Bw, Bw2, Bw3,
83 M, M2, M3,
84 S, S2, S3,
85 E, E2, E3,
86 x, x2, x3,
87 y, y2, y3,
88 z, z2, z3,
89};
90
91enum
92trans
93{
94 uf, ur, ub, ul,
95 df, dr, db, dl,
96 rf, rd, rb, ru,
97 lf, ld, lb, lu,
98 fu, fr, fd, fl,
99 bu, br, bd, bl,
100 uf_mirror, ur_mirror, ub_mirror, ul_mirror,
101 df_mirror, dr_mirror, db_mirror, dl_mirror,
102 rf_mirror, rd_mirror, rb_mirror, ru_mirror,
103 lf_mirror, ld_mirror, lb_mirror, lu_mirror,
104 fu_mirror, fr_mirror, fd_mirror, fl_mirror,
105 bu_mirror, br_mirror, bd_mirror, bl_mirror,
106};
107
108
109/* Structs *******************************************************************/
110
111struct
112alg
113{
114 Move * move;
115 bool * inv;
116 int len;
117 int allocated;
118};
119
120struct
121alglist
122{
123 AlgListNode * first;
124 AlgListNode * last;
125 int len;
126};
127
128struct
129alglistnode
130{
131 Alg * alg;
132 AlgListNode * next;
133};
134
135struct
136block
137{
138 bool edge[12];
139 bool corner[8];
140 bool center[6];
141};
142
143struct
144command
145{
146 /* TODO: more stuff to add? maybe complete help? */
147 /* Maybe add list of options */
148 char * name;
149 char * usage;
150 char * description;
151 ArgParser parse_args;
152 Exec exec;
153};
154
155struct
156commandargs
157{
158 bool success;
159 Alg * scramble;
160 SolveOptions * opts;
161 Step * step;
162 Command * command; /* For help */
163};
164
165struct
166coordinate
167{
168 Indexer index;
169 AntiIndexer cube;
170 Checker check;
171 uint64_t max;
172 int ntrans;
173 Trans * trans;
174};
175
176struct
177cube
178{
179 int epose;
180 int eposs;
181 int eposm;
182 int eofb;
183 int eorl;
184 int eoud;
185 int cp;
186 int coud;
187 int cofb;
188 int corl;
189 int cpos;
190};
191
192struct
193cubearray
194{
195 int * ep;
196 int * eofb;
197 int * eorl;
198 int * eoud;
199 int * cp;
200 int * coud;
201 int * corl;
202 int * cofb;
203 int * cpos;
204};
205
206struct
207cubetarget
208{
209 Cube cube;
210 int target;
211};
212
213struct
214dfsdata
215{
216 int d;
217 int m;
218 int lb;
219 bool niss;
220 Move last1;
221 Move last2;
222 AlgList * sols;
223 Alg * current_alg;
224 Move sorted_moves[NMOVES];
225 int move_position[NMOVES];
226};
227
228struct
229piecefilter
230{
231 bool epose;
232 bool eposs;
233 bool eposm;
234 bool eofb;
235 bool eorl;
236 bool eoud;
237 bool cp;
238 bool coud;
239 bool cofb;
240 bool corl;
241 bool cpos;
242};
243
244struct
245prunedata
246{
247 char * filename;
248 uint8_t * ptable;
249 bool generated;
250 uint64_t n;
251 Coordinate * coord;
252 Moveset moveset;
253};
254
255struct
256solveoptions
257{
258 /* TODO: add option to list *all* solutions satisfying other
259 constraints (min/max moves and optimality) */
260 int min_moves;
261 int max_moves;
262 int max_solutions;
263 bool optimal_only;
264 bool can_niss;
265 bool feedback; /* TODO: rename with "verbose" */
266 bool all;
267 bool print_number;
268};
269
270struct
271step
272{
273 char * shortname;
274 char * name;
275 Estimator estimate;
276 Checker ready;
277 char * ready_msg;
278 Validator is_valid;
279 Moveset moveset;
280 Trans pre_trans;
281 TransDetector detect;
282};
283
284struct
285symdata
286{
287 char * filename;
288 bool generated;
289 Coordinate * coord;
290 Coordinate * sym_coord;
291 int ntrans;
292 Trans * trans;
293 uint64_t * class;
294 Cube * rep;
295 Trans * transtorep;
296};
297
298#endif

Generated with cgit - Back to sebastiano.tronto.net