diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-11-10 17:07:42 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-11-10 19:55:55 +0100 |
| commit | 067ba55add258ab03db328234168af66c4ad87c3 (patch) | |
| tree | f4861907117c420eed3f9c9aa967bf9f2c6a1f7e /cube.h | |
| parent | af1399f223e3857a3d2690337e84430cdbeff16a (diff) | |
| download | nissy-core-067ba55add258ab03db328234168af66c4ad87c3.tar.gz nissy-core-067ba55add258ab03db328234168af66c4ad87c3.zip | |
Towards a definitve API
Diffstat (limited to 'cube.h')
| -rw-r--r-- | cube.h | 68 |
1 files changed, 32 insertions, 36 deletions
| @@ -106,50 +106,46 @@ cube_t readcube(char *format, char *buf); | |||
| 106 | void writecube(char *format, cube_t cube, char *buf); | 106 | void writecube(char *format, cube_t cube, char *buf); |
| 107 | 107 | ||
| 108 | /****************************************************************************** | 108 | /****************************************************************************** |
| 109 | Coordinates | ||
| 110 | |||
| 111 | TODO description | ||
| 112 | ******************************************************************************/ | ||
| 113 | |||
| 114 | int64_t coord_eo(cube_t); | ||
| 115 | |||
| 116 | /****************************************************************************** | ||
| 117 | Solvers | 109 | Solvers |
| 118 | 110 | ||
| 119 | The solutions are returned as a newline-separated list of characters. | 111 | The solutions are returned as a newline-separated list of characters. Moves |
| 112 | are separated by single spaces. | ||
| 120 | 113 | ||
| 121 | Unless specified otherwise, all the solutions are not trivially simplifiable. | 114 | Unless specified otherwise, all the solutions are not trivially simplifiable. |
| 122 | This means that sequences like U U2 or R L R will not appear in any solution. | 115 | This means that sequences like U U2 or R L R will not appear in any solution. |
| 123 | Moreover, two consecutive parallel moves are always going to be sorted in | 116 | Moreover, two consecutive parallel moves are always going to be sorted in |
| 124 | increasing order. For example, L R2 may never appear in a solution, but R2 L | 117 | increasing order. For example, L R2 may never appear in a solution, but R2 L |
| 125 | could. | 118 | could. |
| 126 | |||
| 127 | Solvers return -1 in case of error, the number of solutions found otherwise. | ||
| 128 | |||
| 129 | TODO NISS / INVERSE / LINEAR as a mask? | ||
| 130 | |||
| 131 | All solvers take at least the following parameters, satisfying the conditions | ||
| 132 | in square brackets: | ||
| 133 | TODO more! | ||
| 134 | - cube_t cube [issolvable(cube)]: The cube to solve. | ||
| 135 | - uint8_t depth [depth <= 20]: The lenght of the solution. | ||
| 136 | - int maxsols: The maximum number of solutions to find. The solver | ||
| 137 | stops when the limit is reached. If set to a negative number, all | ||
| 138 | the solutions are found. | ||
| 139 | - move_t *ret: The array where the moves of the solutions are stored. | ||
| 140 | There is no separator between different solutions; to read the | ||
| 141 | solutions, use the fact that all solutions has the same length: the | ||
| 142 | i-th move of the j-th solution is ret[j*depth + i]. | ||
| 143 | |||
| 144 | Some solvers take other parameters. See below for details. | ||
| 145 | ******************************************************************************/ | 119 | ******************************************************************************/ |
| 146 | 120 | ||
| 147 | /* TODO | 121 | int64_t solve( |
| 148 | int solve_generic( | 122 | cube_t cube, /* The cube to solve. Must be solvable. */ |
| 149 | cube_t cube, | 123 | char *solver, /* The solver. Supported solvers: TODO. */ |
| 150 | uint8_t depth, | 124 | char *options, /* Some solvers accept extra options, |
| 151 | int maxsols, | 125 | * like "!filter". |
| 152 | uint8_t *ret, // TODO change to char | 126 | */ |
| 153 | int (*estimate)(cube_t) | 127 | char *nisstype, /* Can be "normal", "inverse", "mixed" or "linear". */ |
| 128 | int8_t minmoves, /* The minimum number of moves. Must be >= 0. */ | ||
| 129 | int8_t maxmoves, /* The maximum number of moves. If negative, the | ||
| 130 | * maximum length is unlimited. | ||
| 131 | */ | ||
| 132 | int64_t maxsols, /* The maximum number of solutions. */ | ||
| 133 | int64_t optimal, /* All solutions at most "optimal" moves from the | ||
| 134 | * shortest solution (respecting minmoves) are found. | ||
| 135 | * If negative, this parameter is ignored. | ||
| 136 | */ | ||
| 137 | void *data, /* Some solvers require extra data to function | ||
| 138 | * properly (for example, pruning tables). This data | ||
| 139 | * can be generated with gendata(), see below. | ||
| 140 | */ | ||
| 141 | char *solutions /* The solutions (return parameter) */ | ||
| 154 | ); | 142 | ); |
| 155 | */ | 143 | |
| 144 | /* Solving n cubes optimally, one solutions per cube. Options are similar | ||
| 145 | * to solve(). | ||
| 146 | */ | ||
| 147 | void multisolve(int n, cube_t *cube, char *solver, void *data, char *sols); | ||
| 148 | |||
| 149 | /* Returns the number of bytes written to data, -1 in case of error. | ||
| 150 | * TODO: write down how much memory every solver requires. */ | ||
| 151 | int64_t gendata(char *solver, void *data); | ||
