I played Tic-tac-toe on a quantum computer… and won!

A game of “Quantum” Tic-tac-toe.

In 1950, Bertie the Brain delighted crowds at the Canadian National Exhibition. It was the first known computer game with a visual display. It was a customed-made electronic version of Tic-tac-toe.

Credit: Life magazine

In 1952, Alexander Douglas created the first video game, called OXO, which simulated Tic-tac-toe on a general-purpose computer. It wasn’t likely that anyone outside of Cambridge played it. Ten years later, programmers at MIT created Spacewar!, which was installed on many PDP-1 Computers, including the one pictured here that I played with my daughter at the old STARTUP computer history exhibit in Albuquerque.

Playing Spacewar! in 2012.

Now, in 2021, the students in my class Introduction to Quantum Computing each created their own version of “Quantum” Tic-tac-toe, which can be played on a quantum computer. (We had to keep the Tic-tac-toe legacy alive! But, also, creating games is the best way to learn computational concepts.)

I created my own version of Quantum Tic-tac-toe alongside the students with the help of some UTS Software Engineering interns. My version is pretty simplistic, but it’s meant to be modular so you can easily modify and test out new quantum moves.

Each move adds a gate to the game circuit. The basic moves are as follows:

  • Measure ends the round and executes the game circuit on the quantum device. The win conditions will be counted and displayed.
  • Not flips an “owned” tile to the other player. If the tile is not currently owned, this does nothing.
  • O turns the initial tile toward being owned by “O.”
  • X turns the initial tile toward being owned by “X.”
  • SWAP swaps the location of two tiles.

As you play, you will see the game board and the circuit. The board shows the sequence of moves but is only indicative. The game circuit is the true state of the game — however, you need to understand a bit about quantum computing to appreciate what’s happening there.

To play the game requires “executing” it on a quantum computer (or simulation).

As of 1 Sep 2021, quantum computers are pretty small and with public access today you can play 2 x 2 Tic-tac-toe. The result of the above game took 10 seconds to run on a quantum device.

Details on the game that was played above and ran on an IBMQ quantum computer.

Okay, Tic-tac-toe, so what? Well, computer games have a long history of development alongside technology. As a teaching tool, games really are amazing. You can play Quantum Tic-tac-toe yourself on a quantum computer using the code below. You could even have a crack at modifying it to create your own set of rules. Enjoy!

Open in Colab to play!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store