diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-10-27 16:25:15 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-10-27 16:25:15 +0200 |
| commit | 2a8d66906dde19ffb7315fb3f60a396a71612037 (patch) | |
| tree | aa6c340c6de7cffd65b23f93b4479b128036250b | |
| parent | 287f6c4067a206fb1c18eb779ef8463f06c0e5e1 (diff) | |
| download | nissy-core-2a8d66906dde19ffb7315fb3f60a396a71612037.tar.gz nissy-core-2a8d66906dde19ffb7315fb3f60a396a71612037.zip | |
Small cleanup
| -rw-r--r-- | src/cube.c | 26 | ||||
| -rw-r--r-- | src/cube.h | 81 |
2 files changed, 43 insertions, 64 deletions
| @@ -152,30 +152,8 @@ static char *transstr[] = { | |||
| 152 | }; | 152 | }; |
| 153 | 153 | ||
| 154 | cube_t solvedcube = { | 154 | cube_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 | ||
| 181 | static cube_t errorcube = { .e = {0}, .c = {0} }; | 159 | static cube_t errorcube = { .e = {0}, .c = {0} }; |
| @@ -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 */ | ||
| 5 | typedef struct { | ||
| 6 | uint8_t c[8]; | ||
| 7 | uint8_t e[12]; | ||
| 8 | } cube_t; | ||
| 9 | |||
| 10 | typedef uint8_t move_t; | ||
| 11 | typedef uint8_t trans_t; | ||
| 12 | |||
| 13 | extern 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. */ | ||
| 19 | typedef enum {H48, SRC} format_t; | ||
| 20 | cube_t readcube(format_t, char *); | ||
| 21 | void writecube(format_t, cube_t, char *); | ||
| 22 | |||
| 23 | bool issolvable(cube_t); | ||
| 24 | bool equal(cube_t, cube_t); | ||
| 25 | bool issolved(cube_t); | ||
| 26 | bool iserror(cube_t); | ||
| 27 | |||
| 28 | int readmoves(char *, move_t *); | ||
| 29 | void writemoves(move_t *, int, char *); | ||
| 30 | |||
| 31 | trans_t readtrans(char *); | ||
| 32 | void writetrans(trans_t, char *); | ||
| 33 | |||
| 34 | cube_t move(cube_t, move_t); | ||
| 35 | cube_t inverse(cube_t); | ||
| 36 | cube_t compose(cube_t, cube_t); | ||
| 37 | |||
| 38 | /* See doc/TRANSFORMATIONS.md for how transformations are applied */ | ||
| 39 | cube_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 */ | ||
| 83 | typedef struct { | ||
| 84 | uint8_t c[8]; | ||
| 85 | uint8_t e[12]; | ||
| 86 | } cube_t; | ||
| 87 | |||
| 88 | typedef uint8_t move_t; | ||
| 89 | typedef uint8_t trans_t; | ||
| 90 | |||
| 91 | extern 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. */ | ||
| 97 | typedef enum {H48, SRC} format_t; | ||
| 98 | cube_t readcube(format_t, char *); | ||
| 99 | void writecube(format_t, cube_t, char *); | ||
| 100 | |||
| 101 | bool issolvable(cube_t); | ||
| 102 | bool equal(cube_t, cube_t); | ||
| 103 | bool issolved(cube_t); | ||
| 104 | bool iserror(cube_t); | ||
| 105 | |||
| 106 | int readmoves(char *, move_t *); | ||
| 107 | void writemoves(move_t *, int, char *); | ||
| 108 | |||
| 109 | trans_t readtrans(char *); | ||
| 110 | void writetrans(trans_t, char *); | ||
| 111 | |||
| 112 | cube_t move(cube_t, move_t); | ||
| 113 | cube_t inverse(cube_t); | ||
| 114 | cube_t compose(cube_t, cube_t); | ||
| 115 | |||
| 116 | /* See doc/TRANSFORMATIONS.md for how transformations are applied */ | ||
| 117 | cube_t transform(cube_t, trans_t); | ||
