aboutsummaryrefslogtreecommitdiff
path: root/cube.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2023-11-10 17:07:42 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2023-11-10 19:55:55 +0100
commit067ba55add258ab03db328234168af66c4ad87c3 (patch)
treef4861907117c420eed3f9c9aa967bf9f2c6a1f7e /cube.h
parentaf1399f223e3857a3d2690337e84430cdbeff16a (diff)
downloadnissy-core-067ba55add258ab03db328234168af66c4ad87c3.tar.gz
nissy-core-067ba55add258ab03db328234168af66c4ad87c3.zip
Towards a definitve API
Diffstat (limited to '')
-rw-r--r--cube.h68
1 files changed, 32 insertions, 36 deletions
diff --git a/cube.h b/cube.h
index d8896d8..791d167 100644
--- a/cube.h
+++ b/cube.h
@@ -106,50 +106,46 @@ cube_t readcube(char *format, char *buf);
106void writecube(char *format, cube_t cube, char *buf); 106void writecube(char *format, cube_t cube, char *buf);
107 107
108/****************************************************************************** 108/******************************************************************************
109Coordinates
110
111TODO description
112******************************************************************************/
113
114int64_t coord_eo(cube_t);
115
116/******************************************************************************
117Solvers 109Solvers
118 110
119The solutions are returned as a newline-separated list of characters. 111The solutions are returned as a newline-separated list of characters. Moves
112are separated by single spaces.
120 113
121Unless specified otherwise, all the solutions are not trivially simplifiable. 114Unless specified otherwise, all the solutions are not trivially simplifiable.
122This means that sequences like U U2 or R L R will not appear in any solution. 115This means that sequences like U U2 or R L R will not appear in any solution.
123Moreover, two consecutive parallel moves are always going to be sorted in 116Moreover, two consecutive parallel moves are always going to be sorted in
124increasing order. For example, L R2 may never appear in a solution, but R2 L 117increasing order. For example, L R2 may never appear in a solution, but R2 L
125could. 118could.
126
127Solvers return -1 in case of error, the number of solutions found otherwise.
128
129TODO NISS / INVERSE / LINEAR as a mask?
130
131All solvers take at least the following parameters, satisfying the conditions
132in square brackets:
133TODO 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
144Some solvers take other parameters. See below for details.
145******************************************************************************/ 119******************************************************************************/
146 120
147/* TODO 121int64_t solve(
148int 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 */
147void 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. */
151int64_t gendata(char *solver, void *data);

Generated with cgit - Back to sebastiano.tronto.net