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 /src/cube.h | |
| parent | 287f6c4067a206fb1c18eb779ef8463f06c0e5e1 (diff) | |
| download | nissy-core-2a8d66906dde19ffb7315fb3f60a396a71612037.tar.gz nissy-core-2a8d66906dde19ffb7315fb3f60a396a71612037.zip | |
Small cleanup
Diffstat (limited to 'src/cube.h')
| -rw-r--r-- | src/cube.h | 81 |
1 files changed, 41 insertions, 40 deletions
| @@ -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); | ||
