This web based game is a submission for the IBM Quantum Awards 2019 the Game Award Challenge.
This game is based on the tabletop game Connect Four and also inspired by the popular Quantum Tic Tac Toe.
However Connect Four differs from Tic Tac Toe in that the pieces are placed from the top and fall to the bottom under the influence of gravity.
- Arjit Khullar @arjitkhullar
- Tomisin Jenrola @ToJen
- Rahul Choudary @YenSid12
The players take turns dropping different colored pieces into columns until they can form a horizontal, vertical or diagonal line of 4 pieces. Instead of placing these classical ('solid') pieces, players can also form quantum superpositions by clicking the 'Begin Superposition' button and placing two quantum pieces (indicated by a lighter shade) in different spots, such that the piece has a 50% chance of appearing in either spot upon quantum measurement. Forming superpositions with quantum pieces serves the additional purpose of denying crucial squares to opponents. Both sides continue placing solid or quantum pieces until the the board is filled up, at which point, the superpositions collapse and the surviving pieces fall into place under the influence of gravity and the game-play resumes.
The game will continue like this until any one of the following conditions is met:
- Player 1 forms a winning combo before their opponent. Note: the winning pieces must be solid and must not have any shaky quantum pieces underneath them, since that could potentially destroy a winning connection upon quantum measurement.
- Player 2 forms a winning combo before their opponent
- Tie I: The board gets completely filled up by solid pieces before either player can form a winning combo thereby ending in a draw
- Tie II: Both players form winning combos simultaneously upon collapse of the superpositions, this is a draw condition unique to our quantum version of Connect Four
To collapse n-pairs of superposed pieces all at once, we first map a qubit to each pair of superposed pieces. Then we create a equally weighted superposition of all 2^n states by applying Hadamard gates to every qubit:
We then measure the state and collapse the game board accordingly. The plots below are from a 3-qubit example of our circuit, performed on the qasm_simulator of the Aer package:
- Clone this repo:
git clone git@github.com:ToJen/quantum-connect-four.git
docker-compose up --build --force-recreate --always-recreate-deps
- Clone this repo:
git clone git@github.com:ToJen/quantum-connect-four.git
cd client
yarn && yarn dev
- Create a separate terminal session
cd server
pip install -r requirements.txt
python main.py
(Python 3.5.7)
Visit http://localhost:5000
docker build -t registry.heroku.com/<heroku-app-name>/web . && docker push registry.heroku.com/<heroku-app-name>/web && heroku container:release web -a <heroku-app-name>