cubecore

A library of core functions for working with 3x3x3 Rubik's cubes
git clone https://git.tronto.net/cubecore
Download | Log | Files | Refs | README | LICENSE

CubeCore

A simple set of basic routines for working with a 3x3x3 Rubik’s Cube.

How to use CubeCore

See the example in example/ for details.

  1. Requirements: a C99 compiler (e.g. GCC)

  2. Compile CubeCore

$ make
$ make test # optional
  1. Include in your C project
#include "cube.h"

or in your C++ project

extern "C" {
#include "cube.h"
}
  1. Compile including the cube.o file
$ gcc mycode.c cube.o

The cube

Each piece is represented by an (unsigned) 8-bit integer. The 4 least-significant bits determine which piece it is, the other 4 determine the orientation.

Edges are numbered as follows (see also cube.c): UF=0 UB=1 DB=2 DF=3 UR=4 UL=5 DL=6 DR=7 FR=8 FL=9 BL=10 BR=11

Corners are numbered as follows: UFR=0 UBL=1 DFL=2 DBR=3 UFL=4 UBR=5 DFR=6 DBL=7

The orientation of the edges is with respect to F/B, the orientation of corners is with respect to U/D.

The permutation of the center pieces is not stored. This means that the cube is assumed to be in a fixed orientation.

I/O format

Reading and writing is not done directly via stdin / stdout, but via an array of char (called buf in the prototypes below).

Multiple representations of the cube as text are supported: