База знаний: Serverless
Quantum Checkers
Опубликовано Денис Завьялов on 20 November 2018 13:16

How did we get to Swifty?

We were working on our own app – checkers with quantum theory rules called Quantum Checkers. Quantum Checkers does not need complex backend but it still needs user authentication to track your score and achievements. Looks easy right? But we realised that to run this simple backend we still need a complex infrastructure behind it: VPS, mongo, node.js etc.

Serverless was the answer. But the technology that looks very simple from the first sight becomes too complex to implement in production – I like iOS development but I do not want to spend days to get into multiple frameworks and AWS tools (I like AWS, but it looks too complex for me in this case).

Next answer was obvious – we are going to build our own serverless! Yes, with quantum checkers instead of blackjack and integrated authentication. So, now we have our own platform for backend development and Quantum Checkers game with authentication and profile management based on Swifty.


What is Quantum Checkers?

Quantum checkers is the extension of the classical English checkers (or Russian draughts) in which an individual piece (or man as  it’s sometimes called) behaves like a quantum objects, which basically means two things:

  1. Players do not know where pieces really are, only probabilities of them to be in different cells
  2. One cannot tell one piece from another of the same color

As in classical checkers or draughts, the game is played by two players on 8×8 cells board. Each player starts with 12 pieces of the same color and aims at capturing all the opponents’ pieces or making them stuck. Then quantum rules take place.

Quantum Rules

Shown on the board are not real pieces, but the probabilities of them, according to all the moves that have been made before. When game starts pieces are put with probabilities 1 (100%) in the classical starting positions. But pieces are not moved from one cell to another. Instead, players can only choose the cells from which they want to move.

This how the board looks when you start the game.


To make a move just tap on the checker you want. It will move in all possible directions it can and the board will reflect the probabilities of finding the piece on each of the new cells. If you play greens and tap on the 3rd piece from your top row it will move like this.


Two half-pieces mean, that the piece you’ve just tapped moved both right and left with equal probability and now sits in both cells simultaneously. Then the opponent moves with its 2nd piece from his bottom row. At this point it will just generate the symmetrical result.


Now if you tap on the rightmost cell where your quantum checker might be, the program will have to evaluate whether the piece is really there. If it is it will move according to the rules, if it’s not, the board will get updated with the result of that measurement and you will be asked to tap again. So, if the piece is on the right …


… it has moved according to the rules. If the opponent’s piece from its 4th row was on its right, then your piece has captured it and moved into the opponents’ 3rd row. This has happened with 50% probability. If the opponent’s piece was on its left, then your piece has moved to its 4th row in both directions, each with equal probability. Since the latter move itself is possible with 50%, the two resulting positions have probabilities of 25%.

This is how you typically think on the game — in which positions your pieces might have happened according to the previous moves and what would be the best choice among them all.

Download the game from AppStore and continue tapping the pieces!

More details about Quantum Checkers


When a cell is picked by a player the program checks whether the piece is really there by looking at the probabilities of pieces in cells. If the probability of a piece of the player’s color in the selected cell is one, the piece moves, if it’s zero the player much take another move. If the probability is between zero and one the program evaluates the cell in order to find out whether the piece is really there. To do the evaluation the program rolls the dice and the higher the probability is, more likely the piece to be really found in the cell.

So, once the piece is found in the cell, it moves in all possible ways it can according the be base rule set, and the probabilities of the pieces on the board are updated. It’s called superposition. When this happens some cells may contain the player’s piece with probability less than one as well as in one cell pieces of both players may co-exist (sum of the probabilities will be less or equal than one).

Classical rules enforce pieces to capture opponents if it’s possible. In quantum checkers this rule is also respected, but if there are more than one option to capture all are taken.


Sometimes moving conflict may occur. For example, in classical checkers when a player wants to move a piece in some direction two options exist:

  1. A piece can move in the destination cell or can capture the opponent’s one
  2. A piece cannot move because its blocked by opponent or some other player’s piece should capture the opponent

Of course, since it’s quantum checkers, these options also may happen with their own probabilities. If the program sees that the piece that moves is in at least two of them, the second evaluation takes place. After this, the program knows in which situation the piece really is, if it’s allowed to move it moves, if not the player is suggested to make another turn. In both cases probabilities of pieces on the board are updated.

End of the game

In classical checkers a player wins either when it captures all opponents pieces or when opponent cannot move. In quantum checkers both situations may happen with some probability, so the quantum match finishes once some player runs out of his checkers or becomes blocked with any non-zero probability.

Said that, there are three ways a match can end:

  1. Draw happens when one player suggest this option to his opponent and the latter accepts it
  2. Quantum win happens when opponent looses all his pieces or gets them blocked with some probability
  3. Classical win is quantum win with probability one.



(0 голос(а))
Эта статья помогла
Эта статья не помогла

Коментарии (0)