diff options
Diffstat (limited to 'old/2021-02-28-transformcube-works/src/solve.h')
| -rw-r--r-- | old/2021-02-28-transformcube-works/src/solve.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/old/2021-02-28-transformcube-works/src/solve.h b/old/2021-02-28-transformcube-works/src/solve.h new file mode 100644 index 0000000..d585a8e --- /dev/null +++ b/old/2021-02-28-transformcube-works/src/solve.h | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | #ifndef SOLVE_H | ||
| 2 | #define SOLVE_H | ||
| 3 | |||
| 4 | #include <stdlib.h> | ||
| 5 | #include "cube.h" | ||
| 6 | #include "moves.h" | ||
| 7 | |||
| 8 | /* Maximum number of moves per solution and of solutions */ | ||
| 9 | #define MAXM 30 | ||
| 10 | #define MAXS 999 | ||
| 11 | |||
| 12 | /* Data for solving a step: | ||
| 13 | - can_niss is true niss can be used, false otherwise. | ||
| 14 | - optimal_only if true, dynamically updates max_moves so non-optimal | ||
| 15 | solutions are discarded. | ||
| 16 | - cleanup determines whether the cleaunup() function should be used on | ||
| 17 | the found solutions before returning. | ||
| 18 | - available[m] is true if the move m can be used, false otherwise. | ||
| 19 | - min_moves and max_moves are the minimum and maximum number of moves that | ||
| 20 | can be used. | ||
| 21 | - max_solution is the maximum number of solutions that can be returned. | ||
| 22 | - precondition can be used to check wheter the step can actually be applied | ||
| 23 | to the cube. If it returns false, solve() stops immediately returning -1. | ||
| 24 | - f must return 0 if and only if the step is solve, otherwise it must return | ||
| 25 | a lower bound for the number of moves required (without niss). | ||
| 26 | - sorted_moves[] can be used to specify in which order moves are tried | ||
| 27 | by the solving algorithm (for example if one wants to always try F' before | ||
| 28 | F). If sorted_moves[0] == NULLMOVE, the list is generated automatically. | ||
| 29 | It is advised to list first all the moves that actually influence the | ||
| 30 | solved state of the step (this is the default choice). This is in order to | ||
| 31 | avoid cases like B2 F for EO and to NISS only when it makes sense. | ||
| 32 | - start_moves [Currently unused, REMOVE] | ||
| 33 | are the moves that will be used as first moves of all | ||
| 34 | solutions. For example giving R' U' F (F' U R) will generate FMC scrambles | ||
| 35 | and y (y) will solve the step on another axis. | ||
| 36 | - pre_rotation are the rotations to apply before the scamble to solve | ||
| 37 | the step wrt a different orientation | ||
| 38 | - pre_rotation are the rotations to apply before the scamble to solve | ||
| 39 | the step wth respect to a different orientation. | ||
| 40 | - solutions[][] is the array where to store the found solutions. */ | ||
| 41 | typedef struct { | ||
| 42 | bool can_niss, optimal_only, cleanup, *available; | ||
| 43 | int min_moves, max_moves; | ||
| 44 | uint64_t max_solutions; | ||
| 45 | bool (*precondition)(Cube); | ||
| 46 | uint16_t (*f)(Cube); | ||
| 47 | Move sorted_moves[NMOVES]; | ||
| 48 | NissMove pre_rotation[3], solutions[MAXS][MAXM]; | ||
| 49 | } SolveData; | ||
| 50 | |||
| 51 | int solve(Cube cube, SolveData *data); /* Returns the number of solutions. */ | ||
| 52 | |||
| 53 | /* Steps */ | ||
| 54 | uint16_t f_eofb(Cube cube); | ||
| 55 | |||
| 56 | #endif | ||
