diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-11-11 21:37:34 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-11-11 21:37:34 +0100 |
| commit | 3568412f8f230774d0d11d7ed1c897424f95d3ef (patch) | |
| tree | 77223792d8c925a9b1fc32b3f4341e943b5f8209 /old/2021-02-28-transformcube-works/src/cube.h | |
| parent | 67e1b5e6e6a2c917a2fe58a37a1382c982b1e5c5 (diff) | |
| download | nissy-3568412f8f230774d0d11d7ed1c897424f95d3ef.tar.gz nissy-3568412f8f230774d0d11d7ed1c897424f95d3ef.zip | |
Rewritten from scratch. Welocme nissy 2.0!
Diffstat (limited to '')
| -rw-r--r-- | old/2021-02-28-transformcube-works/src/cube.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/old/2021-02-28-transformcube-works/src/cube.h b/old/2021-02-28-transformcube-works/src/cube.h new file mode 100644 index 0000000..3229eae --- /dev/null +++ b/old/2021-02-28-transformcube-works/src/cube.h | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | #ifndef CUBE_H | ||
| 2 | #define CUBE_H | ||
| 3 | |||
| 4 | #include <stdio.h> | ||
| 5 | #include <stdbool.h> | ||
| 6 | #include <stdint.h> | ||
| 7 | #include "utils.h" | ||
| 8 | |||
| 9 | typedef enum {U_center,D_center,R_center,L_center,F_center,B_center} Center; | ||
| 10 | typedef enum { UF, UL, UB, UR, DF, DL, DB, DR, FR, FL, BL, BR } Edge; | ||
| 11 | typedef enum { UFR, UFL, UBL, UBR, DFR, DFL, DBL, DBR } Corner; | ||
| 12 | |||
| 13 | typedef struct { | ||
| 14 | uint16_t eofb, eorl, eoud, coud, cofb, corl, | ||
| 15 | epose, eposs, eposm, cp, cpos; | ||
| 16 | } Cube; | ||
| 17 | |||
| 18 | typedef struct { | ||
| 19 | bool epose, eposs, eposm, eofb, eorl, eoud, cp, coud, cofb, corl, cpos; | ||
| 20 | } PieceFilter; | ||
| 21 | |||
| 22 | typedef struct { | ||
| 23 | int *ep, *eofb, *eorl, *eoud, *cp, *coud, *corl, *cofb, *cpos; | ||
| 24 | } CubeArray; | ||
| 25 | |||
| 26 | extern PieceFilter pf_all, pf_cpos, pf_ep, pf_cp, | ||
| 27 | pf_e, pf_s, pf_m, pf_eo, pf_co; | ||
| 28 | |||
| 29 | void cube_to_arrays(Cube cube, CubeArray *arr, PieceFilter f); | ||
| 30 | Cube arrays_to_cube(CubeArray arr, PieceFilter f); | ||
| 31 | |||
| 32 | Center center_at(Cube cube, Center c); | ||
| 33 | Edge edge_at(Cube cube, Edge e); | ||
| 34 | Corner corner_at(Cube cube, Corner c); | ||
| 35 | /* Aggiungi funzioni per "queries" sul cubo: se pezzo è orientato rispetto ad | ||
| 36 | un certo asse, se il pezzo è risolto... */ | ||
| 37 | /* Would be nice: a funciton block_solved(Cube c, Block b), where Block is | ||
| 38 | something like struct {bool centers[6], edges[12], corners[8]} | ||
| 39 | (The advantage over checking pieces one by one is that I can convert | ||
| 40 | to cubearray only once and for all) */ | ||
| 41 | /* Altro TODO, ma forse non ne vale la pena: pre-calcolare tutti i possibili | ||
| 42 | valori per questi, e salvare i risultati in array (facile per cp e cpos, | ||
| 43 | mentre per ep bisogna anche cercare quale tra epose, eposs e eposm contiene | ||
| 44 | il valore giusto) */ | ||
| 45 | |||
| 46 | bool equal(Cube c1, Cube c2); | ||
| 47 | bool is_solvable(Cube cube); | ||
| 48 | bool is_solved(Cube cube); | ||
| 49 | void print_cube(Cube cube); | ||
| 50 | Cube admissible_ep(Cube cube, PieceFilter f); /* Returns admissible ep */ | ||
| 51 | Cube inverse_cube(Cube cube); | ||
| 52 | Cube compose(Cube c2, Cube c1); /* Use c2 as an alg on c1 */ | ||
| 53 | Cube move_via_arrays(CubeArray arr, Cube c, PieceFilter pf); | ||
| 54 | |||
| 55 | #endif | ||
