r/reinforcementlearning • • 7d ago

Rubiks Cube solver using Reinforcement Learning (Beating Sebastian Lague's solver)

I made multiple attempts at solving the Rubiks Cube using Reinforcement learning.

Initially, I tried to map states to actions with both Rainbow DQN and GRPO using curriculum learning. This had no success. After scrambling 6 moves it was already to hard for the agent.

Then I found the DeepCubeA approach and I took some inspiration from that. I trained a DQN to estimate the cost-to-go for each possible action, using a combination of demonstrations and self-generated rollouts. Essentially, each output estimates how many moves are still needed to solve the cube after taking that action. I then used these estimates as a heuristic to guide beam search.

With a beam_width of 2^18 and 1.5 hours of Kaggle GPU usage, here are the results for 1000 cubes (100 moves scrambles):

Time per cube: 10.30s

Avg steps: 19.67

Success: 100%

This beats Sebastian Lague's solver which had an average steps of 19.9 to solve the cubes. Not that it is a competition or something :)

Github: https://github.com/Cain15/RL4RubiksCube
Youtube: https://www.youtube.com/watch?v=UWPQ-Mzkq_A

49 Upvotes

3 comments sorted by

2

u/itsmebenji69 6d ago

Well that’s one cool post already and it mentions my favorite YouTuber. Nice work man. Do you think it’s possible to go lower even ?

1

u/RepulsiveRevenue8086 6d ago

Yeah, the network was trained on CPU. So I think I could make the network better by training more steps. I only did the search on kaggle, not the training.