Gobang Project: An Overview
Introduction to Gobang AI
In November 2023, the Gobang project underwent a comprehensive rewrite, making the code more straightforward and correcting a rare issue where the AI occasionally made incorrect moves. This update has made the AI's gameplay more reliable, and the project has also stepped up to React Version 18.
The project's source code is targeted at hobbyist study of AI and contains some imperfections, understandable given the limitations of the available time and resources.
This project features an AI implementation of Gobang using the minimax algorithm. Users can experience it firsthand by scanning the above QR code or visiting https://gobang2.light7.cn/. For those encountering issues with the https
protocol, an alternative link is http://gobang2.light7.cn/.
For those interested in machine learning and neural networks, there's an exciting development in the works based on the Alpha Zero principles called alpha-zero-gobang, implemented with Tensorflow 2.x.
Common Questions
-
What is the principle behind the AI? The AI is based on the minimax search algorithm with several common performance enhancements. It does not utilize machine learning techniques like neural networks or reinforcement learning.
-
Why does the AI seem less skilled? The AI relies on a minimax algorithm with limited optimizations, and it's restricted by the speed at which JavaScript runs in a browser. This results in reduced search depth, affecting its skill level.
-
What are the differences in AI difficulty levels? The difficulty levels vary in search depth; deeper searches equate to stronger AI but also increase the time taken to make decisions.
-
Is an internet connection necessary? An internet connection is needed for the initial page load or refresh, but AI processing occurs locally, so no connection is necessary thereafter.
-
Why does the computer take time to make moves? As the AI executes in a local browser, its speed depends on hardware capabilities. Higher difficulty settings involve deeper searches, increasing time. If it's too slow, consider lowering the difficulty.
-
Is the algorithm used in the AI original? The algorithms are not original creations. Most are publicly available, and the project combines them with modest improvements.
Contact Information
For discussions and questions, you can join the QQ group with the ID 622613966
. To enter, use the verification information gobang
.
Update Log
- November 23, 2023: Complete rewrite for V3, simplified code, fixed occasional missteps by the AI, resulting in a more stable play.
- November 29, 2020: Fixed a scoring bug, added a configurable random opening library, and resolved website issues for smoother gameplay.
Tutorial
A series of blog posts is available detailing the step-by-step process of developing a Gobang AI:
- Gobang AI Design Tutorial Part 1: Introduction
- Part 2: The Evolution of Game Algorithms
- Part 3: Minimax Search Algorithm
- Part 4: Alpha-Beta Pruning Algorithm
- Part 5: Heuristic Evaluation Functions
- Part 6: Iterative Deepening
- Part 7: Zobrist Hashing
- Part 8: Checkmate Prediction (Kill Move)
- Part 9: Performance Optimization
It is noted that while there may be differences between the tutorial and repository code, the underlying principles remain consistent. The author aims for a spirit of open sharing and welcomes feedback on any oversights or errors via issues.
Installation Dependencies
This project is a frontend-only setup, with AI written in JavaScript, requiring Node and NPM for local development. Although Node versions haven't been extensively tested, versions v16 to v20 should function correctly.
To begin, run npm install
to install dependencies. Available commands include:
npm start
- Starts the local development servernpm test
- Runs unit testsnpm run js
- Compiles JavaScriptnpm run less
- Compiles LESSnpm run watch
- Initiates watch mode for automatic file compilationnpm run build
- Compiles the project into the dist directory
About the Author
The author is a frontend engineer with experience working at major tech companies like Baidu, Alibaba, and ByteDance. Outside work, he explores various technologies unrelated to his daily tasks.