diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-09-08 18:28:30 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-09-08 18:28:30 +0200 |
| commit | 4d08bf731a099de2d174c73489636e1a12935aee (patch) | |
| tree | c751858cb6e33172c97a1123432f7c59d7d94d7e /src/cube.h | |
| parent | c5dfc897160bc9bbc6a91c77b5d58d421fd1cfe1 (diff) | |
| download | nissy-core-4d08bf731a099de2d174c73489636e1a12935aee.tar.gz nissy-core-4d08bf731a099de2d174c73489636e1a12935aee.zip | |
New implementation, moved old to experiments/
Diffstat (limited to '')
| -rw-r--r-- | src/cube.h | 42 |
1 files changed, 34 insertions, 8 deletions
| @@ -3,25 +3,51 @@ typedef enum { | |||
| 3 | R, R2, R3, L, L2, L3, | 3 | R, R2, R3, L, L2, L3, |
| 4 | F, F2, F3, B, B2, B3 | 4 | F, F2, F3, B, B2, B3 |
| 5 | } move_t; | 5 | } move_t; |
| 6 | |||
| 6 | typedef struct { | 7 | typedef struct { |
| 7 | uint64_t e; | 8 | uint8_t c[8]; |
| 8 | uint64_t c; | 9 | uint8_t e[12]; |
| 9 | } cube_t; | 10 | } cube_t; |
| 10 | 11 | ||
| 11 | extern cube_t solvedcube; | 12 | extern cube_t solvedcube; |
| 12 | extern cube_t errorcube; | ||
| 13 | 13 | ||
| 14 | bool isconsistent(cube_t); | 14 | /* |
| 15 | bool issolved(cube_t); | 15 | The functions readcube() and writecube() use the following format. |
| 16 | |||
| 17 | Each edge is represented by two letters denoting the sides it belongs to | ||
| 18 | and one number denoting its orientation (0 oriented, 1 mis-oriented). | ||
| 19 | Similarly, each corner is represented by three letters and a number | ||
| 20 | (0 oriented, 1 twisted clockwise, 2 twisted counter-clockwise). | ||
| 21 | Edge orientation is relative to the F / B axis, corner orientation is | ||
| 22 | relative to the U / D axis. | ||
| 23 | |||
| 24 | The pieces are ordered such that the solved cube looks like this: | ||
| 25 | |||
| 26 | UF0 UB0 DB0 DF0 UR0 UL0 DL0 DR0 FR0 FL0 BL0 BR0 | ||
| 27 | UFR0 UBL0 DFL0 DBR0 UFL0 UBR0 DFR0 DBL0 | ||
| 28 | |||
| 29 | Whitespace (including newlines) between pieces is ignored when reading | ||
| 30 | the cube, and a single whitespace character is added between pieces | ||
| 31 | when writing. | ||
| 32 | |||
| 33 | The cube after the moves R'U'F looks like this: | ||
| 34 | |||
| 35 | FL1 BR0 DB0 UR1 UF0 UB0 DL0 FR0 UL1 DF1 BL0 DR0 | ||
| 36 | UBL1 DBR1 UFR2 DFR2 DFL2 UBL2 UFL2 DBL0 | ||
| 37 | |||
| 38 | More formats might be supported in the future. | ||
| 39 | */ | ||
| 16 | 40 | ||
| 17 | cube_t readcube(char *); | 41 | cube_t readcube(char *); |
| 18 | void writecube(cube_t, char *); | 42 | void writecube(cube_t, char *); |
| 19 | 43 | ||
| 44 | bool isconsistent(cube_t); | ||
| 45 | bool equal(cube_t, cube_t); | ||
| 46 | bool issolved(cube_t); | ||
| 47 | bool iserror(cube_t); | ||
| 48 | |||
| 20 | int readmoves(char *, move_t *); | 49 | int readmoves(char *, move_t *); |
| 21 | void writemoves(move_t *, int, char *); | 50 | void writemoves(move_t *, int, char *); |
| 22 | 51 | ||
| 23 | cube_t move(cube_t, move_t); | 52 | cube_t move(cube_t, move_t); |
| 24 | |||
| 25 | /* | ||
| 26 | cube_t inverse(cube_t); | 53 | cube_t inverse(cube_t); |
| 27 | */ | ||
