nissy-fmc

A Rubik's cube FMC assistant
git clone https://git.tronto.net/nissy-fmc
Download | Log | Files | Refs | README | LICENSE

cube.h (1963B)


      1 #define NMOVES_ALL  55
      2 #define NMOVES_HTM  19
      3 #define NTRANS      48
      4 #define MAX_ALG_LEN 22
      5 #define MIN(a,b)    (((a) < (b)) ? (a) : (b))
      6 #define MAX(a,b)    (((a) > (b)) ? (a) : (b))
      7 
      8 typedef enum edge { UF, UL, UB, UR, DF, DL, DB, DR, FR, FL, BL, BR } Edge;
      9 typedef enum { UFR, UFL, UBL, UBR, DFR, DFL, DBL, DBR } Corner;
     10 typedef enum {
     11         NULLMOVE,
     12         U, U2, U3, D, D2, D3,
     13         R, R2, R3, L, L2, L3,
     14         F, F2, F3, B, B2, B3,
     15         Uw, Uw2, Uw3, Dw, Dw2, Dw3,
     16         Rw, Rw2, Rw3, Lw, Lw2, Lw3,
     17         Fw, Fw2, Fw3, Bw, Bw2, Bw3,
     18         M, M2, M3, S, S2, S3, E, E2, E3,
     19         x, x2, x3, y, y2, y3, z, z2, z3,
     20 } Move;
     21 typedef enum {
     22         uf, ur, ub, ul,
     23         df, dr, db, dl,
     24         rf, rd, rb, ru,
     25         lf, ld, lb, lu,
     26         fu, fr, fd, fl,
     27         bu, br, bd, bl,
     28         uf_mirror, ur_mirror, ub_mirror, ul_mirror,
     29         df_mirror, dr_mirror, db_mirror, dl_mirror,
     30         rf_mirror, rd_mirror, rb_mirror, ru_mirror,
     31         lf_mirror, ld_mirror, lb_mirror, lu_mirror,
     32         fu_mirror, fr_mirror, fd_mirror, fl_mirror,
     33         bu_mirror, br_mirror, bd_mirror, bl_mirror,
     34 } Trans;
     35 
     36 typedef struct { int ep[12]; int eo[12]; int cp[8]; int co[8]; } Cube;
     37 typedef struct { Move move[MAX_ALG_LEN]; bool inv[MAX_ALG_LEN]; int len; } Alg;
     38 typedef struct { int n; Trans t[NTRANS]; } TransGroup;
     39 
     40 extern TransGroup tgrp_udfix;
     41 
     42 void compose(Cube *, Cube *);
     43 void copy_cube(Cube *, Cube *);
     44 void invert_cube(Cube *);
     45 bool is_solved(Cube *);
     46 void make_solved(Cube *);
     47 
     48 Move base_move(Move);
     49 bool commute(Move, Move);
     50 Move inverse_move(Move);
     51 
     52 void copy_alg(Alg *, Alg *);
     53 void append_move(Alg *, Move, bool);
     54 void apply_move(Move, Cube *);
     55 void apply_alg(Alg *, Cube *);
     56 bool apply_scramble(char *, Cube *);
     57 int alg_string(Alg *, char *);
     58 
     59 void apply_trans(Trans, Cube *);
     60 Trans inverse_trans(Trans);
     61 void transform_alg(Trans, Alg *);
     62 Move transform_move(Trans, Move);
     63 Trans transform_trans(Trans, Trans);
     64 
     65 void init_cube(void);