diff options
Diffstat (limited to 'src/cubetypes.h')
| -rw-r--r-- | src/cubetypes.h | 176 |
1 files changed, 87 insertions, 89 deletions
diff --git a/src/cubetypes.h b/src/cubetypes.h index ad9c627..cf6b7d5 100644 --- a/src/cubetypes.h +++ b/src/cubetypes.h | |||
| @@ -10,6 +10,8 @@ | |||
| 10 | #define NROTATIONS 24 | 10 | #define NROTATIONS 24 |
| 11 | #define entry_group_t uint8_t /* For pruning tables */ | 11 | #define entry_group_t uint8_t /* For pruning tables */ |
| 12 | 12 | ||
| 13 | #define MAX_N_COORD 6 | ||
| 14 | |||
| 13 | /* Enums *********************************************************************/ | 15 | /* Enums *********************************************************************/ |
| 14 | 16 | ||
| 15 | typedef enum | 17 | typedef enum |
| @@ -28,6 +30,12 @@ corner | |||
| 28 | } Corner; | 30 | } Corner; |
| 29 | 31 | ||
| 30 | typedef enum | 32 | typedef enum |
| 33 | coordtype | ||
| 34 | { | ||
| 35 | COMP_COORD, SYM_COORD, SYMCOMP_COORD | ||
| 36 | } CoordType; | ||
| 37 | |||
| 38 | typedef enum | ||
| 31 | edge | 39 | edge |
| 32 | { | 40 | { |
| 33 | UF, UL, UB, UR, | 41 | UF, UL, UB, UR, |
| @@ -81,28 +89,24 @@ typedef struct command Command; | |||
| 81 | typedef struct commandargs CommandArgs; | 89 | typedef struct commandargs CommandArgs; |
| 82 | typedef struct coordinate Coordinate; | 90 | typedef struct coordinate Coordinate; |
| 83 | typedef struct cube Cube; | 91 | typedef struct cube Cube; |
| 84 | typedef struct cubearray CubeArray; | ||
| 85 | typedef struct dfsarg DfsArg; | 92 | typedef struct dfsarg DfsArg; |
| 86 | typedef struct estimatedata EstimateData; | 93 | typedef struct indexer Indexer; |
| 94 | typedef struct movable Movable; | ||
| 87 | typedef struct moveset Moveset; | 95 | typedef struct moveset Moveset; |
| 88 | typedef struct piecefilter PieceFilter; | 96 | typedef struct pdgendata PDGenData; |
| 89 | typedef struct prunedata PruneData; | 97 | typedef struct prunedata PruneData; |
| 90 | typedef struct solveoptions SolveOptions; | 98 | typedef struct solveoptions SolveOptions; |
| 91 | typedef struct step Step; | 99 | typedef struct step Step; |
| 100 | typedef struct stepalt StepAlt; | ||
| 92 | typedef struct symdata SymData; | 101 | typedef struct symdata SymData; |
| 93 | typedef struct threaddatasolve ThreadDataSolve; | 102 | typedef struct threaddatasolve ThreadDataSolve; |
| 94 | typedef struct threaddatagenpt ThreadDataGenpt; | 103 | typedef struct threaddatagenpt ThreadDataGenpt; |
| 104 | typedef struct transgroup TransGroup; | ||
| 95 | 105 | ||
| 96 | typedef Cube (*AntiIndexer) (uint64_t); | 106 | typedef bool (*Checker) (Cube *); |
| 97 | typedef bool (*Checker) (Cube); | ||
| 98 | typedef uint64_t (*CoordMover) (Move, uint64_t); | ||
| 99 | typedef uint64_t (*CoordTransformer) (Trans, uint64_t); | ||
| 100 | typedef int (*Estimator) (DfsArg *); | ||
| 101 | typedef bool (*Validator) (Alg *); | 107 | typedef bool (*Validator) (Alg *); |
| 102 | typedef void (*Exec) (CommandArgs *); | 108 | typedef void (*Exec) (CommandArgs *); |
| 103 | typedef uint64_t (*Indexer) (Cube); | ||
| 104 | typedef CommandArgs * (*ArgParser) (int, char **); | 109 | typedef CommandArgs * (*ArgParser) (int, char **); |
| 105 | typedef int (*TransDetector) (Cube, Trans *); | ||
| 106 | typedef int (*TransFinder) (uint64_t, Trans *); | 110 | typedef int (*TransFinder) (uint64_t, Trans *); |
| 107 | 111 | ||
| 108 | 112 | ||
| @@ -167,83 +171,69 @@ commandargs | |||
| 167 | struct | 171 | struct |
| 168 | coordinate | 172 | coordinate |
| 169 | { | 173 | { |
| 170 | Indexer index; | 174 | char * name; |
| 175 | CoordType type; | ||
| 176 | bool generated; | ||
| 177 | Indexer * i[99]; | ||
| 171 | uint64_t max; | 178 | uint64_t max; |
| 172 | CoordMover move; | 179 | uint64_t * mtable[NMOVES]; |
| 173 | CoordTransformer transform; | 180 | uint64_t * ttable[NTRANS]; |
| 174 | SymData * sd; | 181 | TransGroup * tgrp; |
| 175 | TransFinder tfind; /* TODO: should be easy to remove */ | 182 | Coordinate * base[2]; |
| 176 | Coordinate * base; /* TODO: part of refactor */ | 183 | uint64_t * symclass; |
| 184 | uint64_t * symrep; | ||
| 185 | Trans * transtorep; | ||
| 186 | Trans * ttrep_move[NMOVES]; | ||
| 187 | uint64_t * selfsim; | ||
| 177 | }; | 188 | }; |
| 178 | 189 | ||
| 179 | struct | 190 | struct |
| 180 | cube | 191 | cube |
| 181 | { | 192 | { |
| 182 | int epose; | 193 | int ep[12]; |
| 183 | int eposs; | 194 | int eo[12]; |
| 184 | int eposm; | 195 | int cp[8]; |
| 185 | int eofb; | 196 | int co[8]; |
| 186 | int eorl; | 197 | int xp[6]; |
| 187 | int eoud; | ||
| 188 | int cp; | ||
| 189 | int coud; | ||
| 190 | int cofb; | ||
| 191 | int corl; | ||
| 192 | int cpos; | ||
| 193 | }; | 198 | }; |
| 194 | 199 | ||
| 195 | struct | 200 | struct |
| 196 | cubearray | 201 | movable |
| 197 | { | 202 | { |
| 198 | int * ep; | 203 | uint64_t val; |
| 199 | int * eofb; | 204 | Trans t; |
| 200 | int * eorl; | ||
| 201 | int * eoud; | ||
| 202 | int * cp; | ||
| 203 | int * coud; | ||
| 204 | int * corl; | ||
| 205 | int * cofb; | ||
| 206 | int * cpos; | ||
| 207 | }; | 205 | }; |
| 208 | 206 | ||
| 209 | struct | 207 | struct |
| 210 | dfsarg | 208 | dfsarg |
| 211 | { | 209 | { |
| 212 | Step * step; | 210 | Cube * cube; |
| 213 | SolveOptions * opts; | 211 | Movable ind[MAX_N_COORD]; |
| 214 | Trans t; | 212 | Trans t; |
| 215 | Cube cube; | 213 | StepAlt * sa; |
| 216 | Cube inverse; | 214 | SolveOptions * opts; |
| 217 | int d; | 215 | int d; |
| 218 | uint64_t badmoves; | 216 | int bound; |
| 219 | uint64_t badmovesinv; | ||
| 220 | bool niss; | 217 | bool niss; |
| 221 | Move last1; | 218 | Move last[2]; |
| 222 | Move last2; | 219 | Move lastinv[2]; |
| 223 | Move last1inv; | ||
| 224 | Move last2inv; | ||
| 225 | EstimateData * ed; | ||
| 226 | AlgList * sols; | 220 | AlgList * sols; |
| 227 | pthread_mutex_t * sols_mutex; | 221 | pthread_mutex_t * sols_mutex; |
| 228 | Alg * current_alg; | 222 | Alg * current_alg; |
| 229 | }; | 223 | }; |
| 230 | 224 | ||
| 231 | struct | 225 | struct |
| 232 | estimatedata | 226 | indexer |
| 233 | { | 227 | { |
| 234 | int corners; | 228 | int n; |
| 235 | int normal_ud; | 229 | uint64_t (*index)(Cube *); |
| 236 | int normal_fb; | 230 | void (*to_cube)(uint64_t, Cube *); |
| 237 | int normal_rl; | ||
| 238 | int inverse_ud; | ||
| 239 | int inverse_fb; | ||
| 240 | int inverse_rl; | ||
| 241 | int oldret; | ||
| 242 | }; | 231 | }; |
| 243 | 232 | ||
| 244 | struct | 233 | struct |
| 245 | moveset | 234 | moveset |
| 246 | { | 235 | { |
| 236 | char * name; | ||
| 247 | bool (*allowed)(Move); | 237 | bool (*allowed)(Move); |
| 248 | bool (*allowed_next)(Move, Move, Move); | 238 | bool (*allowed_next)(Move, Move, Move); |
| 249 | Move sorted_moves[NMOVES+1]; | 239 | Move sorted_moves[NMOVES+1]; |
| @@ -251,34 +241,24 @@ moveset | |||
| 251 | }; | 241 | }; |
| 252 | 242 | ||
| 253 | struct | 243 | struct |
| 254 | piecefilter | 244 | pdgendata |
| 255 | { | 245 | { |
| 256 | bool epose; | 246 | Coordinate * coord; |
| 257 | bool eposs; | 247 | Moveset * moveset; |
| 258 | bool eposm; | 248 | bool compact; |
| 259 | bool eofb; | 249 | PruneData * pd; |
| 260 | bool eorl; | ||
| 261 | bool eoud; | ||
| 262 | bool cp; | ||
| 263 | bool coud; | ||
| 264 | bool cofb; | ||
| 265 | bool corl; | ||
| 266 | bool cpos; | ||
| 267 | }; | 250 | }; |
| 268 | 251 | ||
| 269 | struct | 252 | struct |
| 270 | prunedata | 253 | prunedata |
| 271 | { | 254 | { |
| 272 | char * filename; | ||
| 273 | entry_group_t * ptable; | 255 | entry_group_t * ptable; |
| 274 | bool generated; | ||
| 275 | uint64_t n; | 256 | uint64_t n; |
| 276 | Coordinate * coord; | 257 | Coordinate * coord; |
| 277 | Moveset * moveset; | 258 | Moveset * moveset; |
| 278 | bool compact; | 259 | bool compact; |
| 279 | int base; | 260 | int base; |
| 280 | uint64_t count[16]; | 261 | uint64_t count[16]; |
| 281 | PruneData * fallback; | ||
| 282 | uint64_t fbmod; | 262 | uint64_t fbmod; |
| 283 | }; | 263 | }; |
| 284 | 264 | ||
| @@ -302,19 +282,35 @@ step | |||
| 302 | { | 282 | { |
| 303 | char * shortname; | 283 | char * shortname; |
| 304 | char * name; | 284 | char * name; |
| 305 | bool final; | 285 | StepAlt * alt[99]; |
| 306 | Checker is_done; | 286 | Trans t[99]; |
| 307 | Estimator estimate; | ||
| 308 | Checker ready; | ||
| 309 | char * ready_msg; | 287 | char * ready_msg; |
| 310 | Validator is_valid; | 288 | }; |
| 289 | |||
| 290 | struct | ||
| 291 | stepalt | ||
| 292 | { | ||
| 293 | Checker ready; | ||
| 294 | bool final; | ||
| 311 | Moveset * moveset; | 295 | Moveset * moveset; |
| 312 | Trans pre_trans; | 296 | /* Just a comment, (TODO: remove this): moveset is really a stepalt |
| 313 | TransDetector detect; | 297 | * property, because for example we may want to define a "fingertrick |
| 314 | int ntables; | 298 | * friendly ZBLL" step, where we allow either <R U D> or <R U F> as |
| 315 | PruneData * tables[10]; | 299 | * movesets (or similar) */ |
| 300 | int n_coord; | ||
| 301 | Coordinate * coord[MAX_N_COORD]; | ||
| 302 | Trans coord_trans[MAX_N_COORD]; | ||
| 303 | PruneData * pd[MAX_N_COORD]; | ||
| 304 | bool compact_pd[MAX_N_COORD]; | ||
| 305 | Coordinate * fallback_coord[MAX_N_COORD]; | ||
| 306 | PruneData * fallback_pd[MAX_N_COORD]; | ||
| 307 | uint64_t fbmod[MAX_N_COORD]; | ||
| 308 | int n_dbtrick; | ||
| 309 | int dbtrick[MAX_N_COORD][3]; | ||
| 310 | Validator is_valid; | ||
| 316 | }; | 311 | }; |
| 317 | 312 | ||
| 313 | /* | ||
| 318 | struct | 314 | struct |
| 319 | symdata | 315 | symdata |
| 320 | { | 316 | { |
| @@ -328,23 +324,18 @@ symdata | |||
| 328 | uint64_t * unsym; | 324 | uint64_t * unsym; |
| 329 | Trans * transtorep; | 325 | Trans * transtorep; |
| 330 | uint64_t * selfsim; | 326 | uint64_t * selfsim; |
| 331 | CoordTransformer transform; /* TODO: remove, use that of base coord */ | ||
| 332 | }; | 327 | }; |
| 328 | */ | ||
| 329 | |||
| 333 | 330 | ||
| 334 | struct | 331 | struct |
| 335 | threaddatasolve | 332 | threaddatasolve |
| 336 | { | 333 | { |
| 334 | DfsArg arg; | ||
| 337 | int thid; | 335 | int thid; |
| 338 | Trans t; | ||
| 339 | Cube cube; | ||
| 340 | Step * step; | ||
| 341 | int depth; | ||
| 342 | SolveOptions * opts; | ||
| 343 | AlgList * start; | 336 | AlgList * start; |
| 344 | AlgListNode ** node; | 337 | AlgListNode ** node; |
| 345 | AlgList * sols; | ||
| 346 | pthread_mutex_t * start_mutex; | 338 | pthread_mutex_t * start_mutex; |
| 347 | pthread_mutex_t * sols_mutex; | ||
| 348 | }; | 339 | }; |
| 349 | 340 | ||
| 350 | struct | 341 | struct |
| @@ -359,4 +350,11 @@ threaddatagenpt | |||
| 359 | pthread_mutex_t * upmutex; | 350 | pthread_mutex_t * upmutex; |
| 360 | }; | 351 | }; |
| 361 | 352 | ||
| 353 | struct | ||
| 354 | transgroup | ||
| 355 | { | ||
| 356 | int n; | ||
| 357 | Trans t[NTRANS]; | ||
| 358 | }; | ||
| 359 | |||
| 362 | #endif | 360 | #endif |
