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.h157
1 files changed, 3 insertions, 154 deletions
diff --git a/src/core/cube.h b/src/core/cube.h
index b24fb5c..4b28103 100644
--- a/src/core/cube.h
+++ b/src/core/cube.h
@@ -13,11 +13,13 @@ _static cube_t frommoves(const char *);
13_static void getcube_fix(int64_t *, int64_t *, int64_t *, int64_t *); 13_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); 14_static cube_t getcube(int64_t, int64_t, int64_t, int64_t);
15 15
16_static cube_t move(cube_t, uint8_t);
17_static cube_t transform_edges(cube_t, uint8_t); 16_static cube_t transform_edges(cube_t, uint8_t);
18_static cube_t transform_corners(cube_t, uint8_t); 17_static cube_t transform_corners(cube_t, uint8_t);
19_static cube_t transform(cube_t, uint8_t); 18_static cube_t transform(cube_t, uint8_t);
20 19
20/* declared in moves.h */
21_static cube_t move(cube_t, uint8_t);
22
21_static cube_t 23_static cube_t
22cubefromarray(uint8_t c[static 8], uint8_t e[static 12]) 24cubefromarray(uint8_t c[static 8], uint8_t e[static 12])
23{ 25{
@@ -239,159 +241,6 @@ applytrans(cube_t cube, const char *buf)
239 return transform(cube, t); 241 return transform(cube, t);
240} 242}
241 243
242_static cube_t
243move(cube_t c, uint8_t m)
244{
245 switch (m) {
246 case _move_U:
247 return _move(U, c);
248 case _move_U2:
249 return _move(U2, c);
250 case _move_U3:
251 return _move(U3, c);
252 case _move_D:
253 return _move(D, c);
254 case _move_D2:
255 return _move(D2, c);
256 case _move_D3:
257 return _move(D3, c);
258 case _move_R:
259 return _move(R, c);
260 case _move_R2:
261 return _move(R2, c);
262 case _move_R3:
263 return _move(R3, c);
264 case _move_L:
265 return _move(L, c);
266 case _move_L2:
267 return _move(L2, c);
268 case _move_L3:
269 return _move(L3, c);
270 case _move_F:
271 return _move(F, c);
272 case _move_F2:
273 return _move(F2, c);
274 case _move_F3:
275 return _move(F3, c);
276 case _move_B:
277 return _move(B, c);
278 case _move_B2:
279 return _move(B2, c);
280 case _move_B3:
281 return _move(B3, c);
282 default:
283 LOG("move error, unknown move\n");
284 return zero;
285 }
286}
287
288_static cube_t
289premove(cube_t c, uint8_t m){
290 switch (m) {
291 case _move_U:
292 return _premove(U3, c);
293 case _move_U2:
294 return _premove(U2, c);
295 case _move_U3:
296 return _premove(U, c);
297 case _move_D:
298 return _premove(D3, c);
299 case _move_D2:
300 return _premove(D2, c);
301 case _move_D3:
302 return _premove(D, c);
303 case _move_R:
304 return _premove(R3, c);
305 case _move_R2:
306 return _premove(R2, c);
307 case _move_R3:
308 return _premove(R, c);
309 case _move_L:
310 return _premove(L3, c);
311 case _move_L2:
312 return _premove(L2, c);
313 case _move_L3:
314 return _premove(L, c);
315 case _move_F:
316 return _premove(F3, c);
317 case _move_F2:
318 return _premove(F2, c);
319 case _move_F3:
320 return _premove(F, c);
321 case _move_B:
322 return _premove(B3, c);
323 case _move_B2:
324 return _premove(B2, c);
325 case _move_B3:
326 return _premove(B, c);
327 default:
328 LOG("move error, unknown move\n");
329 return zero;
330 }
331}
332_static uint8_t
333invertmove(uint8_t m)
334{
335 switch (m) {
336 case _move_U:
337 return _move_U3;
338 case _move_U2:
339 return _move_U2;
340 case _move_U3:
341 return _move_U;
342 case _move_D:
343 return _move_D3;
344 case _move_D2:
345 return _move_D2;
346 case _move_D3:
347 return _move_D;
348 case _move_R:
349 return _move_R3;
350 case _move_R2:
351 return _move_R2;
352 case _move_R3:
353 return _move_R;
354 case _move_L:
355 return _move_L3;
356 case _move_L2:
357 return _move_L2;
358 case _move_L3:
359 return _move_L;
360 case _move_F:
361 return _move_F3;
362 case _move_F2:
363 return _move_F2;
364 case _move_F3:
365 return _move_F;
366 case _move_B:
367 return _move_B3;
368 case _move_B2:
369 return _move_B2;
370 case _move_B3:
371 return _move_B;
372 default:
373 LOG("invertmove error, unknown move\n");
374 return _error;
375 }
376}
377
378_static uint8_t*
379invertpremoves(uint8_t *moves, uint8_t nmoves)
380{
381 uint8_t i;
382 uint8_t *ret = malloc(nmoves * sizeof(uint8_t));
383
384 for (i = 0; i < nmoves; i++)
385 ret[i] = invertmove(moves[i]);
386
387 // invert elements in the array
388 for (i = 0; i < nmoves / 2; i++)
389 _swap(ret[i], ret[nmoves - i - 1]);
390 return ret;
391}
392
393
394
395/* 244/*
396TODO transform is now relegated to a separated file because it is too long. 245TODO transform is now relegated to a separated file because it is too long.
397It would be nice to make it shorter without loosing performance. 246It would be nice to make it shorter without loosing performance.

Generated with cgit - Back to sebastiano.tronto.net