Skip to content

A Rubik's cube solver written in C++ that uses the "Layer by Layer" method.

Notifications You must be signed in to change notification settings

mattiaVDM/Rubik-sCubeSolver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 

Repository files navigation

Rubik-sCubeSolverInC++

Immagine

The solver is based on a method called "layer by layer", it is the simplest method to solve a Rubik's Cube. It is divided into five phases described in detail in this video:

https://www.youtube.com/watch?v=1t1OL2zN0LQ

The program works using two main classes:

Cube class

The class contains 6 vectors that correspond to the 6 faces of the cube, each vector has 9 elements that correspond to the 9 cubes of the face. Each element is a char that indicates the color of the cube that is in that particular position. The class also contains the input and output operators, copy constructor and all the functions that allow you to make the moves (from the rotations of the entire cube to those of the individual faces). I implemented a basic GUI to visualize the cube in 2D.

Solver class

The solver class contains a vector of cube objects in which copies of the cubes are saved after the completion of each phase. It also contains the function that automatically resolves the cube.

The main is an interactive menu that allows you to:

  • Insert a cube manually or generate it automatically.

  • Simulate the resolution of x cubes to print the statistics (minimum and maximum moves used, average moves). The solver on my laptot solves up to 6000 cubes per second.

Immagine

  • Solve the cube generated manually: a list of the moves applicable to the cube is printed, I added this feature only for fun since the 2D printing of the cube does not allow easy resolution.

2

  • Solve the automatically generated cube: A copy of the cube is printed after each phase, once solved a txt file is generated which displays all the moves made starting from the original cube.

3

About

A Rubik's cube solver written in C++ that uses the "Layer by Layer" method.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages