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.
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:
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:
git clone [email protected]:ToJen/quantum-connect-four.git
docker-compose up --build --force-recreate --always-recreate-deps
git clone [email protected]:ToJen/quantum-connect-four.git
cd client
yarn && yarn dev
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>