A comprehensive project for solving NxN Rubik's Cubes using various algorithmic techniques. This application provides a 3D visualization of the cube, implements multiple solving algorithms, and includes a benchmarking system to compare their performance.
- Interactive 3D Visualization: Manipulate and view the Rubik's Cube from any angle using Three.js
- Multiple Solving Algorithms:
- Brute Force (for 2x2 cubes only)
- Layer-by-Layer (LBL) Method
- Kociemba's Two-Phase Algorithm
- Thistlethwaite's Algorithm
- Neural Network Approach (simulated)
- Benchmarking System: Compare the performance of different algorithms in terms of time, moves, and success rate
- Step-by-Step Solution Playback: View the solution steps and play them back at different speeds
- Support for Different Cube Sizes: 2x2, 3x3, 4x4, and 5x5 cubes
- JavaScript: Core programming language
- Three.js: 3D visualization library
- Chart.js: Data visualization for benchmarking results
- Webpack: Module bundling
- Babel: JavaScript transpiling
- Node.js (v14 or higher)
- npm (v6 or higher)
-
Clone the repository:
git clone https://github.com/yourusername/rubiks-cube-solver.git cd rubiks-cube-solver
-
Install dependencies:
npm install
-
Start the development server:
npm start
-
Open your browser and navigate to
http://localhost:8080
To build the application for production:
npm run build
The built files will be in the dist
directory.
rubiks-cube-solver/
├── src/
│ ├── components/
│ │ ├── CubeView3d/ # 3D cube visualization
│ │ ├── CubeView2d/ # 2D net view of cube
│ │ ├── SettingsPanel/ # Cube controls and settings
│ │ ├── SolverPanel/ # Algorithm selection
│ │ ├── StatsPanel/ # Performance metrics display
│ │ ├── LogsPanel/ # Move history and notation
│ │ ├── Header/ # Application header
│ │ └── ui/ # Reusable UI components
│ │ ├── Button/
│ │ ├── PanelLabel/
│ │ ├── ResizeHandle/
│ │ └── MoveTable/
│ ├── core/
│ │ ├── cube.ts # Cube state and logic
│ │ ├── IDDFS.ts # IDDFS solver implementation
│ │ ├── IDAStar.ts # IDA* solver implementation
│ │ ├── CFOP.ts # CFOP solver implementation
│ │ └── Worker.ts # Web Worker for background solving
│ ├── types/ # TypeScript type definitions
│ ├── App.tsx # Main application component
│ └── App.module.css # Global styles
├── public/ # Static assets
├── package.json # Project dependencies
├── tsconfig.json # TypeScript configuration
└── README.md
1.Control Panel (Left):
-
Cube size selection
-
Scramble functionality
-
Manual move controls
-
Algorithm selection
-
2.Visualization Panel (Center):
-
3D cube renderer with orbit controls
-
2D net view of the cube
-
Resizable panels for optimal viewing
3.Information Panel (Right):
-
Algorithm statistics (move count, time taken)
-
Move history log
-
Solution steps
When solving:
- Select an algorithm from the Solver panel
- Watch the step-by-step solution
- View performance metrics in real-time
- Replay or reverse any part of the solution
The brute force approach tries all possible move sequences until a solution is found. Due to the enormous search space (approximately 43 quintillion positions for a 3x3 cube), this approach is only feasible for 2x2 cubes or for finding optimal solutions for specific cases.
The Layer-by-Layer method solves the cube one layer at a time, typically starting with the bottom layer, then the middle layer, and finally the top layer. This method is intuitive and commonly used by human solvers.
Kociemba's algorithm divides the solution into two phases:
- Reduce the cube to a subgroup where only specific moves are needed
- Solve within that subgroup
This algorithm can find near-optimal solutions for 3x3 cubes.
Thistlethwaite's algorithm breaks down the solution into four stages, each reducing the cube to a smaller subgroup:
- G0 -> G1: Orient all edges
- G1 -> G2: Place M-slice edges in M-slice, orient all corners
- G2 -> G3: Place E-slice edges in E-slice, U corners in U face, D corners in D face
- G3 -> G4: Solve the cube
This approach significantly reduces the search space and can find solutions with a reasonable number of moves.
This approach uses machine learning techniques to learn solving strategies. While still experimental, neural networks show promise in developing efficient solving strategies.
The algorithms used to solve Rubik's Cubes have applications beyond the puzzle itself:
- AI and Search Algorithms: The techniques used to navigate the vast state space of a Rubik's Cube are applicable to other complex search problems.
- Robotics: The manipulation sequences and pattern recognition used in cube solving inform robotic movement planning and object manipulation.
- Logistics and Optimization: The group theory and state-space reduction techniques have applications in scheduling, routing, and other optimization problems.
- Parallel Computing: Distributing the search for Rubik's Cube solutions demonstrates principles of parallel algorithm design that apply to other computationally intensive tasks.
This project is licensed under the MIT License - see the LICENSE file for details.
- Ernő Rubik for inventing the Rubik's Cube
- Herbert Kociemba for the Two-Phase Algorithm
- Morwen Thistlethwaite for Thistlethwaite's Algorithm
- The Three.js team for the amazing 3D library