aboutsummaryrefslogtreecommitdiff
path: root/src/core/cube.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/cube.h')
-rw-r--r--src/core/cube.h66
1 files changed, 0 insertions, 66 deletions
diff --git a/src/core/cube.h b/src/core/cube.h
index 4b28103..df5161a 100644
--- a/src/core/cube.h
+++ b/src/core/cube.h
@@ -1,25 +1,12 @@
1#define _move(M, c) compose(c, _move_cube_ ## M)
2#define _premove(M, c) compose(_move_cube_ ## M, c)
3
4_static cube_t cubefromarray(uint8_t [static 8], uint8_t [static 12]); 1_static cube_t cubefromarray(uint8_t [static 8], uint8_t [static 12]);
5_static cube_t solvedcube(void); 2_static cube_t solvedcube(void);
6_static bool isconsistent(cube_t); 3_static bool isconsistent(cube_t);
7_static bool issolvable(cube_t); 4_static bool issolvable(cube_t);
8_static bool issolved(cube_t); 5_static bool issolved(cube_t);
9_static bool iserror(cube_t); 6_static bool iserror(cube_t);
10_static cube_t applymoves(cube_t, const char *);
11_static cube_t applytrans(cube_t, const char *);
12_static cube_t frommoves(const char *);
13_static void getcube_fix(int64_t *, int64_t *, int64_t *, int64_t *); 7_static void getcube_fix(int64_t *, int64_t *, int64_t *, int64_t *);
14_static cube_t getcube(int64_t, int64_t, int64_t, int64_t); 8_static cube_t getcube(int64_t, int64_t, int64_t, int64_t);
15 9
16_static cube_t transform_edges(cube_t, uint8_t);
17_static cube_t transform_corners(cube_t, uint8_t);
18_static cube_t transform(cube_t, uint8_t);
19
20/* declared in moves.h */
21_static cube_t move(cube_t, uint8_t);
22
23_static cube_t 10_static cube_t
24cubefromarray(uint8_t c[static 8], uint8_t e[static 12]) 11cubefromarray(uint8_t c[static 8], uint8_t e[static 12])
25{ 12{
@@ -149,41 +136,6 @@ iserror(cube_t cube)
149 return equal(cube, zero); 136 return equal(cube, zero);
150} 137}
151 138
152_static cube_t
153applymoves(cube_t cube, const char *buf)
154{
155 uint8_t r, m;
156 const char *b;
157
158 DBG_ASSERT(isconsistent(cube), zero,
159 "move error: inconsistent cube\n");
160
161 for (b = buf; *b != '\0'; b++) {
162 while (*b == ' ' || *b == '\t' || *b == '\n')
163 b++;
164 if (*b == '\0')
165 goto applymoves_finish;
166 if ((r = readmove(*b)) == _error)
167 goto applymoves_error;
168 if ((m = readmodifier(*(b+1))) != 0)
169 b++;
170 cube = move(cube, r + m);
171 }
172
173applymoves_finish:
174 return cube;
175
176applymoves_error:
177 LOG("applymoves error\n");
178 return zero;
179}
180
181_static cube_t
182frommoves(const char *buf)
183{
184 return applymoves(solved, buf);
185}
186
187_static void 139_static void
188getcube_fix(int64_t *ep, int64_t *eo, int64_t *cp, int64_t *co) 140getcube_fix(int64_t *ep, int64_t *eo, int64_t *cp, int64_t *co)
189{ 141{
@@ -227,21 +179,3 @@ getcube(int64_t ep, int64_t eo, int64_t cp, int64_t co)
227 179
228 return cubefromarray(carr, earr); 180 return cubefromarray(carr, earr);
229} 181}
230
231_static cube_t
232applytrans(cube_t cube, const char *buf)
233{
234 uint8_t t;
235
236 DBG_ASSERT(isconsistent(cube), zero,
237 "transformation error: inconsistent cube\n");
238
239 t = readtrans(buf);
240
241 return transform(cube, t);
242}
243
244/*
245TODO transform is now relegated to a separated file because it is too long.
246It would be nice to make it shorter without loosing performance.
247*/

Generated with cgit - Back to sebastiano.tronto.net