June 13th 2018 by Tanisha Bassan
Quantum Computers are starting to slowly become a common term in the tech/physics community. However very few people know how they work much less how to program them.
I decided to take this as a challenge for myself and hopefully teach other people about this new and exciting technology!
A high-level overview of Quantum Computers:
→ Basically giving computers the super power to solve really long/hard/unfeasible problems.
Someone has to figure out how to code these things before we can start cracking the fun problems. Notable companies such as IBM, Rigetti, Microsoftand Xanad have created softwares that now allow us to start learning the language of these mystical computers. The focus today is on Strawberryfields, Xanadu’s open-source software for photonic quantum computing. (The fact its named after a Beatles song makes me love the language even more!)
The screenshot above shows the software Xanadu has created, the official programming language is called Blackbird (yet again another famous Beatles song). Visit their Documentation to learn how to get started!
I was inspired by Dr. James Wootten to try my hand at creating a Quantum Battleships game but using qumodes instead of qubits. Qumodes, as Xanadu has labeled them represent the continuous-variable model system of photons. This means they can compute in infinite-dimensional hilbert space making them a powerful form of quantum systems. Hilbert space is where all the operations are done on a mode where is has more attributes and is larger than our normal euclidean space dimensions. Qubits remain to be discrete and continuous and herein lies the difference between the two physical quantum carriers.
The Quantum Battleships Game
The goal of this game is to help give other people and myself an easy introduction to quantum programming and help build up the intuition of how qumodes work.
First lets install and set up a python environment to run and execute our program. To make it easy I provide simple instructions which allow you to create a virtual environment using Anaconda3 (install latest version)
Now that we have our environment and dependencies setup we can go ahead and run our code. You can copy the code from my Github here and try running it on your own computer.
The introduction provides a small tidbit on photonic quantum computers before getting started, here is what the screen should look like:
This is an open-project that I will continue to improve so as this game progresses I hope to develop a compelling story that goes along with the game and explains quantum computing in a fun way. (I need your help!)
Next up is choosing where to place Player 1’s ships on a grid.
Player 1 has to place a ship on any of the positions, each letter represents a different qumode which will be acted upon when hit on a bomb. The objective is to sink the ship by applying quantum gates that put each state in a superposition and based on the fock states measured (probability) the ships will collapse to either 0 or 1 which determines if your ship is alive or dead.
Now Player 2 has to choose where to place the bombs and destroy Player 1’s ship.
I picked 1, 2, 3 ready to shoot my bombs into to sea of quantum ships. The bombs are the gates which influence the state of each mode, making them either have a great probability of 0 or 1 to determine of the ship is sunken or not. Depending on the noise and entanglement of each mode the game should end when Player 1’s ship has sunk or stayed afloat. The results can be weird at times where for some ships that should have sunk the opposite may be true. This all leads towards understanding the crazy actions of very small things and how they can lead us to create the most powerful computational devices in history. Nature at its most core value is probabilistic.
Quick Summary of Steps on how to Play:
- Set up your virtual environment with strawberryfields downloaded as a package
- Create a folder with the python code on your computer
- Access the code from your python terminal and run the file to start the game
- Click the enter key to move through the introduction
- Player onechooses a position
- Player two has 3 guesses to input
- Based on the randomness of the qumodes and the guesses the game can be won by either player
Here is a quick video that takes you through all the steps:
This toy game can be helpful in understanding the bigger picture around quantum computing. It is important to understand the randomness that can occur within these systems. The implications here are that as we scale our quantum computers to bigger problems, everything will be determined by the highest probability. This is very unconventional from our deterministic lives where there are only set number answers and nothing in between.
There is still much improvement to be made so I encourage feedback and any comments as they are a way for me to learn and create a more engaging game. Feel free to reach out to me on LinkedIn, thank you for reading!