diff options
Diffstat (limited to 'src/cubetypes.h')
| -rw-r--r-- | src/cubetypes.h | 240 |
1 files changed, 121 insertions, 119 deletions
diff --git a/src/cubetypes.h b/src/cubetypes.h index 3752019..ad9c627 100644 --- a/src/cubetypes.h +++ b/src/cubetypes.h | |||
| @@ -10,8 +10,6 @@ | |||
| 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 | |||
| 15 | /* Enums *********************************************************************/ | 13 | /* Enums *********************************************************************/ |
| 16 | 14 | ||
| 17 | typedef enum | 15 | typedef enum |
| @@ -30,12 +28,6 @@ corner | |||
| 30 | } Corner; | 28 | } Corner; |
| 31 | 29 | ||
| 32 | typedef enum | 30 | typedef enum |
| 33 | coordtype | ||
| 34 | { | ||
| 35 | COMP_COORD, SYM_COORD, SYMCOMP_COORD | ||
| 36 | } CoordType; | ||
| 37 | |||
| 38 | typedef enum | ||
| 39 | edge | 31 | edge |
| 40 | { | 32 | { |
| 41 | UF, UL, UB, UR, | 33 | UF, UL, UB, UR, |
| @@ -84,32 +76,33 @@ trans | |||
| 84 | typedef struct alg Alg; | 76 | typedef struct alg Alg; |
| 85 | typedef struct alglist AlgList; | 77 | typedef struct alglist AlgList; |
| 86 | typedef struct alglistnode AlgListNode; | 78 | typedef struct alglistnode AlgListNode; |
| 87 | typedef struct choicestep ChoiceStep; | 79 | typedef struct block Block; |
| 88 | typedef struct command Command; | 80 | typedef struct command Command; |
| 89 | typedef struct commandargs CommandArgs; | 81 | typedef struct commandargs CommandArgs; |
| 90 | typedef struct coordinate Coordinate; | 82 | typedef struct coordinate Coordinate; |
| 91 | typedef struct cube Cube; | 83 | typedef struct cube Cube; |
| 92 | /*typedef struct dfsarg DfsArg;*/ | 84 | typedef struct cubearray CubeArray; |
| 93 | typedef struct fstcube FstCube; | 85 | typedef struct dfsarg DfsArg; |
| 94 | typedef struct indexer Indexer; | 86 | typedef struct estimatedata EstimateData; |
| 95 | typedef struct movable Movable; | ||
| 96 | typedef struct moveset Moveset; | 87 | typedef struct moveset Moveset; |
| 88 | typedef struct piecefilter PieceFilter; | ||
| 97 | typedef struct prunedata PruneData; | 89 | typedef struct prunedata PruneData; |
| 98 | typedef struct solveoptions SolveOptions; | 90 | typedef struct solveoptions SolveOptions; |
| 99 | typedef struct step Step; | 91 | typedef struct step Step; |
| 100 | typedef struct symdata SymData; | 92 | typedef struct symdata SymData; |
| 101 | typedef struct threaddatasolve ThreadDataSolve; | 93 | typedef struct threaddatasolve ThreadDataSolve; |
| 102 | typedef struct threaddatagenpt ThreadDataGenpt; | 94 | typedef struct threaddatagenpt ThreadDataGenpt; |
| 103 | typedef struct transgroup TransGroup; | ||
| 104 | 95 | ||
| 105 | typedef bool (*Checker) (Cube *); | 96 | typedef Cube (*AntiIndexer) (uint64_t); |
| 106 | typedef bool (*CubeTester) (Cube *, Alg *); | 97 | typedef bool (*Checker) (Cube); |
| 107 | /*typedef bool (*DfsMover) (DfsArg *);*/ | 98 | typedef uint64_t (*CoordMover) (Move, uint64_t); |
| 108 | typedef void (*DfsExtraCopier) (void *, void *); | 99 | typedef uint64_t (*CoordTransformer) (Trans, uint64_t); |
| 109 | typedef Alg * (*Validator) (Alg *); | 100 | typedef int (*Estimator) (DfsArg *); |
| 101 | typedef bool (*Validator) (Alg *); | ||
| 110 | typedef void (*Exec) (CommandArgs *); | 102 | typedef void (*Exec) (CommandArgs *); |
| 103 | typedef uint64_t (*Indexer) (Cube); | ||
| 111 | typedef CommandArgs * (*ArgParser) (int, char **); | 104 | typedef CommandArgs * (*ArgParser) (int, char **); |
| 112 | typedef bool (*Tester) (void); | 105 | typedef int (*TransDetector) (Cube, Trans *); |
| 113 | typedef int (*TransFinder) (uint64_t, Trans *); | 106 | typedef int (*TransFinder) (uint64_t, Trans *); |
| 114 | 107 | ||
| 115 | 108 | ||
| @@ -122,10 +115,6 @@ alg | |||
| 122 | bool * inv; | 115 | bool * inv; |
| 123 | int len; | 116 | int len; |
| 124 | int allocated; | 117 | int allocated; |
| 125 | Move * move_normal; | ||
| 126 | int len_normal; | ||
| 127 | Move * move_inverse; | ||
| 128 | int len_inverse; | ||
| 129 | }; | 118 | }; |
| 130 | 119 | ||
| 131 | struct | 120 | struct |
| @@ -144,13 +133,11 @@ alglistnode | |||
| 144 | }; | 133 | }; |
| 145 | 134 | ||
| 146 | struct | 135 | struct |
| 147 | choicestep | 136 | block |
| 148 | { | 137 | { |
| 149 | char * shortname; | 138 | bool edge[12]; |
| 150 | char * name; | 139 | bool corner[8]; |
| 151 | Step * step[99]; | 140 | bool center[6]; |
| 152 | Trans t[99]; | ||
| 153 | char * ready_msg; | ||
| 154 | }; | 141 | }; |
| 155 | 142 | ||
| 156 | struct | 143 | struct |
| @@ -169,7 +156,7 @@ commandargs | |||
| 169 | bool success; | 156 | bool success; |
| 170 | Alg * scramble; | 157 | Alg * scramble; |
| 171 | SolveOptions * opts; | 158 | SolveOptions * opts; |
| 172 | ChoiceStep * cs; | 159 | Step * step; |
| 173 | Command * command; /* For help */ | 160 | Command * command; /* For help */ |
| 174 | int n; | 161 | int n; |
| 175 | char scrtype[20]; | 162 | char scrtype[20]; |
| @@ -180,119 +167,119 @@ commandargs | |||
| 180 | struct | 167 | struct |
| 181 | coordinate | 168 | coordinate |
| 182 | { | 169 | { |
| 183 | char * name; | 170 | Indexer index; |
| 184 | CoordType type; | ||
| 185 | bool generated; | ||
| 186 | Indexer * i[99]; | ||
| 187 | uint64_t max; | 171 | uint64_t max; |
| 188 | uint64_t * mtable[NMOVES]; | 172 | CoordMover move; |
| 189 | uint64_t * ttable[NTRANS]; | 173 | CoordTransformer transform; |
| 190 | TransGroup * tgrp; | 174 | SymData * sd; |
| 191 | Coordinate * base[2]; | 175 | TransFinder tfind; /* TODO: should be easy to remove */ |
| 192 | uint64_t * symclass; | 176 | Coordinate * base; /* TODO: part of refactor */ |
| 193 | uint64_t * symrep; | ||
| 194 | Trans * transtorep; | ||
| 195 | Trans * ttrep_move[NMOVES]; | ||
| 196 | uint64_t * selfsim; | ||
| 197 | }; | 177 | }; |
| 198 | 178 | ||
| 199 | struct | 179 | struct |
| 200 | cube | 180 | cube |
| 201 | { | 181 | { |
| 202 | int ep[12]; | 182 | int epose; |
| 203 | int eo[12]; | 183 | int eposs; |
| 204 | int cp[8]; | 184 | int eposm; |
| 205 | int co[8]; | 185 | int eofb; |
| 206 | int xp[6]; | 186 | int eorl; |
| 187 | int eoud; | ||
| 188 | int cp; | ||
| 189 | int coud; | ||
| 190 | int cofb; | ||
| 191 | int corl; | ||
| 192 | int cpos; | ||
| 207 | }; | 193 | }; |
| 208 | 194 | ||
| 209 | /* | ||
| 210 | struct | 195 | struct |
| 211 | movable | 196 | cubearray |
| 212 | { | 197 | { |
| 213 | uint64_t val; | 198 | int * ep; |
| 214 | Trans t; | 199 | int * eofb; |
| 200 | int * eorl; | ||
| 201 | int * eoud; | ||
| 202 | int * cp; | ||
| 203 | int * coud; | ||
| 204 | int * corl; | ||
| 205 | int * cofb; | ||
| 206 | int * cpos; | ||
| 215 | }; | 207 | }; |
| 216 | */ | ||
| 217 | 208 | ||
| 218 | /* | ||
| 219 | struct | 209 | struct |
| 220 | dfsarg | 210 | dfsarg |
| 221 | { | 211 | { |
| 222 | Cube * cube; | 212 | Step * step; |
| 223 | Movable ind[MAX_N_COORD]; | ||
| 224 | Trans t; | ||
| 225 | Step * s; | ||
| 226 | SolveOptions * opts; | 213 | SolveOptions * opts; |
| 214 | Trans t; | ||
| 215 | Cube cube; | ||
| 216 | Cube inverse; | ||
| 227 | int d; | 217 | int d; |
| 228 | int bound; | 218 | uint64_t badmoves; |
| 219 | uint64_t badmovesinv; | ||
| 229 | bool niss; | 220 | bool niss; |
| 221 | Move last1; | ||
| 222 | Move last2; | ||
| 223 | Move last1inv; | ||
| 224 | Move last2inv; | ||
| 225 | EstimateData * ed; | ||
| 230 | AlgList * sols; | 226 | AlgList * sols; |
| 231 | pthread_mutex_t * sols_mutex; | 227 | pthread_mutex_t * sols_mutex; |
| 232 | Alg * current_alg; | 228 | Alg * current_alg; |
| 233 | void * extra; | ||
| 234 | }; | 229 | }; |
| 235 | */ | ||
| 236 | 230 | ||
| 237 | /* | ||
| 238 | struct | 231 | struct |
| 239 | dfsarg | 232 | estimatedata |
| 240 | { | 233 | { |
| 241 | void * cube_data; | 234 | int corners; |
| 242 | SolveOptions * opts; | 235 | int normal_ud; |
| 243 | int d; | 236 | int normal_fb; |
| 244 | int bound; | 237 | int normal_rl; |
| 245 | bool niss; | 238 | int inverse_ud; |
| 246 | AlgList * sols; | 239 | int inverse_fb; |
| 247 | Alg * current_alg; | 240 | int inverse_rl; |
| 248 | Solver * solver; | 241 | int oldret; |
| 249 | Threader * threader; | ||
| 250 | }; | 242 | }; |
| 251 | */ | ||
| 252 | 243 | ||
| 253 | struct | 244 | struct |
| 254 | fstcube | 245 | moveset |
| 255 | { | 246 | { |
| 256 | uint16_t uf_eofb; | 247 | bool (*allowed)(Move); |
| 257 | uint16_t uf_eposepe; | 248 | bool (*allowed_next)(Move, Move, Move); |
| 258 | uint16_t uf_coud; | 249 | Move sorted_moves[NMOVES+1]; |
| 259 | uint16_t uf_cp; | 250 | uint64_t mask[NMOVES][NMOVES]; |
| 260 | uint16_t fr_eofb; | ||
| 261 | uint16_t fr_eposepe; | ||
| 262 | uint16_t fr_coud; | ||
| 263 | uint16_t rd_eofb; | ||
| 264 | uint16_t rd_eposepe; | ||
| 265 | uint16_t rd_coud; | ||
| 266 | }; | 251 | }; |
| 267 | 252 | ||
| 268 | struct | 253 | struct |
| 269 | indexer | 254 | piecefilter |
| 270 | { | 255 | { |
| 271 | int n; | 256 | bool epose; |
| 272 | uint64_t (*index)(Cube *); | 257 | bool eposs; |
| 273 | void (*to_cube)(uint64_t, Cube *); | 258 | bool eposm; |
| 274 | }; | 259 | bool eofb; |
| 275 | 260 | bool eorl; | |
| 276 | struct | 261 | bool eoud; |
| 277 | moveset | 262 | bool cp; |
| 278 | { | 263 | bool coud; |
| 279 | char * name; | 264 | bool cofb; |
| 280 | bool (*allowed)(Move); | 265 | bool corl; |
| 281 | bool (*can_append)(Alg *, Move, bool); | 266 | bool cpos; |
| 282 | bool (*cancel_niss)(Alg *); | ||
| 283 | Move sorted_moves[NMOVES+1]; | ||
| 284 | }; | 267 | }; |
| 285 | 268 | ||
| 286 | struct | 269 | struct |
| 287 | prunedata | 270 | prunedata |
| 288 | { | 271 | { |
| 272 | char * filename; | ||
| 289 | entry_group_t * ptable; | 273 | entry_group_t * ptable; |
| 274 | bool generated; | ||
| 290 | uint64_t n; | 275 | uint64_t n; |
| 291 | Coordinate * coord; | 276 | Coordinate * coord; |
| 292 | Moveset * moveset; | 277 | Moveset * moveset; |
| 293 | uint64_t count[16]; | ||
| 294 | bool compact; | 278 | bool compact; |
| 295 | int base; | 279 | int base; |
| 280 | uint64_t count[16]; | ||
| 281 | PruneData * fallback; | ||
| 282 | uint64_t fbmod; | ||
| 296 | }; | 283 | }; |
| 297 | 284 | ||
| 298 | struct | 285 | struct |
| @@ -313,30 +300,52 @@ solveoptions | |||
| 313 | struct | 300 | struct |
| 314 | step | 301 | step |
| 315 | { | 302 | { |
| 316 | Checker ready; | 303 | char * shortname; |
| 304 | char * name; | ||
| 317 | bool final; | 305 | bool final; |
| 318 | Moveset * moveset; | 306 | Checker is_done; |
| 319 | int n_coord; | 307 | Estimator estimate; |
| 320 | Coordinate * coord[MAX_N_COORD]; | 308 | Checker ready; |
| 321 | Trans coord_trans[MAX_N_COORD]; | 309 | char * ready_msg; |
| 322 | PruneData * pd[MAX_N_COORD]; | ||
| 323 | bool pd_compact[MAX_N_COORD]; | ||
| 324 | Validator is_valid; | 310 | Validator is_valid; |
| 325 | /*DfsMover custom_move_checkstop;*/ | 311 | Moveset * moveset; |
| 326 | DfsExtraCopier copy_extra; | 312 | Trans pre_trans; |
| 313 | TransDetector detect; | ||
| 314 | int ntables; | ||
| 315 | PruneData * tables[10]; | ||
| 316 | }; | ||
| 317 | |||
| 318 | struct | ||
| 319 | symdata | ||
| 320 | { | ||
| 321 | char * filename; | ||
| 322 | bool generated; | ||
| 323 | Coordinate * coord; | ||
| 324 | Coordinate * sym_coord; | ||
| 325 | int ntrans; | ||
| 326 | Trans * trans; | ||
| 327 | uint64_t * class; | ||
| 328 | uint64_t * unsym; | ||
| 329 | Trans * transtorep; | ||
| 330 | uint64_t * selfsim; | ||
| 331 | CoordTransformer transform; /* TODO: remove, use that of base coord */ | ||
| 327 | }; | 332 | }; |
| 328 | 333 | ||
| 329 | /* | ||
| 330 | struct | 334 | struct |
| 331 | threaddatasolve | 335 | threaddatasolve |
| 332 | { | 336 | { |
| 333 | DfsArg arg; | ||
| 334 | int thid; | 337 | int thid; |
| 338 | Trans t; | ||
| 339 | Cube cube; | ||
| 340 | Step * step; | ||
| 341 | int depth; | ||
| 342 | SolveOptions * opts; | ||
| 335 | AlgList * start; | 343 | AlgList * start; |
| 336 | AlgListNode ** node; | 344 | AlgListNode ** node; |
| 345 | AlgList * sols; | ||
| 337 | pthread_mutex_t * start_mutex; | 346 | pthread_mutex_t * start_mutex; |
| 347 | pthread_mutex_t * sols_mutex; | ||
| 338 | }; | 348 | }; |
| 339 | */ | ||
| 340 | 349 | ||
| 341 | struct | 350 | struct |
| 342 | threaddatagenpt | 351 | threaddatagenpt |
| @@ -350,11 +359,4 @@ threaddatagenpt | |||
| 350 | pthread_mutex_t * upmutex; | 359 | pthread_mutex_t * upmutex; |
| 351 | }; | 360 | }; |
| 352 | 361 | ||
| 353 | struct | ||
| 354 | transgroup | ||
| 355 | { | ||
| 356 | int n; | ||
| 357 | Trans t[NTRANS]; | ||
| 358 | }; | ||
| 359 | |||
| 360 | #endif | 362 | #endif |
