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-05-26-before-restyle/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-05-26-before-restyle/cube.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/old/2021-05-26-before-restyle/cube.h b/old/2021-05-26-before-restyle/cube.h new file mode 100644 index 0000000..0c9fc7b --- /dev/null +++ b/old/2021-05-26-before-restyle/cube.h | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | #ifndef CUBE_H | ||
| 2 | #define CUBE_H | ||
| 3 | |||
| 4 | #include <stdio.h> | ||
| 5 | #include <stdbool.h> | ||
| 6 | #include <stdint.h> | ||
| 7 | #include <string.h> | ||
| 8 | #include "utils.h" | ||
| 9 | |||
| 10 | typedef enum {U_center,D_center,R_center,L_center,F_center,B_center} Center; | ||
| 11 | typedef enum { UF, UL, UB, UR, DF, DL, DB, DR, FR, FL, BL, BR } Edge; | ||
| 12 | typedef enum { UFR, UFL, UBL, UBR, DFR, DFL, DBL, DBR } Corner; | ||
| 13 | |||
| 14 | typedef struct { | ||
| 15 | uint16_t eofb, eorl, eoud, coud, cofb, corl, | ||
| 16 | epose, eposs, eposm, cp, cpos; | ||
| 17 | } Cube; | ||
| 18 | |||
| 19 | typedef struct { | ||
| 20 | bool edge[12], corner[8], center[6]; | ||
| 21 | } Block; | ||
| 22 | |||
| 23 | typedef struct { | ||
| 24 | bool epose, eposs, eposm, eofb, eorl, eoud, cp, coud, cofb, corl, cpos; | ||
| 25 | } PieceFilter; | ||
| 26 | |||
| 27 | typedef struct { | ||
| 28 | int *ep, *eofb, *eorl, *eoud, *cp, *coud, *corl, *cofb, *cpos; | ||
| 29 | } CubeArray; | ||
| 30 | |||
| 31 | extern PieceFilter pf_all, pf_cpos, pf_ep, pf_cp, | ||
| 32 | pf_e, pf_s, pf_m, pf_eo, pf_co; | ||
| 33 | |||
| 34 | void cube_to_arrays(Cube cube, CubeArray *arr, PieceFilter f); | ||
| 35 | Cube arrays_to_cube(CubeArray arr, PieceFilter f); | ||
| 36 | |||
| 37 | /* piece can be edge or corner and orientation is any of the following: | ||
| 38 | "eofb", "eorl", "eoud", "coud", "corl", "cofb" | ||
| 39 | Return either 0 (oriented) or 1 for edges and 0, 1 or 2 for corners */ | ||
| 40 | int piece_orientation(Cube cube, int piece, char *orientation); | ||
| 41 | Center center_at(Cube cube, Center c); | ||
| 42 | Edge edge_at(Cube cube, Edge e); | ||
| 43 | Corner corner_at(Cube cube, Corner c); | ||
| 44 | bool block_solved(Cube cube, Block); | ||
| 45 | /* Aggiungi funzioni per "queries" sul cubo: se pezzo è orientato rispetto ad | ||
| 46 | un certo asse, se il pezzo è risolto... */ | ||
| 47 | /* Would be nice: a funciton block_solved(Cube c, Block b), where Block is | ||
| 48 | something like struct {bool centers[6], edges[12], corners[8]} | ||
| 49 | (The advantage over checking pieces one by one is that I can convert | ||
| 50 | to cubearray only once and for all) */ | ||
| 51 | /* Altro TODO, ma forse non ne vale la pena: pre-calcolare tutti i possibili | ||
| 52 | valori per questi, e salvare i risultati in array (facile per cp e cpos, | ||
| 53 | mentre per ep bisogna anche cercare quale tra epose, eposs e eposm contiene | ||
| 54 | il valore giusto) */ | ||
| 55 | |||
| 56 | bool equal(Cube c1, Cube c2); | ||
| 57 | bool is_solved(Cube cube); | ||
| 58 | void print_cube(Cube cube); | ||
| 59 | Cube admissible_ep(Cube cube, PieceFilter f); /* Returns admissible ep */ | ||
| 60 | Cube inverse_cube(Cube cube); | ||
| 61 | Cube compose(Cube c2, Cube c1); /* Use c2 as an alg on c1 */ | ||
| 62 | Cube compose_filtered(Cube c2, Cube c1, PieceFilter f); | ||
| 63 | Cube move_via_arrays(CubeArray arr, Cube c, PieceFilter pf); | ||
| 64 | |||
| 65 | #endif | ||
