Tic-tac-toe… but more confusing and way cooler

Silen Naihin
5 min readJan 1, 2019

Superposition. Collapse of the wavefunction. The two words shot out through the air in forms of soundwaves, making anyone in their path confused. Those words have been floating around with explanations from mainstream media articles, but how can you actually visualize these principles? I’ve decided to help clear the air, as I sure don’t like the smell of uncertainty (neither did Einstein ;).

One way to explain these phenomena intuitively would be tic-tac-toe. Not regular old ‘it’s a tie again’ tic-tac-toe, I’m talking about quantum tic-tac-toe. Alan Goff invented this version of tic-tac-toe to introduce quantum physics without mathematics, and offer a “a conceptual foundation for understanding the meaning of quantum mechanics”. I wrote this article assuming you know basic concepts of quantum computing, such as what a qubit is. I explain everything in depth in another article I wrote. Check it out here.

Tic-Tac-Toe Origination

A form of tic-tac-toe was originally played by the Romans called terni lapilli (three pebbles at a time) in the first century. In this form of the game, you only had 3 pieces and you had to keep moving them around to keep playing. Later, this evolved into the version of tic-tac-toe we play today. The goal of the game, is to form a row of 3 with your chosen letter, X or O. This may sound easy, but your opponent, is trying to stop you from getting a 3 in a row, and is pursuing a 3 in a row themselves. When two players know what they are doing, the outcome is usually a draw (which is why people stick with rock-paper-scissors, at least someone will win eventually!). Now, 2000 years later we have evolved the game once more, into its ultimate form — quantum tic-tac-toe.

Gameplay

This version of quantum tic-tac-toe runs in the command line, so to start, you just run the file in the command line. Once you run the file, a welcome message will appear along with a set of instructions:

In this version of tic-tac-toe, the goal is the same — make a row of 3. But it’s a little more complicated than that. Each turn is a superposition of two moves, meaning your one turn gets split up into a probability of those two spots you play in. The moves that you play are anticorrelated, meaning that the qubits are split up into parts of the full 100% of the spot if the opponent attempts to occupy it. Once you make your moves, you end the game whenever, and a simulation of the possible outcomes is generated.

Say player X went through his turn, then we measured the outcome of the game by typing ‘end’:

The simulation would have about a 50% chance of collapsing X to the top left spot and about a 50% spot of collapsing to the middle spot. This demonstrates the superposition of the one move. Just like a qubit in superposition, the move had a possibility of being in two different places, even though it was only one move. Once we ‘measured’ the move, we ‘collapsed the wave function’ and discerned the percentage of each of the possible outcomes happening. Isn’t that cool? Notice how the percentages are not 50% exactly. This is because the Qiskit includes noise in its simulations. Today, quantum computers are full of errors and the threats of decoherence screwing up your entire calculation are prevalent. To make Qiskit as accurate as possible, noise is included in the simulations.

Code Side

This version of quantum tic-tac-toe is implemented using Qiskit IBM’s open-source framework for working with quantum computers, using circuits and algorithms. I took inspiration from Qiskits version of this game. In the code below you can see that several things are needed in order to run the simulation:

First, you need to import Aer, a high performance simulator framework for quantum circuits. This is what powers the simulation when you end the game and wait for the outcomes. QuantumCircuit creates a quantum circuit, ClassicalRegister creates a regular register, and QuantumRegister creates a quantum register, and they are used to run the simulation. CompositeGate, is a sequence of quantum gates, and it can be used create a new composite gate. Execute is used to run the quantum circuit. The composite_gates are quantum gates or operations (e.g cnx = CNOT gate — which entangles two qubits). They are used to control and change the quantum circuit.

Wrap-Up

There are a couple of different versions of quantum tic-tac-toe, as this version of the game is not quite as linear as the normal version (although a winning condition still exists, meaning that a tie can happen). The original version of quantum tic-tac-toe is played slightly differently. The superposition still exists, but the collapse condition is different. Instead of moves being anticorrelated and computed at the end, the collapse is controlled by the players once a closed loop is formed. This is a more intuitive way of playing quantum tic-tac-toe, but also a little bit less quantum as it is not a real simulation. Watch a video on how to play this version here. Play this version of the game here.

When people think of an application running on a quantum computer, images of breaking internet security, or simulating drugs, or predicting the stock market probably come up. We aren’t there yet, and we still have a lot of development to do in quantum computers to get to that stage. Quantum tic-tac-toe offers an intuitive introduction to some not so intuitive principles to make it easier to get into the field.

Thanks for reading!

I would really appreciate it if you could

  • Clap to show your support
  • Follow me on LinkedIn and Medium (Silen Naihin)
  • Give constructive criticism in the comments

This story is published in Noteworthy, where 10,000+ readers come every day to learn about the people & ideas shaping the products we love.

Follow our publication to see more product & design stories featured by the Journal team.

--

--