A simple Gomoku (or also called Five-In-A-Row) AI implemented in Python from scratch.
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
.
In order to run this program, the pygame
library must be installed first:
> pip install pygame
├── 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
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.
This repository is part of the submission of the final project for the MSc course 20602 - COMPUTER SCIENCE (ALGORITHMS) at Bocconi University.