Software LOG-02 · Jun 2024
Quantik: a board game in C against the computer
The board game Quantik in C, with an SDL2 graphical interface and an alpha-beta minimax AI. Started as a team in 1st year and never finished, then taken back to make it playable.

AThe context
Quantik is played on a 4 × 4 board with four shapes: you win by placing the fourth different shape in a row, a column or a square, and you may not place a shape where your opponent has already placed it. As a team of three, I handled the rules, Valentin the SDL interface and Henri the AI. At the end of the project, none of the three parts worked with the others: the game was not playable.
BWhat I did
- Rules rewritten: the placement rule was inverted, squares were never checked and a win counted four pieces instead of four shapes
- AI rewritten as minimax with alpha-beta pruning, without storing the move tree: each move is played, explored, then undone
- Valentin's SDL interface connected to the game: drag and drop with the allowed cells highlighted, animated AI turn, winning area highlighted
- Automated tests: the AI wins 200 games out of 200 against a random player and thinks for less than a second per move
CThe challenge
The first version of the AI tried to build the whole tree of possible moves in memory, with up to 64 moves per turn: the tree was never filled correctly and the program crashed on the computer's first move. The solution was to stop storing the tree and instead traverse it by playing then undoing each move on a single board, and to adapt the depth to how full the board is: 3 to 6 moves ahead early in the game, then a calculation to the end from the sixth piece placed.
DIn pictures
