solve.h (1884B)
1 #ifndef SOLVE_H 2 #define SOLVE_H 3 4 /* TODO: remove multiple solvers? 5 can just run solver multiple times and then merge the results 6 */ 7 8 #include "moves.h" 9 10 #define MAX_SOLVERS 99 11 12 typedef struct dfsarg DfsArg; 13 typedef struct threader Threader; 14 typedef struct solver Solver; 15 16 /* TODO: add solver and threader in DfsData, remove from dispatch args and similar */ 17 18 struct dfsarg { 19 void * cubedata; 20 void * threaddata; 21 SolveOptions * opts; 22 int d; 23 bool niss; 24 Alg * current_alg; 25 }; 26 27 struct threader { 28 void (*append_sol)(Alg *, void *); 29 void (*dispatch)(DfsArg *, AlgList *, Solver *, Threader *); 30 int (*get_nsol)(void *); 31 /* TODO: threader should have param, like solver? */ 32 }; 33 34 struct solver { 35 Moveset * moveset; 36 bool (*move_check_stop)(void *, DfsArg *, Threader *); 37 Alg * (*validate_solution)(void *, Alg *); 38 bool (*niss_makes_sense)(void *, void *, Alg *); 39 /* TODO: move param to somewhere where it makes more sense */ 40 void * param; 41 /* TODO: the following should be part of a generic cube description */ 42 /* TODO: remove alloc? */ 43 /* TODO: revisit apply_move, maybe apply_alg? or both? */ 44 void * (*alloc_cubedata)(void *); 45 /* TODO: replace by knowing size and doing memcpy? */ 46 void (*copy_cubedata)(void *, void *, void *); 47 void (*free_cubedata)(void *, void *); 48 void (*invert_cube)(void *, void *); 49 bool (*is_solved)(void *, void *); 50 void (*apply_move)(void *, void *, Move); 51 /* TODO: remove dependence on Cube, preparation should be done before */ 52 void * (*prepare_cube)(void *, Cube *); 53 }; 54 55 void dfs(DfsArg *, Solver *, Threader *); 56 /* TODO: remove dependence on Cube, preparation should be done before */ 57 AlgList * solve(Cube *, SolveOptions *, Solver **, Threader *); 58 59 #endif