I want to start a new tutorial about Quantum computers and quantum computing in general. This will be one of the first posts on this topics.

Card game: Hide queen

This is very simple game with 4 cards and 1 queen. All you need to do is to hide the queen in a slot. Then you have to find it.

This is the link to the game: quantum card test

After the execution you can see how many iteration are for quantum and for classical computer:

Quantum: 1 attempt, Classical: 2 attempts

And a short explanation:

In this example, the Quantum Experience simulates quantum physics to search all of the potential possibilities, and find the queen on the first try. The classical computer computes one step at a time and could take four tries.

Here you can find a small simulation of this game in python running 1000 shuffled decks of cards:

import random
import collections

deck = [1, 0, 0, 0]

probability = []

def queen(deck):
    i = 1
    while (deck[i - 1] != 1):
        i += 1
    probability.append(i)


for i in range(0, 1000):
    random.shuffle(deck)
    queen(deck)

print  (collections.Counter(probability))

and the result:

Counter({3: 265, 2: 250, 4: 243, 1: 242})

as you can the attempts are almost equal around 25 %. The biggest number is 3 - which means that this algorithm finds the queen most of the times in 3 attempts. Or we could say that it finds the queen as quantum computer in 1 shot only in 25 % of the time.

How quantum computer work

The quantum computer implement a Grover's algorithm. This algorithm use an oracle function which simulate all the 4 versions of the card positions and find the most probable of all just in one shot.

One this link you can find discussion about the algorithm and how it works:

Grover's Algorithm: Hiding the queen

From the same link you can simulate or run the algorithm on a real quantum machine(after registration on the site).

Since there are only 2 cards you will need only 2 qubits for this experiment.

So several questions arise for me - which I'll check in next posts:

  • how to hide queen on a different position than the 4th one - which is in the example
  • how to implement this game for more cards

Quantum computers could be really interesting new field in computer science area. I would try to cover some topics on it and go deeper in this matter.