Rubik’s Cube Solver

 Status : Completed

Tags: opencv python tkinter Kociemba



AIM

To develop a code that provides a sequence of moves to solve or make a unique pattern in a Rubik’s cube.


COMPONENTS AND TECHNOLOGIES USED

  • python

  • opencv

  • tkinter

  • Kociemba


OVERVIEW

Introduction

  • Rubik's cube is a 3D combination puzzle toy having six faces.

  • Each face of the cube can be rotated in a clockwise or counterclockwise direction so that it can be shuffled to a different position.

  • Solving a puzzle means arranging a cube such that each of the 9 blocks in the same face has identical color. 

 

Components -

  • The Rubik's Cube Solver project requires a computer with at least 4GB of RAM, Python 3.7 or higher, OpenCV 4.0 or higher, and NumPy, Tkinter, and Kociemba libraries installed.
  • A webcam or a camera with at least 5MP resolution is required for capturing Rubik's Cube faces.


 

Working -

  1. The initial position of the Rubik's cube is detected using a webcam and shown in an interactive GUI.

  2.  If the position of the shown cube can't be achieved by shuffling a solved cube then color detection has to be done again to the accuracy.

  1. After storing and showing the initial phase of the cube we have to press the specific key to whichever pattern we want to be made at the end, as shown in the window.


 

  1.  Then it shows the steps we needed to do to proceed toward the solution and it also shows the current position of the cube through the GUI after each step. 

 

  1. When we follow certain steps which are shown then the desired state of the cube is obtained.For example you have selected checkerboard in this case. 

 




 

Methodology -

  1. The Rubik's Cube faces are detected using the OpenCV library, which applies color segmentation and edge detection techniques to identify the colors of each face.
  2. The color data is stored in NumPy arrays, where each element corresponds to a particular cubelet on the Rubik's Cube.
  3. The GUI displays Rubik's Cube, solution steps, and pattern generation options.
  4. The user can interact with the solver using certain keys which are mentioned in the GUI.
  5. The GUI is implemented using Python and Tkinter, and it updates in real time as the solver progresses.
  6. The Rubik's Cube is solved using the Kociemba algorithm, which is a two-phase algorithm that generates an optimal solution for any given Rubik's Cube state.
  7. The solver applies the Kociemba algorithm to the Rubik's Cube data stored in NumPy arrays, and it updates the GUI to show the progress of the solution.
  8. It provides the option to generate different patterns on the cube, such as checkerboards, stripes, and dots.
  9. The user can select a pattern from a dropdown menu, and the solver applies the corresponding algorithm to the Rubik's Cube data stored in NumPy arrays.
  10. The generated pattern is displayed in the GUI in real-time.

Source Code -

https://github.com/roboclub-mnnit/Rubik_cube_solver-2022-23-Project

Video link -

https://www.youtube.com/watch?v=FHDl_1TUIMY

Resources -

Python Resource -

https://www.youtube.com/watch?v=YYXdXT2l-Gg&list=PL-osiE80TeTt2d9bfVyTiXJA-UTHn6WwU

OpenCv Resource -

https://www.youtube.com/playlist?list=PLS1QulWo1RIa7D1O6skqDQ-JZ1GGHKK-K

https://youtu.be/oXlwWbU8l2o

NumPy Resource -

https://www.youtube.com/watch?v=ZaKzw9tULeM&list=PLjVLYmrlmjGfgBKkIFBkMNGG7qyRfo00W

Kociemba Resource

https://pypi.org/project/kociemba/

 

Real-life applications -

  1. Learning and teaching: The Rubik's Cube is a popular puzzle that requires strategy and logical thinking to solve. 
  2. Entertainment: Solving a Rubik's Cube can be a fun and challenging activity for many people. Software that provides instructions can make the process easier and more enjoyable for those who want to solve the cube as a leisure activity.
  3. Competitive events: Rubik's Cube competitions are held worldwide, where participants try to solve the cube as quickly as possible. Software that shows the optimal solution can be used as a training tool for participants to improve their speed and accuracy.
  4. Brain training: It can improve cognitive abilities such as memory, spatial reasoning, and problem-solving skills.




 

The problem faced -

  1. Color Detection: One of the main challenges in our project was detecting the colors of each block on the Rubik's Cube. We had to set the HSV values for detection according to the light of the surrounding, which required a lot of experimentation and fine-tuning to ensure accurate detection.
  2. GUI Development: Creating a GUI that could display the cube, show the detected colors, and provide the sequence of steps to solve the cube was a significant challenge. We had to make sure that the GUI was user-friendly and easy to understand while also being responsive to the solutions provided by the algorithm.
  3. Integration: Finally, integrating all the different components of our project, including the color detection, algorithm, GUI, and 3D representation, required a lot of coordination and troubleshooting. We had to make sure that all the pieces worked together seamlessly to provide a complete and functional Rubik's Cube solver.

 

CONTRIBUTORS -

Name

Branch

Reg. no.

Vinay Singh

Computer Science and Engineering

20214071

Pavan Kumar

Electronics and Communication Engineering

20215043

 

MENTORS -

  1.   Anurag Gupta  (E.C.E., Final year)
  2.  Shreya Gupta  ( I.T., Pre-Final Year)