Solving A Rubik’s Cube with Supervised Learning — Intuitively and Exhaustively Explained

A popular toy in a brave new world

“Mosaic Space” by Daniel Warfield using Midjourney, Matplotlib, and Affinity Design 2. All images by the author unless otherwise specified. Article originally made available on Intuitively and Exhaustively Explained.

In this article we’ll make an AI model that can solve a Rubik’s Cube. We’ll define our own dataset, make a transformer style model that can learn based on that dataset, and use that model to solve new and randomly shuffled Rubik’s Cubes.

In tackling this problem we’ll discuss practical problems which come up frequently in data science, and the techniques data scientists use to solve those problems.

Who is this useful for? Anyone interested in achieving mastery of modern AI.

How advanced is this post? This post covers advanced modeling strategies intuitively, and is appropriate for readers of all levels.

Pre-requisites: There are no prerequisites for this article, though an understanding of transformer style models may be useful for some of the later, code heavy sections.

References: A link to the code and supporting resources can be found in the reference section at the end of this article.

Defining a Rubik’s Cube as a Modeling Problem

As you likely know, the Rubik’s Cube is a geometric game featuring a 3x3x3 cube with different…