Skip to content
Akshath Raghav edited this page Jul 5, 2021 · 19 revisions

cubot

🔠 Contents

What is Cubot?

There are many Rubik's Cube-related graphic projects and solvers which implement various algorithms for solving the cube.
But programmers might not want something just for visualizing the cube, they might want a data-structure type of solution for them to use in their own projects without having to make their own files. Perhaps they want to only make a 3D cube with the help of a library. Cubot is a library meant for this very purpose.

🤔 Why would I want it?

With Cubot, you can

  • Virtually construct a Cube ( 2x2/3x3 ),
  • Quickly execute moves and perform algorithms seamlessly,
  • Manipulate the Cube using simple java,
  • Get the solution for the cube
  • Use a cube in your own projects
  • and so much more, with the help of the methods it provides

Now speed is relative, as we all know. But Cubot can scramble the Cube, print, solve the Cube, print, bring the cube back into the scrambled state and print again, in less than a second on average.

long startTime = System.nanoTime();

Cubot cube = new Cubot();
// "U2 F2 D2 U R' D2 B2 U L2 B' D' U2 F L F U' B' R' F' U F' U B L' D2 B R' B F2 R'" --> Offical WCA Scramble

cube.stringAlg("U2 F2 D2 U R' D2 B2 U L2 B' D' U2 F L F U' B' R' F' U F' U B L' D2 B R' B F2 R'") ;
// scrambles


Cubot cube2 = new Cubot(cube.cubeToArr()) ;
System.out.println(cube);
// prints output

String s  = cube.solve() ;
// solves

System.out.println(cube);
// prints ouput

System.out.println();

cube.reverseAlg(s, true) ;
// rescrambles with the solve again

System.out.println(cube);
// prints output

System.out.println("Re-scrambled ? = " + ((Cube3) cube.getCube()).solved((Cube3) cube2.getCube())) ;
// checks if the rescrambled cube is the same as the first scramble

long endTime = System.nanoTime();
long time = (endTime - startTime) ;
System.out.println("-----------------------------");
System.out.println("Execution time in milliseconds: " + time / 1000000);

Example Example

🧠 How it works

Cubot is the top-most class in the hierarchy of the library, and it has-a Cubot3 and Cubot2

The cube object is made in the Cube class and the non-cubearray-changing methods also reside there.
For the moves, it makes use of different algorithms and re-uses simpler moves for bigger slice moves. All this happens in the Moves class.
The Checker class handles the solving of the cube and has helper methods.

Clone this wiki locally