Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dleedev365/ai-tic-tac-toe-pmcts
A console game that allows a human player to play against a computer whose decisions are based on pure Monte Carlo Tree Search algorithm
https://github.com/dleedev365/ai-tic-tac-toe-pmcts
artifical-intelligense game monte-carlo-tree-search python3 tic-tac-toe
Last synced: 10 days ago
JSON representation
A console game that allows a human player to play against a computer whose decisions are based on pure Monte Carlo Tree Search algorithm
- Host: GitHub
- URL: https://github.com/dleedev365/ai-tic-tac-toe-pmcts
- Owner: dleedev365
- Created: 2019-07-10T04:35:38.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-22T22:03:28.000Z (over 4 years ago)
- Last Synced: 2024-03-23T00:52:03.773Z (8 months ago)
- Topics: artifical-intelligense, game, monte-carlo-tree-search, python3, tic-tac-toe
- Language: Python
- Homepage:
- Size: 356 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Purpose
To design an AI program that makes its moves based on pure Monte Carlo Tree Search algorithm against dumb-to-smart players# Technologies
- Python3# Process
### Step 1: The Language of ChoicePython has a great community support for Artificial Intelligence libraries and many other benefits Artificial Intelligence development such as:
- consistency and simple syntax
- extensive selection of libraries and frameworks
- Platform independence
- Great community and popularityWith these benefits in mind, I chose python3 for this project.
### Step 2: The Understanding of Algorithm
Before implementing algorithm, I needed to understand the logic of pure Monte Carlo Tree Search. The pMCTS basically says, for each move, all feasible moves are determined: k random games are played out to the very end, and the scores are recorded. The move leading to the best score is chosen. Ties are broken by fair coin flips. The challenging part is to find the minimum number of play-outs that guarantees 100% win rate or draw, but no loss, against a smart player.
### Step 3: The Implementation
Coding was fairly straight-forward although time complexity and data structures needed to be carefully chosen. Based on the understanding of the algorithm, I found that there always has to be a new move recorded in the gameboard and checked before either a human player or computer decides the next move. Therefore, python dictionary met this need and the algorithm was designed in O(N^2) because each column of rows or row of columns needs to be checked every time a new move is made.
- [View Source Code](/game.py.py)
### Step 4: Final Result & ReflectionAs a result, my AI program guarantees 100% win rate or draw if the number of playouts (simulates games itself given a move) exceeds to 300 playouts which takes about maximum 5 seconds to decide a move.From this project, I learned that algorithm design with respect to time complexity is crucial for real-time applications and it was fun to learn a basic AI algorithm for the first time!