Making A Spooky Quantum Game in 15 Hours or Less
It’s no longer news that many organizations and even NASA
are in a race to reach what is known as quantum supremacy or the quantum advantage. This means they are investing in resources to develop new computers that are able to solve problems that current (classical) computers cannot; and of course perform faster at already solved problems. If you’re reading this article, you may have heard about Quantum Computing and all it promises to deliver and are curious to learn about the technology.
One of the best ways to learn is often by doing. This year’s IBM Q Awards
provided itself a great opportunity to experiment with this new frontier. There is a wealth of information available online about the field of quantum computing. However, for the purpose of our discussion, there are three basic concepts that should be understood. I attempt to explain them below.
1. Qubit: Short for quantum bit, this refers to a basic unit of quantum information. It is the quantum version of a bit in classical computing.
2. Quantum Superposition: The value of a classical bit can either be a 0 or a 1, the off or on states. A qubit on the other hand, can be in both off and on states at the same time. This is called superposition.
3. Quantum Measurement: Picture a coin lying flat on a surface. It could have either of its faces on top, with “heads” being one possibility and “tails” being another. This coin is a two-state system like a qubit and can simultaneously be in a superposition of the heads and tails states. However the superposition only survives until we check the coin, at which point it is forced into either a heads or tails state. This irreversible process of destroying superpositions through observation is known as measurement or collapse. It is a fundamental assumption of quantum theory. The probability of obtaining an outcome (heads or tails in the case of our coin) is determined prior to measurement by the superposition.
With these in mind, let’s move on to the good stuff.
There are many more concepts than the ones defined above. Due to limited time, our entry for the competition focused on applying these principles to the popular game Connect Four. The game is similar to X-and-O (Tic-Tac-Toe) except the goal is to make four connecting discs on a larger board.
To add quantumness to it, players have the option to insert two discs at a time when it’s their turn by clicking on the ACTIVATE SUPERPOSITION button. This simulates “superposition”. Quantum discs (represented as lighter shades) do not have a final position on the board but instead have a 50% chance of retaining their spot after clicking the COLLAPSE button to perform quantum measurement.
In the picture above, the Player 1 (blue) has two quantum (light-blue) discs, a superposition. The same goes for Player 2 (red) but with light-red to represent its quantum discs instead. The result of measurement will remove half of the quantum discs from the board and convert the other half to classical (solid colour) discs. As mentioned earlier, measuring a quantum object modifies its state leaving it in only one state.
We can see that Player 2 used their turn to collapse the board in the picture above. Note how columns 3, 6 and 7 have been updated accordingly. Both players’ quantum discs in column 3 are resolved to an on state meaning that the other quantum discs in columns 6 and 7 were removed from the board. What happens if a quantum disc is removed and has classical discs above it?
When Player 1 collapses the board, one of the two quantum discs is turned off and removed while the other is turned on and reduced to its classical state. Notice how Player 2’s classical disc is repositioned by obeying the laws of gravity and falling to the row beneath it that was previously occupied by one of Player 1’s quantum discs.
Behind The Scenes
To collapse n
-pairs of superposed discs all at once, we first map a qubit to each pair of superposed pieces. Then we create an equally weighted superposition of all 2^n
states by applying something called a Hadamard gates to every qubit. We achieve with the aid of the open source Qiskit
library. After measuring the state, the board is redrawn to reflect the updated state.
This couldn’t have happened without the efforts of the team:
Subscribe to get your daily round-up of top tech stories!