Cerb is a C++ implementation of a simple algorithm to solve a 3x3x3 Rubik's Cube.
In contrast to the conventional approaches like the Beginner's method, Roux method, ZZ and Fridrich method which are targeted towards minimizing the total number of moves required to solve the cube, Cerb solves the cube piece by piece. Since there are eight corner pieces and twelve edge pieces in a 3x3x3 Rubik's Cube, it would take a little more than twenty iterations to get all of them to their respective positions. Further, the separation of orientation and permutation of corner peices adds to the verbosity of the solution. The average number of quarter moves required for a full solve is roughly about 500-600, which corresponds to atleast two-three minutes. So we're certainly not making the Guinness book, least of all in the minimum-moves category!
The program takes in the scrambled cube configuration in two different text files - one for the corner pieces and the other one for edge pieces. Follow the below lettering scheme to format your cube configuration files. If the cube is traced using the lettering schemes given below from position a
to position x
, the edge and corner config files will look like this
colAt(a) colAt(b) colAt(c) ... colAt(x)
where colAt(#)
represents the the color at position #
.
Lettering Scheme for Corners | Lettering Scheme for Edges |
---|---|
In the main.cpp
, invoke the Cube::solve(EDGE_CONFIG_FILE_PATH, CORNER_CONFIG_FILE_PATH)
function and compile the project into a neat little executable.
The entire project is divided into three class files, so compiling the program ought to be simple enough. A Makefile is provided in the root directory of the project which simplies the compilation and linking process.
If make
is not installed, then the project can be manually compiled with the g++
compiler
g++ -c main.cpp headers/Cube.cpp headers/Edges.cpp headers/Corners.cpp
This compiles the source files into object files which can then be linked into an executable cerb
g++ main.o Cube.o Edges.o Corners.o -o cerb
Finally, to generate a solution to the cube configuration in the text files at EDGE_CONFIG_FILE_PATH
and CORNER_CONFIG_FILE_PATH
, just execute the assembler output file ./cerb
These tests were performed using the cerberus simulator.