/iQuhack

Primary LanguagePythonMIT LicenseMIT

Qic Qac Qoe - iQuHack 2022

Overview

We implement a quantum version of the classic two-player game, Tic Tac Toe.

Installation instruction

pip3 install pygame
pip3 install qiskit
pip3 install qiskit.aqua
pip3 install matplotlib
python3 main.py

Technical Details

Our game is played on a 3x3 grid, where each square is a qubit initialized to the state:

One player wins with 0's, and another player wins with 1's. Upon each turn, a player may perform one of six possible moves:

1) Measurement

The player measures any state on the board in the basis. The state on the board hence collapses into the measured state.

Additionally, the player may apply single-qubit gates on a particular quantum state:

2) Hadamard gate

The player selects one qubit and applies

It is represented by "plus -> O" gate in the game.

3) Z gate followed by Hadamard gate

The player selects one qubit and applies

It is represented by "plus -> X" gate in the game.

4) Controlled NOT gate

The player selects two qubits, and applies

This may result in the two states becoming entangled with each other.

5) SWAP gate

Finally, to showcase the full range of the capabilities of quantum computation, the player may also teleport a quantum state across the board:

6) Quantum teleportation

Each player carries an ancillary qubit m, which can be used to form an EPR pair with another state on the grid j and teleport an existing state at square i to j. A C-NOT gate is applied to qubit i and m (i is the control qubit and m is the target qubit). After applying Hadamard to qubit i, we measure both quibits i and m.

Such a move would not be possible with classical bits.

Gameplay

Gameplay begins by running the file main.py, upon which the players will see an initialized board, with buttons for each action that may be performed on the qubits.

The player may then select a qubit and a possible operation on the qubit from the selection menu.

Each player takes turns, performing actions on the qubits.

The winning condition is checked after all qubits have been measured or after 20 moves (to prevent infinite gameplay). It is important to note that once a state has been measured, no further actions may be performed on that state. Furthermore, all states are measured prior to the winning condition being checked.

Resources

Our game is inspired by

M. Nagy and N. Nagy, "Quantum Tic-Tac-Toe: A Genuine Probabilistic Approach," Applied Mathematics, Vol. 3 No. 11A, 2012, pp. 1779-1786. doi: 10.4236/am.2012.331243.

In our project, we have extended their ideas and implemented additional gates and actions.

About the team

We are a diverse group of MIT undergraduate students studying subjects from physics to chemistry, from mathematics to computer science. We came together as a group to pursue our shared interests in quantum computing and quantum technologies. Our time at MIT has granted us the opportunity to meet and learn from leading experts in the field. These experiences have been extremely valuable and will certainly have an impact on our futures.

Team members: Chirag Falor, Hieu Dinh, Lauren Li, Linh Nguyen, Shu Ge