Path: blob/main/notebooks/ch-demos/coin-game.ipynb
3855 views
Quantum Coin Game
Table of Contents
Introduction
What is Quantum Coin Game ?
Quantum Coin Game is one of the fundamental concept of quantum computing, which uses simple implementation of quantum gates or more precisely uses the wierdness of quantum mechanics, to win about 97% of the time, when played against an opponent. Flipping of coin and say heads or tails.
Where the concept came from ?
The concept of Quantum Coin Game came from the idea of classical coin game which can only show heads and tails. But since the game utilizes the concepts of quantum mechanics, it would be interesting to see what could be the outcome of the whole experiment.
What is the main idea of this game ?
The main concept of this game is how the quantum computer uses the power of quantum superposition, which tells an object can exists in 2 different states at the same time, to win absolutely everytime.
NOTE: To learn more about quantum superposition, link to "Qiskit Textbook" superposition page.
What are the rules of this game ?
Quantum Computer plays a move but it is not revealed to the Opponent(Human).
Opponent(Human) plays a move and it is also not revealed to the Quantum Computer.
Finally Quantum Computer plays a move.
Results are shown. If its heads, then Quantum Computer wins. Else, Opponent(Human) wins.
NOTE: "Playing a move" refers to "Flipping the coin" and we consider the coin as fair coin.
NOTE: Refer to Shohini's Ted Talk
Analogy
Now that we know what is a quantum coin game, what is it based on and most importantly what are the rules of this game, lets convert the concept of this game in quantum computing terminology.
The 'coin' in flipping a coin we referring here is a 'single qubit gate'.
where and
"Flipping" the coin is application of the bit-flip operator
The "heads" state is defined as
and "tails" as
The quantum computer "plays" by applying the Hadamard operator
Approach
Lets see how to approach the game in quantum computing terminology-
The coin is initialized to the "heads" state.
The computer plays, applying the Hadamard operator to the coin (operators are applied using matrix multiplication).
The coin enters the state.
The human plays, choosing whether to flip the coin (apply the operator) or do nothing (apply the operator). However, since the operator just flips the state vector upside down, has no effect. Same goes for .
No matter what, the state is after the human plays.
The computer plays, applying the Hadamard operator again, taking the coin to the "heads" state.
Using the above approach the possibility table reduces to-
| Start State | Quantum | Classical | Quantum | Result | Who Wins? |
|---|---|---|---|---|---|
| Quantum | |||||
| Quantum |
Now lets look at the possibilities-
Quantum Computer Wins ( ):
Classical Human Wins ( ):
Either Quantum Computer or Classical Human Wins ( ):
This table shows the quantum computer wins of the time. But in Shohini's talk it is , due to errors.
Building the initial circuit
Turn 1. Quantum Computer
Turn 2. Classical Human
Turn 3. Quantum Computer
Quantum Computer uses Hadamard on its first turn
Unlike the perfect simulation, the real quantum computer only wins ~ of the time, the in which it loses is due to errors. Quantum computers have improved a bit since Shohini's talk where the error is closer to .
This simple and yet fun little game shows the basic quantum states , , and , plus the common ways of moving between them with the , , , gates.
This notebook is inspired from:
[1]. Ted talk by Sohini Ghosh.
[2]. Quantum Coin Flipping from Wikipedia
The rules of the game we learned so far are the main rules of the game. But, think of other variations of the game as well, tweak the game a little could result in significant change in answer. Such as-
What if, instead of quantum computer taking first turn, the classical human take the first turn ?
What if, instead of representing head as , the tail is represented as ?
What if, instead of using fair coin, we used unfair coin ?
What if, instead of playing against a classical human, the quantum computer plays with another quantum computer ?
What if, instead of having 3 turns, there are number of turns ?
What if, instead of using all gates, restrict the use of some gates ?
and many more variations are possible.