Gomoku is a timeless strategy board game played on a grid, where players aim to align five stones in a row to outsmart their opponent. This web-based version offers a modern design, a challenging AI, and dynamic gameplay.
The objective of Gomoku is to align five stones in a row before your opponent. To add complexity, this version includes the ability to capture your opponent's stones. You can also win by capturing five pairs of your opponent's stones.
Captures occur when you place two of your stones at both ends of exactly two of your opponentβs stones (neither one stone nor more than two stones). The captured stones are removed from the board, freeing those positions for reuse.
White stones can capture the black stones by placing a stone at the highlighted position.
A "free three" is a line of three stones that can lead to a "free four"βa move that cannot be defended because either endpoint of the line creates a winning row of five stones. To balance gameplay, moves that create two simultaneous free threes (a "double free three") are forbidden.
The AI uses the Mini-Max Algorithm with Alpha-Beta Pruning to make strategic decisions.
- Mini-Max: A decision-making algorithm that simulates all possible moves to minimize the opponent's advantage while maximizing the AI's chances of winning.
- Alpha-Beta Pruning: An optimization technique that skips evaluating branches of the decision tree that won't affect the outcome, significantly reducing computation time.
The AI implements several optimizations for enhanced performance:
- β Alpha-Beta Pruning: Reduces unnecessary calculations.
- β Dynamic Depth Adjustment: Adjusts the search depth based on the current game state.
- β Risk-Based Action Evaluation: Focuses on moves that represent threats or opportunities.
- β Priority Sorting: Evaluates actions in order of strategic importance.
- β Efficient Game State Simulation: Saves only the move and game status instead of performing a complete deepcopy for simulations.
To run this project, the first step is to install Docker on your machine. Docker simplifies deployment by providing an isolated environment for your application.
This project includes a Makefile, which allows you to execute Docker commands more easily, without having to type them manually. While using make is optional, it is highly recommended to simplify operations. You can install make by following this link or by searching for installation instructions specific to your system.
Run this command in your terminal:
makeThis will display:
Next, run this to start the web application:make runIf you prefer not to use make, you can start the web application by running the following command:
docker-compose -f docker-compose.yml build
docker-compose -f docker-compose.yml up -dNavigate to the Project Folder
You can access the project folder by using this link.