diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-10-05 09:31:02 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-10-05 09:42:39 +0200 |
| commit | 9e698917cb5b332cdbf1969ddfe3840239106c8d (patch) | |
| tree | 1125917c5d281aff8acfd94292b8a3d3e370bc2d /src/cube.h | |
| parent | 99fabe8592a4022313b1cb0581881ee1bc6b1c99 (diff) | |
| download | nissy-core-9e698917cb5b332cdbf1969ddfe3840239106c8d.tar.gz nissy-core-9e698917cb5b332cdbf1969ddfe3840239106c8d.zip | |
Implemented compose; some cleanup
Diffstat (limited to '')
| -rw-r--r-- | src/cube.h | 51 |
1 files changed, 6 insertions, 45 deletions
| @@ -1,52 +1,13 @@ | |||
| 1 | typedef enum { | 1 | /* TODO: ifdef for different implementations */ |
| 2 | U = 0, U2, U3, D, D2, D3, | 2 | #include "cube_array.h" |
| 3 | R, R2, R3, L, L2, L3, | ||
| 4 | F, F2, F3, B, B2, B3 | ||
| 5 | } move_t; | ||
| 6 | 3 | ||
| 7 | typedef enum { | 4 | /* For moves and transformations, see constants.h */ |
| 8 | UF_i = 0, UL_i, UB_i, UR_i, DF_i, DL_i, DB_i, DR_i, | 5 | typedef uint8_t move_t; |
| 9 | UF_m, UL_m, UB_m, UR_m, DF_m, DL_m, DB_m, DR_m, | 6 | typedef uint8_t trans_t; |
| 10 | RU_i, RF_i, RD_i, RB_i, LU_i, LF_i, LD_i, LB_i, | ||
| 11 | RU_m, RF_m, RD_m, RB_m, LU_m, LF_m, LD_m, LB_m, | ||
| 12 | FU_i, FR_i, FD_i, FL_i, BU_i, BR_i, BD_i, BL_i, | ||
| 13 | FU_m, FR_m, FD_m, FL_m, BU_m, BR_m, BD_m, BL_m | ||
| 14 | } trans_t; | ||
| 15 | |||
| 16 | typedef struct { | ||
| 17 | uint8_t c[8]; | ||
| 18 | uint8_t e[12]; | ||
| 19 | } cube_t; | ||
| 20 | 7 | ||
| 21 | extern cube_t solvedcube; | 8 | extern cube_t solvedcube; |
| 22 | 9 | ||
| 23 | /* | 10 | /* For the textual representation of the cube, see utils/FORMAT.txt */ |
| 24 | The functions readcube() and writecube() use the following format. | ||
| 25 | |||
| 26 | Each edge is represented by two letters denoting the sides it belongs to | ||
| 27 | and one number denoting its orientation (0 oriented, 1 mis-oriented). | ||
| 28 | Similarly, each corner is represented by three letters and a number | ||
| 29 | (0 oriented, 1 twisted clockwise, 2 twisted counter-clockwise). | ||
| 30 | Edge orientation is relative to the F / B axis, corner orientation is | ||
| 31 | relative to the U / D axis. | ||
| 32 | |||
| 33 | The pieces are ordered such that the solved cube looks like this: | ||
| 34 | |||
| 35 | UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 | ||
| 36 | UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | ||
| 37 | |||
| 38 | Whitespace (including newlines) between pieces is ignored when reading | ||
| 39 | the cube, and a single whitespace character is added between pieces | ||
| 40 | when writing. | ||
| 41 | |||
| 42 | The cube after the moves R'U'F looks like this: | ||
| 43 | |||
| 44 | FL1 BR0 DB0 UR1 UF0 UB0 DL0 FR0 UL1 DF1 BL0 DR0 | ||
| 45 | UBL1 DBR1 UFR2 DFR2 DFL2 UBL2 UFL2 DBL0 | ||
| 46 | |||
| 47 | More formats might be supported in the future. | ||
| 48 | */ | ||
| 49 | |||
| 50 | cube_t readcube(char *); | 11 | cube_t readcube(char *); |
| 51 | void writecube(cube_t, char *); | 12 | void writecube(cube_t, char *); |
| 52 | 13 | ||
