diff options
Diffstat (limited to 'src/core/cube.h')
| -rw-r--r-- | src/core/cube.h | 66 |
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 |
| 24 | cubefromarray(uint8_t c[static 8], uint8_t e[static 12]) | 11 | cubefromarray(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 | ||
| 153 | applymoves(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 | |||
| 173 | applymoves_finish: | ||
| 174 | return cube; | ||
| 175 | |||
| 176 | applymoves_error: | ||
| 177 | LOG("applymoves error\n"); | ||
| 178 | return zero; | ||
| 179 | } | ||
| 180 | |||
| 181 | _static cube_t | ||
| 182 | frommoves(const char *buf) | ||
| 183 | { | ||
| 184 | return applymoves(solved, buf); | ||
| 185 | } | ||
| 186 | |||
| 187 | _static void | 139 | _static void |
| 188 | getcube_fix(int64_t *ep, int64_t *eo, int64_t *cp, int64_t *co) | 140 | getcube_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 | ||
| 232 | applytrans(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 | /* | ||
| 245 | TODO transform is now relegated to a separated file because it is too long. | ||
| 246 | It would be nice to make it shorter without loosing performance. | ||
| 247 | */ | ||
