aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2023-10-27 16:25:15 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2023-10-27 16:25:15 +0200
commit2a8d66906dde19ffb7315fb3f60a396a71612037 (patch)
treeaa6c340c6de7cffd65b23f93b4479b128036250b
parent287f6c4067a206fb1c18eb779ef8463f06c0e5e1 (diff)
downloadnissy-core-2a8d66906dde19ffb7315fb3f60a396a71612037.tar.gz
nissy-core-2a8d66906dde19ffb7315fb3f60a396a71612037.zip
Small cleanup
Diffstat (limited to '')
-rw-r--r--src/cube.c26
-rw-r--r--src/cube.h81
2 files changed, 43 insertions, 64 deletions
diff --git a/src/cube.c b/src/cube.c
index 48bc2f5..87570b4 100644
--- a/src/cube.c
+++ b/src/cube.c
@@ -152,30 +152,8 @@ static char *transstr[] = {
152}; 152};
153 153
154cube_t solvedcube = { 154cube_t solvedcube = {
155 .c = { 155 .c = {0, 1, 2, 3, 4, 5, 6, 7},
156 [_c_ufr] = _c_ufr, 156 .e = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
157 [_c_ubl] = _c_ubl,
158 [_c_dfl] = _c_dfl,
159 [_c_dbr] = _c_dbr,
160 [_c_ufl] = _c_ufl,
161 [_c_ubr] = _c_ubr,
162 [_c_dfr] = _c_dfr,
163 [_c_dbl] = _c_dbl
164 },
165 .e = {
166 [_e_uf] = _e_uf,
167 [_e_ub] = _e_ub,
168 [_e_db] = _e_db,
169 [_e_df] = _e_df,
170 [_e_ur] = _e_ur,
171 [_e_ul] = _e_ul,
172 [_e_dl] = _e_dl,
173 [_e_dr] = _e_dr,
174 [_e_fr] = _e_fr,
175 [_e_fl] = _e_fl,
176 [_e_bl] = _e_bl,
177 [_e_br] = _e_br
178 }
179}; 157};
180 158
181static cube_t errorcube = { .e = {0}, .c = {0} }; 159static cube_t errorcube = { .e = {0}, .c = {0} };
diff --git a/src/cube.h b/src/cube.h
index cac6b01..1e11432 100644
--- a/src/cube.h
+++ b/src/cube.h
@@ -1,4 +1,44 @@
1/* Constants *****************************************************************/ 1/* Types *********************************************************************/
2
3/* TODO: ifdef for different implementations */
4/* See doc/CUBE_INTERNAL.md for a description of the cube format */
5typedef struct {
6 uint8_t c[8];
7 uint8_t e[12];
8} cube_t;
9
10typedef uint8_t move_t;
11typedef uint8_t trans_t;
12
13extern cube_t solvedcube;
14
15/* Functions *****************************************************************/
16
17/* Not all formats are supported for both read and write. */
18/* See doc/CUBE_TEXT.md for details. */
19typedef enum {H48, SRC} format_t;
20cube_t readcube(format_t, char *);
21void writecube(format_t, cube_t, char *);
22
23bool issolvable(cube_t);
24bool equal(cube_t, cube_t);
25bool issolved(cube_t);
26bool iserror(cube_t);
27
28int readmoves(char *, move_t *);
29void writemoves(move_t *, int, char *);
30
31trans_t readtrans(char *);
32void writetrans(trans_t, char *);
33
34cube_t move(cube_t, move_t);
35cube_t inverse(cube_t);
36cube_t compose(cube_t, cube_t);
37
38/* See doc/TRANSFORMATIONS.md for how transformations are applied */
39cube_t transform(cube_t, trans_t);
40
41/* Constants for moves and transformations ***********************************/
2 42
3/* Standard moves */ 43/* Standard moves */
4#define U 0U 44#define U 0U
@@ -76,42 +116,3 @@
76#define errormove 99U 116#define errormove 99U
77#define errortrans 99U 117#define errortrans 99U
78 118
79/* Types *********************************************************************/
80
81/* TODO: ifdef for different implementations */
82/* See doc/CUBE_INTERNAL.md for a description of the cube format */
83typedef struct {
84 uint8_t c[8];
85 uint8_t e[12];
86} cube_t;
87
88typedef uint8_t move_t;
89typedef uint8_t trans_t;
90
91extern cube_t solvedcube;
92
93/* Functions *****************************************************************/
94
95/* Not all formats are supported for both read and write. */
96/* See doc/CUBE_TEXT.md for details. */
97typedef enum {H48, SRC} format_t;
98cube_t readcube(format_t, char *);
99void writecube(format_t, cube_t, char *);
100
101bool issolvable(cube_t);
102bool equal(cube_t, cube_t);
103bool issolved(cube_t);
104bool iserror(cube_t);
105
106int readmoves(char *, move_t *);
107void writemoves(move_t *, int, char *);
108
109trans_t readtrans(char *);
110void writetrans(trans_t, char *);
111
112cube_t move(cube_t, move_t);
113cube_t inverse(cube_t);
114cube_t compose(cube_t, cube_t);
115
116/* See doc/TRANSFORMATIONS.md for how transformations are applied */
117cube_t transform(cube_t, trans_t);

Generated with cgit - Back to sebastiano.tronto.net