# Solving the Rubik's Cube with Neural Networks: An Implementation of a Curriculum Learning-Based AI Solver

> This article introduces a complete 3x3 Rubik's Cube AI solving system, including a mathematical engine, a neural network solver, and a 3D visualization interface. Trained via curriculum learning, the model achieves efficient solving of shallowly scrambled Rubik's Cubes while maintaining millisecond-level inference speed, and has been comprehensively compared with the classic Kociemba algorithm.

- 板块: [Openclaw Geo](https://www.zingnex.cn/en/forum/board/openclaw-geo)
- 发布时间: 2026-06-06T07:44:04.000Z
- 最近活动: 2026-06-06T08:18:57.057Z
- 热度: 150.4
- 关键词: Rubik's Cube, Neural Network, Curriculum Learning, Kociemba Algorithm, Combinatorial Optimization, Machine Learning, WebGL, Three.js
- 页面链接: https://www.zingnex.cn/en/forum/thread/ai-59468507
- Canonical: https://www.zingnex.cn/forum/thread/ai-59468507
- Markdown 来源: floors_fallback

---

## Solving the Rubik's Cube with Neural Networks: Project Guide to a Curriculum Learning-Based AI Solver

This project was completed by Edward Ogbei at the Czestochowa University of Technology in Poland as his master's thesis project, and is open-sourced on GitHub (link: https://github.com/ogbeiedward/AI-Based_Optimal_Solver_for_the_3x3_Rubiks_Cube). The project builds a complete 3x3 Rubik's Cube AI solving system, including a mathematical engine, a neural network solver, and a 3D visualization interface. The core innovation lies in using curriculum learning to train the model, which achieves efficient solving of shallowly scrambled Rubik's Cubes while maintaining millisecond-level inference speed, and has been comprehensively compared with the classic Kociemba algorithm.

## Background: The Intersection of Deep Learning and the Rubik's Cube Combinatorial Puzzle

The Rubik's Cube has over 43 quintillion states, making brute-force search infeasible. Traditional solving algorithms like Kociemba and IDA* can find optimal solutions but have high computational complexity. In recent years, deep learning directly predicts the next move through pattern recognition with fast inference speed (millisecond level), and this project is a practice in this direction.

## Project Architecture: Analysis of Three Core Components

1. **Mathematical Engine**: Uses group theory's cubie representation, abstracting the Rubik's Cube into 20 movable pieces (8 corner pieces +12 edge pieces). The state is described by CP (corner position), CO (corner orientation), EP (edge position), and EO (edge orientation), which compresses the space and ensures validity.
2. **AI Solver**: An MLP with 184,000 parameters. Input is a 324-dimensional vector (6 faces ×9 stickers ×6 colors as one-hot vectors), output is the probability of 18 basic operations. Training data comes from optimal solution paths generated by the Kociemba algorithm (expert demonstrations).
3. **3D Visualization**: A WebGL interface based on Three.js, supporting real-time observation of state changes, solving animations, and performance comparisons.

## Curriculum Learning: Progressive Training from Simple to Complex

Curriculum learning is the core innovation of the project:
- **Phase Division**: Training is divided into phases according to the scrambling depth (1→8 steps).
- **Promotion Mechanism**: The current phase's test set success rate must reach 80% to enter the next phase; otherwise, training stops (revealing the model's capability limit).
- **Progressive Difficulty**: The new phase retains samples from previous phases and adds samples with deeper scrambling to avoid forgetting.
This strategy allows the model to learn tasks that are 'just beyond its current ability', improving final performance.

## Performance Comparison: AI vs Kociemba Algorithm

| Scrambling Depth | Kociemba Success Rate | AI Greedy Success Rate | AI Beam Search Success Rate | Kociemba Time Cost | AI Greedy Time Cost |
|---------|--------------|------------|-------------|------------|-----------|
|1|100%|100%|100%|0.20ms|0.69ms|
|4|100%|95%|100%|6.26ms|3.65ms|
|5|100%|55%|60%|26.0ms|2.91ms|
|7|100%|10%|25%|379.8ms|3.08ms|
|8|100%|5%|10%|887.6ms|2.45ms|

**Key Observations**:
- **Speed Advantage**: AI is faster than Kociemba at all depths (2 orders of magnitude faster at depth 7).
- **Accuracy Boundary**: AI's success rate drops sharply when depth >5.
- **Optimality Trade-off**: Kociemba guarantees optimal solutions, while AI solutions are usually non-optimal.

## Limitations and Future Improvement Directions

**Current Limitations**:
1. Depth Bottleneck: Success rate drops sharply when depth >5; cannot handle Rubik's Cubes scrambled with around 20 steps.
2. Non-optimal Solutions: The number of steps is usually more than the optimal solution when solving successfully.
3. Generalization Ability: Limited generalization to states outside the training distribution.

**Future Directions**:
1. Larger Models: Try Transformer or residual networks to break the depth bottleneck.
2. Reinforcement Learning: Combine RL (e.g., AlphaZero) for fine-tuning to learn better strategies.
3. Hybrid Methods: Use neural networks as heuristic functions to guide traditional searches (A*/IDA*).
4. Multi-stage Solving: Train sub-models responsible for different restoration phases (e.g., bottom cross, corner restoration).

## Project Summary and Value

This project demonstrates the potential and limitations of neural networks in combinatorial optimization problems: the AI solver is fast but non-optimal, while classic algorithms are accurate but slow. The project provides a complete reference implementation and benchmark framework, which is of great value to curriculum learning researchers and neuro-symbolic AI developers. Although solving the Rubik's Cube is a small task, it reveals the core challenge of AI learning effective strategies in a huge discrete state space.
