diff options
Diffstat (limited to '')
| -rw-r--r-- | src/cubetypes.h | 286 |
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 | |||
| 13 | typedef enum | ||
| 14 | center | ||
| 15 | { | ||
| 16 | U_center, D_center, | ||
| 17 | R_center, L_center, | ||
| 18 | F_center, B_center | ||
| 19 | } Center; | ||
| 20 | |||
| 21 | typedef enum | ||
| 22 | corner | ||
| 23 | { | ||
| 24 | UFR, UFL, UBL, UBR, | ||
| 25 | DFR, DFL, DBL, DBR | ||
| 26 | } Corner; | ||
| 27 | |||
| 28 | typedef enum | ||
| 29 | edge | ||
| 30 | { | ||
| 31 | UF, UL, UB, UR, | ||
| 32 | DF, DL, DB, DR, | ||
| 33 | FR, FL, BL, BR | ||
| 34 | } Edge; | ||
| 35 | |||
| 36 | typedef enum | ||
| 37 | move | ||
| 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 | |||
| 54 | typedef enum | ||
| 55 | trans | ||
| 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 | |||
| 74 | typedef struct alg Alg; | ||
| 75 | typedef struct alglist AlgList; | ||
| 76 | typedef struct alglistnode AlgListNode; | ||
| 77 | typedef struct block Block; | ||
| 78 | typedef struct command Command; | ||
| 79 | typedef struct commandargs CommandArgs; | ||
| 80 | typedef struct coordinate Coordinate; | ||
| 81 | typedef struct cube Cube; | ||
| 82 | typedef struct cubearray CubeArray; | ||
| 83 | typedef struct cubetarget CubeTarget; | ||
| 84 | typedef struct dfsdata DfsData; | ||
| 85 | typedef struct piecefilter PieceFilter; | ||
| 86 | typedef struct prunedata PruneData; | ||
| 87 | typedef struct solveoptions SolveOptions; | ||
| 88 | typedef struct step Step; | ||
| 89 | typedef struct symdata SymData; | ||
| 90 | |||
| 91 | typedef Cube (*AntiIndexer) (uint64_t); | ||
| 92 | typedef bool (*Checker) (Cube); | ||
| 93 | typedef int (*Estimator) (CubeTarget); | ||
| 94 | typedef bool (*Validator) (Alg *); | ||
| 95 | typedef void (*Exec) (CommandArgs *); | ||
| 96 | typedef uint64_t (*Indexer) (Cube); | ||
| 97 | typedef bool (*Moveset) (Move); | ||
| 98 | typedef CommandArgs * (*ArgParser) (int, char **); | ||
| 99 | typedef Trans (*TransDetector) (Cube); | ||
| 100 | |||
| 101 | |||
| 102 | /* Structs *******************************************************************/ | ||
| 103 | |||
| 104 | struct | ||
| 105 | alg | ||
| 106 | { | ||
| 107 | Move * move; | ||
| 108 | bool * inv; | ||
| 109 | int len; | ||
| 110 | int allocated; | ||
| 111 | }; | ||
| 112 | |||
| 113 | struct | ||
| 114 | alglist | ||
| 115 | { | ||
| 116 | AlgListNode * first; | ||
| 117 | AlgListNode * last; | ||
| 118 | int len; | ||
| 119 | }; | ||
| 120 | |||
| 121 | struct | ||
| 122 | alglistnode | ||
| 123 | { | ||
| 124 | Alg * alg; | ||
| 125 | AlgListNode * next; | ||
| 126 | }; | ||
| 127 | |||
| 128 | struct | ||
| 129 | block | ||
| 130 | { | ||
| 131 | bool edge[12]; | ||
| 132 | bool corner[8]; | ||
| 133 | bool center[6]; | ||
| 134 | }; | ||
| 135 | |||
| 136 | struct | ||
| 137 | command | ||
| 138 | { | ||
| 139 | char * name; | ||
| 140 | char * usage; | ||
| 141 | char * description; | ||
| 142 | ArgParser parse_args; | ||
| 143 | Exec exec; | ||
| 144 | }; | ||
| 145 | |||
| 146 | struct | ||
| 147 | commandargs | ||
| 148 | { | ||
| 149 | bool success; | ||
| 150 | Alg * scramble; | ||
| 151 | SolveOptions * opts; | ||
| 152 | Step * step; | ||
| 153 | Command * command; /* For help */ | ||
| 154 | }; | ||
| 155 | |||
| 156 | struct | ||
| 157 | coordinate | ||
| 158 | { | ||
| 159 | Indexer index; | ||
| 160 | AntiIndexer cube; | ||
| 161 | uint64_t max; | ||
| 162 | int ntrans; | ||
| 163 | Trans * trans; | ||
| 164 | }; | ||
| 165 | |||
| 166 | struct | ||
| 167 | cube | ||
| 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 | |||
| 182 | struct | ||
| 183 | cubearray | ||
| 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 | |||
| 196 | struct | ||
| 197 | cubetarget | ||
| 198 | { | ||
| 199 | Cube cube; | ||
| 200 | int target; | ||
| 201 | }; | ||
| 202 | |||
| 203 | struct | ||
| 204 | dfsdata | ||
| 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 | |||
| 218 | struct | ||
| 219 | piecefilter | ||
| 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 | |||
| 234 | struct | ||
| 235 | prunedata | ||
| 236 | { | ||
| 237 | char * filename; | ||
| 238 | uint8_t * ptable; | ||
| 239 | bool generated; | ||
| 240 | uint64_t n; | ||
| 241 | Coordinate * coord; | ||
| 242 | Moveset moveset; | ||
| 243 | }; | ||
| 244 | |||
| 245 | struct | ||
| 246 | solveoptions | ||
| 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 | |||
| 258 | struct | ||
| 259 | step | ||
| 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 | |||
| 272 | struct | ||
| 273 | symdata | ||
| 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 | ||
