aboutsummaryrefslogtreecommitdiff
path: root/old/2021-02-06/cube.h
diff options
context:
space:
mode:
Diffstat (limited to 'old/2021-02-06/cube.h')
-rw-r--r--old/2021-02-06/cube.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/old/2021-02-06/cube.h b/old/2021-02-06/cube.h
new file mode 100644
index 0000000..bc4f14b
--- /dev/null
+++ b/old/2021-02-06/cube.h
@@ -0,0 +1,60 @@
1#ifndef CUBE_H
2#define CUBE_H
3
4#include <stdio.h>
5#include <stdbool.h>
6#include <stdint.h>
7#include "utils.h"
8
9#define NMOVES (z3+1)
10
11/* Constants for moves and pieces */
12typedef enum {
13 NULLMOVE,
14 U, U2, U3, D, D2, D3, R, R2, R3, L, L2, L3, F, F2, F3, B, B2, B3,
15 Uw, Uw2, Uw3, Dw, Dw2, Dw3, Rw, Rw2, Rw3,
16 Lw, Lw2, Lw3, Fw, Fw2, Fw3, Bw, Bw2, Bw3,
17 M, M2, M3, S, S2, S3, E, E2, E3,
18 x, x2, x3, y, y2, y3, z, z2, z3,
19} Move;
20typedef enum {U_center,D_center,R_center,L_center,F_center,B_center} Center;
21typedef enum { UF, UL, UB, UR, DF, DL, DB, DR, FR, FL, BL, BR } Edge;
22typedef enum { UFR, UFL, UBL, UBR, DFR, DFL, DBL, DBR } Corner;
23
24/* An alg is an array of "NissMoves", which can be on normal or on inverse. */
25typedef struct { bool inverse; Move m; } NissMove;
26
27/* Representation of the cube */
28typedef struct {
29 uint16_t eofb, eorl, eoud, coud, cofb, corl,
30 epose, eposs, eposm, cp, cpos;
31} Cube;
32
33extern bool commute[NMOVES][NMOVES];
34extern bool possible_next[NMOVES][NMOVES][NMOVES];
35extern Move inverse[NMOVES];
36/* Movesets */
37extern bool standard_moveset[NMOVES];
38
39int copy_alg(NissMove *src, NissMove *dest); /*return number of moves copied */
40
41bool equal(Cube c1, Cube c2);
42bool is_solvable(Cube cube);
43/* reorient=true allows solved in wrong orientation */
44bool is_solved(Cube cube, bool reorient);
45void print_cube(Cube cube);
46void print_moves(NissMove *alg);
47int read_moves(char *str, NissMove *alg, int n); /* reads at most n moves */
48void cleanup(NissMove *src, int n); /* rewrites using basic moves, at most n */
49Cube blank_cube();
50Cube inverse_cube(Cube cube);
51Cube move_cube(Move m, Cube cube);
52Cube compose(Cube c2, Cube c1); /* Use c2 as an alg */
53Cube apply_alg(NissMove *alg, Cube cube);
54
55void init_ttables(bool read, bool write);
56void init_aux_tables();
57
58void init_dbg();
59
60#endif

Generated with cgit - Back to sebastiano.tronto.net