GithubHelp home page GithubHelp logo

rubix-cube-solver's Introduction

Rubix-Cube-Solver

A primary rubik's cube solver in python using matplotlib and opencv.

Overview

This is a rubik's cube solver with beginner's algorithm from beginner's algorithm. It first reads the faces of a real rubik's cube using opencv and passes the states to the solver. Then it displays the move sequence in animation using matplotlib.

Dependencies

  • Python v3.6.5
  • numpy v1.14.3
  • Opencv-python v4.1.0.25
  • matplotlib v3.0.3

Run

To setup the solver, change directory to code and run

$ python solver.py

Capture the Rubik's Cube

capture cube

Then an opencv window using PC camera should appear. The letter on the left-top square indicates the face of the rubik's cube. Place the rubik's cube inside the squares as prompted and adjust the color shown in each piece by clicking inside the corresponding square. If the color shows n, then the color is not recognized and manual adjustment is required. If the colors are correct, click the Set square to confirm the colors. After that, the colors are insensible to live video changes. To make the colors sensible to live video, click Set again. The mapping of the colors and faces is shown in the following table.

Face Color
Front [F] Red [r]
Left [L] Green [g]
Back [B] Orange [o]
Right [R] Blue [b]
Up [U] White [w]
Down [D] Yellow [y]

View Initial State

When all six faces are recorded, a rubik's cube in the recorded face should be displayed in a matplotlib figure. Confirm that the state is correct and close the window.

confirm state

Solve

Then the animation of solving the rubik's cube should appear, and it stops when the cube is solved. The following figures show a screenshot of the solving animation and the final solved state.

solving final

Notes

  1. The current color recognition is crude and is significantly influenced by conditions of the environment, mainly lighting conditions.
  2. The beginner's algorithm is not an efficient algorithm for solving rubik's cube. This implementation takes 200 moves to solve a cube on average.
  3. A user interface might be constructed in future development.

rubix-cube-solver's People

Contributors

higgsboson-x avatar

Stargazers

 avatar Prahlad G Menon, PhD, PMP avatar

Watchers

Prahlad G Menon, PhD, PMP avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.