Try our game!
- Clone our repo
- Run
pip install -r requirements.txt - Run
python main.py
Instructions
Ahoy, Quantum Commander! Prepare to set sail on a mind-bending voyage through the fabric of spacetime as we engage in Quantum Battleship, where uncertainty and strategy collide in an epic duel across the quantum realm. Ready your fleet and navigate the uncertain waters of superposition as we embark on a journey that defies the laws of classical warfare!
Your mission, valiant commander, is to lay waste to a fleet of 10 enemy battleships using the enigmatic weaponry of classical and quantum cannons. Take heed, for these are not regular battleships. They exist in states of superposition across the vast ocean. Use the space bar to toggle between classical cannons and enigmatic quantum cannons, and press enter to unleash their fury. Classical cannons unveil the true nature of a single square. Quantum cannons shall illuminate the probabilities of four adjacent grid squares. Legend has it parts of sea are entangled, for firing upon one shall unveil the destiny of its counterpart. To gain further insights, toggle the image on the right to reveal the intricate heat map of probabilities.
Best of luck, intrepid commander, may your valour and determination guide you to triumph on these tumultuous quantum seas.
Inspiration
Quantum physics is confusing. We wanted to create an adaptation of this classic board game to help model three classic quantum physics principles: superposition, entanglement, and uncertainty.
How it works
The goal of the game is to hit ten of your enemy's ships using the least amount of cannon shots. The battleships exist as a linear combination of two possible states throughout the board, either a ship being present or not. You have two types of cannons in your arsenal: classical cannons and quantum cannons. Classical cannons observe the state of any square, forcing the superposition to collapse into one of the two states. Quantum cannons reveal the probabilities of four adjacent grid squares having a ship.
The idea of superposition is fundamental to our implementation of battleship. In regular battleship, each square definitively either contains a ship or does not. In our implementation, every square is a superposition of those two states, which is described by a wave function. The function dictates the probability of the square having a ship or not. The square exists in this state of superposition until we fire a classical cannon on it. Observing the square forces it into one of the two eigenstates a|0> + b|1>.
We also incorporated quantum entanglement into our battleship game. Eight pairs of entangled battleships are scattered throughout the board. If one ship of the pair is selected with a classic cannon, its partner also collapses into the same state.
The third idea is something we like to call the HeisenBread Uncertainty Principle. Heisenberg claimed that we cannot know both the position and the speed of an electron with perfect accuracy; measuring one property leads us to lose information about the other, and vice versa. Our game mimics this idea on a high level. Every time you fire a classical cannon, you gain information about a location on the board, but you grow more uncertain about the total number of ships on the board. Your uncertainty of the number of ships left on the board always follows the sequence (ΔQ_{n}) = {0, 0.99, 1.98, ...}.
How we built it
We used IBM’s Qiskit library for the backend, a quantum computing library that operates on the level of qubits and circuits. We used qubits to represent the superposition and collapse of a square, and simulated its behaviour to measure it. It was interesting to see how abstract quantum physics ideas are able to be directly translated into computing concepts. For instance, CNOT gates can be applied to two qubits to entangle them. The front end was created from scratch using pygame library.
Challenges we ran into
Our biggest challenge with the project was balancing the line between incorporating authentic quantum physics properties without losing sight of the original gameplay. It was tempting to redefine certain theories in order for them to better fit with the logistics of the game.
Accomplishments that we're proud of
This was all of our first times working with quantum physics and quantum computing, so we're very proud of our final product. We're glad we were able to get a final product finished.
What's next for Quantum Battleship
One feature we unfortunately did not get the time to implement was a 2-player option for Quantum Battleship. Additionally, we want to add in more features related to quantum mechanics while learning more about it along the way.

Log in or sign up for Devpost to join the conversation.