Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mathieucaroff/gomoku
A Gomoku AI
https://github.com/mathieucaroff/gomoku
ai gomoku heuristics
Last synced: 5 days ago
JSON representation
A Gomoku AI
- Host: GitHub
- URL: https://github.com/mathieucaroff/gomoku
- Owner: mathieucaroff
- Created: 2022-07-14T00:45:51.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-01-20T18:51:24.000Z (10 months ago)
- Last Synced: 2024-04-28T04:45:56.793Z (7 months ago)
- Topics: ai, gomoku, heuristics
- Language: TypeScript
- Homepage: https://mathieucaroff.com/gomoku
- Size: 284 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# [Gomoku AI](https://gomokuai.vercel.app/)
Play gomoku against an AI [by clicking this link](https://gomokuai.vercel.app/).
## Alternative configurations
- [You play first](https://gomokuai.vercel.app/)
- [The AI plays first](https://gomokuai.vercel.app/?versus=aiHuman)
- [Two AIs play against one another](https://gomokuai.vercel.app/?versus=aiAi)
- [Two AIs play against one another but fast](https://gomokuai.vercel.app/?versus=aiAi&timeout=0)
- [You play first and the AI is too defensive](https://gomokuai.vercel.app/?defensive)## AI algorithms
### Basic AI One
The underlying principles of the Basic AI One are simple:
- Identify all the groups of five aligned positions in the board, be it a vertical, horizontal or diagonal alignment.
- For each color, figure out all the lines of five, four, three, two and one piece-s of that color which do not contain the other color
- Play at the place of greatest priority.The priority of a position is a nine-uplet i.e. a series of ten numbers. The first is the number of lines of five that would be **completed** by playing there. The second is the number of lines of five that would be **prevented** by playing there. The third is the number of lines of four that would be completed. The fourth is the number of lines of four that would be prevented, and so on till the ninth.
### Basic AI Two
The Basic AI Two addresses an issue with the Basic AI One where it would play to extend a semi-blocked line of two pieces into a line of three pieces, when it should have played to prevent the opponent from getting a pair of three-pieces unblocked alignments. This behaviour is obtained by merging two priority levels for alignments of one or two pieces: the priority for extending our lines is no longer superior to the priority for blocking the opponent.
The Basic AI Two wins more than 80% of the games against the Basic AI One when playing second, and more than 90% of them when playing first. Indeed, Basic AI Two lost one game in a batch of eleven.
### PVS
The PVS algorithm implemented in this game relies on a "Basic AI" as an heuristics which tells them in what order the moves should be examined. When the depth limit is reach, the Heuristic used to measure the value of a position is based on the outcome of the game: "loose", "draw" or "win", as well as the number of moves it took to reach that outcome. If the outcome is a draw, the position scores 0. If the outcome is a win, the position scores `2 ** (412 - (number of half-moves))`.