Skip to content

Rubik's Cube Solver. An optimized implementation of Kociemba's two-phase algorithm. C++

License

Notifications You must be signed in to change notification settings

lilborgo/min2phaseCXX

 
 

Repository files navigation

min2phase C++

Usage

First, you need to initialize the algorithm using:

    min2phase::init();

After that, you can write the initialization into a file, so the next time the algorithm initialization will be faster. Using:

    min2phase::writeFile("name.m2pc");

Now, the next time you can load the coordinates from the file:

    min2phase::loadFile("name.m2pc");

If you try to load a file that does not exist, min2phase::init() will be executed automatically.

After the initialization, you can execute the solver. This is an example of how it works. See min2phase.h for the arguments explanation of the solver.

#include <iostream>
#include <min2phase/min2phase.h>
#include <min2phase/tools.h>

int main(int argc, char *argv[]){

    min2phase::init();//precomputed coordinates

    std::cout << min2phase::solve(min2phase::tools::randomCube(), 21, 1000000, 0, min2phase::APPEND_LENGTH | min2phase::USE_SEPARATOR, nullptr);
    return 0;
}

See tools.h for some useful function for the solver. You can also read the coordinates from a file, see min2phase.h. Reading from a file the coordinates will increase the speed of the algorithm.

Compiling

cmake CMakeLists.txt
make
g++ -I include/ yourporgram.cpp -L. -lmin2phase -o yourporgram -Wl,-rpath,.

License

This software is distributed on GPLv3.0, more information available in LICENSE.md.