Skip to content

Unbeatable Tic Tac Toe AI (MCTS, minimax) built in Rust.

Notifications You must be signed in to change notification settings

0xTijan/tic-tac-toe-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Tic Tac Toe AI

A command-line (unbeatable) Tic Tac Toe AI game implemented in Rust. This project offers multiple game play modes, including AI algorithms like Minimax and Monte Carlo Tree Search (MCTS).

Table of Contents

Section Description
Features Overview of game modes and AI
Installation How to install and run the game
Game Modes Explanation of different game modes
AI Algorithms Summary of Minimax & MCTS
Gallery Screenshot of the game
Resources Useful links for AI learning
Contact Get in touch with the developer

Features

  • Multiplayer: Play against another human.
  • Basic Bot: Bot plays immediate wins.
  • Minimax AI: Uses the Minimax algorithm to play optimally.
  • MCTS AI: Uses Monte Carlo Tree Search for decision-making.

Installation 🚀

Clone the repository and build the project:

git clone https://github.com/0xTijan/tic-tac-toe-ai.git
cd tic-tac-toe-ai
cargo build

Run the game:

cargo run

Game Modes 🎮

1. Multiplayer

Two players take turns on the same terminal.

2. Basic Bot

The bot takes opportunities for immediate wins and blocks the opponent's immediate wins; otherwise, it plays randomly.

3. Minimax AI

A strategy-based AI that always plays optimally by evaluating the best possible move using the Minimax algorithm.

4. Monte Carlo Tree Search (MCTS) AI

An AI that uses Monte Carlo simulations to determine the best move. It balances exploration and exploitation to refine its strategy.

AI Algorithms

Minimax

The Minimax algorithm evaluates all possible moves, selecting the one that maximizes the AI’s chance of winning while minimizing the opponent’s best options. It guarantees perfect play but can be computationally expensive.

👉 Full explanation in ./minimax.md.

Monte Carlo Tree Search (MCTS)

Unlike Minimax, MCTS uses simulations to statistically determine the best move, making it effective for large game spaces.

👉 Full breakdown in ./mcts.md.

Gallery

game

Resources

Contact

For questions or suggestions, reach out via GitHub or email at tijan@tijan.dev or visit my website.

About

Unbeatable Tic Tac Toe AI (MCTS, minimax) built in Rust.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages