File size: 1,462 Bytes
9f04095
 
 
 
 
 
57b240e
9f04095
 
4b13a2e
9f04095
4b13a2e
 
d29ea33
ba6ac07
2a0a9fd
 
 
 
 
 
4b13a2e
 
 
67ab4fa
 
 
4b13a2e
67ab4fa
 
 
4b13a2e
67ab4fa
 
 
4b13a2e
67ab4fa
 
 
4b13a2e
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
---
title: "Rubik's Cube Solver"
emoji: 🧊
colorFrom: blue
colorTo: green
sdk: docker
app_port: 7860
---

## 🧊 Rubik's Cube Solver

Solve the Rubik's Cube using Reinforcement Learning! 🚀

https://github.com/user-attachments/assets/0f6cdf0c-37f5-4f7c-a367-c696e21ad4dc

## How it works

In this reinforcement learning approach to solving the Rubik’s Cube, we begin by training a neural network that learns both a value function and a policy function. The value function evaluates the quality of the current state, while the policy function guides the choice of the next move. To search for the optimal solution, we then apply Monte Carlo Tree Search (MCTS), which balances exploration and exploitation during decision-making.

Our overall algorithm design is inspired by the paper [Solving the Rubik’s Cube with Deep Reinforcement Learning and Search](https://arxiv.org/abs/1805.07470). However, we introduced a few simple modifications in the network component to better suit our implementation.

## 🏋️‍♂️ Train the Model

1. Navigate to the `rlcube` directory:
   ```
   cd rlcube
   ```
2. Install dependencies:
   ```
   uv sync
   ```
3. Activate the virtual environment:
   ```
   source .venv/bin/activate
   ```
4. Start training:
   ```
   python -m rlcube.train.train
   ```

After training, your model will be saved in the `models` folder.  
Please rename the trained file to `model_final.pth` so it can be used by the API. 🎯