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

Generated with cgit - Back to sebastiano.tronto.net