Skip to content

Implementation in python of a Gomoku AI from scratch based on MiniMax and Alpha-Beta Pruning

License

Notifications You must be signed in to change notification settings

husus/gomokuAI-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.
start_screen

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.
end_screen




Disclaimer

This repository is part of the submission of the final project for the MSc course 20602 - COMPUTER SCIENCE (ALGORITHMS) at Bocconi University.

About

Implementation in python of a Gomoku AI from scratch based on MiniMax and Alpha-Beta Pruning

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages