This is a Gomoku game project developed as part of the 42 projects. The project includes both a backend and a frontend, with the backend written in Python and the frontend in TypeScript using React.
- Python
- Node.js
- npm
- Clone the repository:
git clone https://github.com/sboof911/Gomoku cd Gomoku
To build both the frontend and backend, run:
make buildThis will:
- Create a virtual environment for the backend and install the dependencies.
- Build the frontend using npm.
- Package the backend using PyInstalle
To start the project, run:
make startThis will build the project and start the Gomoku executable.
To clean the build artifacts, run:
make cleanTo perform a full clean, run:
make fcleanThe AI for the Gomoku game is implemented using the Minimax algorithm with alpha-beta pruning. The AI logic is located in the ai directory and includes the following key components:
-
Minimax Algorithm: The core of the AI is the Minimax algorithm, which is implemented in the
minimaxfunction. This function recursively evaluates possible moves to determine the best move for the AI player. -
Alpha-Beta Pruning: To optimize the Minimax algorithm, alpha-beta pruning is used to eliminate branches in the search tree that do not need to be explored. This helps in reducing the computation time.
-
Heuristic Evaluation: The AI uses a heuristic evaluation function to score the board positions. This function is implemented in the
heuristic_evaluationfunction and considers factors such as the number of stones in a row, potential captures, and free spaces. -
AI Manager: The
AI_managerclass manages the AI's decision-making process. It handles the initialization of the AI and determining the best move based on the Minimax algorithm. -
Memoization: To further optimize the AI, memoization is used to store previously computed board states and their evaluations. This helps in avoiding redundant calculations and speeds up the decision-making process.
The backend is located in the backend directory and includes:
api: Contains the API logic for the game.ai: Contains the AI logic for the game, including heuristic evaluation and memoization.game: Contains the core game logic, including board representation, move validation, and game state management.settings: Contains configuration settings for the game, including game rules and server settings.server: The main server file.
The frontend is located in the render directory and includes: