Gomoku AI in Python
A simple Gomoku (or also called Five-In-A-Row) AI implemented in Python from scratch.
๐ Overview
Gomoku is a strategy board game with 2 players and on a 15x15 board. The objective of the game is to form an unbroken chain of 5 stones (vertically, horizontally, diagonally) and the first player to do that wins the game. In this project, you can play against the AI that uses the MiniMax algorithm with alpha beta prunning in order to make the next move. Everything is integrated with a GUI made through pygame
.
๐ Requirement
In order to run this program, the pygame
library must be installed first:
> pip install pygame
๐ Files Structure
โโโ assets
โ โโโ black_piece.png
โ โโโ board.jpg
โ โโโ button.png
โ โโโ menu_board.png
โ โโโ white_piece.png
โโโ gui
โ โโโ button.py
โ โโโ interface.py
โโโ source
โ โโโ AI.py
โ โโโ gomoku.py
โ โโโ utils.py
โโโ .gitignore
โโโ LICENSE
โโโ README.md
โโโ play.py
๐ฎ The Game: Execution
For playing against the AI, run the following commands:
> git clone https://github.com/husus/gomokuAI-py
> cd gomokuAI-py
> python3 play.py
The image below is the starting screen of the game interface that would appear after the above-mentioned commands have been run correctly. The player can choose between black or white, and the other color will be assigned to the AI. Remember that according to the Gomoku rules, black always starts first.
To make the moves, it is necessary to simply click on the empty intersections of the board and one stone will be placed. The game keeps going by alternating turns between the human player and the AI until one of the two wins by forming an unbroken chain of five stones of the same color. Once the game ends, the following screen will pop out and the player can choose whether to restart the game or not. By selecting no, the pygame window will be closed automatically.
Disclaimer
This repository is part of the submission of the final project for the MSc course 20602 - COMPUTER SCIENCE (ALGORITHMS) at Bocconi University.