This repository contains an implementation of the board game Santorini. My implementation provides three different types of opponents based on difficulty.
Santorini is a strategy-based board game where players compete to be the first to build a tower and place their worker on the third level. The game is played on a 5x5 board, and each player controls two workers. On each turn, a player moves one of their workers and then builds on an adjacent square. The objective is to reach the third level of a tower before your opponent does.
For detailed rules and instructions on how to play the game, you can refer to the official Santorini rules here.
This implementation includes a GUI that lets you play against three different levels of AI opponents: Random, Heuristic, and ML. The GUI can be launched using the following commands:
Launch the game with a random AI opponent:
python3 gui.py human randomIn this mode, your opponent makes random moves with no strategy.
Launch the game with a heuristic AI opponent:
python3 gui.py human heuristicIn this mode, the AI uses a heuristic strategy to optimize its moves. The heuristic evaluates:
- Height Advantage: Prioritizes building and moving to higher levels.
- Center Control: Attempts to control the center of the board.
- Worker Proximity: Keeps workers close to prevent the opponent from blocking key moves.
These factors are weighted for each available move and optimal move is played.
Launch the game with a machine learning opponent:
python3 gui.py human mlIn every turn, the chosen move is determined by multiplying the heuristic score by the machine learning output. This allows the heuristic score to dominate in the early stages, where basic principles like height advantage and worker positioning are key. As the game progresses and becomes more strategically complex, the model output (which will yield higher scores) takes precedence.
The ML opponent uses a convolutional neural network that processes board states represented as a 5x5 grid with separate channels for height and worker positions. The model was trained using 3.5 million simulated games and board positions with two random opponents playing against each other. By examining the last sequence of moves that led a the simulated player to win and assigning appropriate weights (larger "rewards" for moves closer to the final victory position, and high awards for the steps right before). By using a CNN approach, the model can well understand the positions that can lead to a victory and execute the proper strategies once it recognizes a pattern that may potentially lead to a victory.
In the final machine learning strategy, we combine combines heuristic evaluation with the deep learning predictions. Early moves are thus mostly based on basic principles encapsulated in the heuristic score, while later moves are informed by the model.

