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

Generated with cgit - Back to sebastiano.tronto.net