GitHunt
AR

ari7hkm/tic-tac-toe-ai

Tic-Tac-Toe game with an unbeatable AI using the Minimax algorithm and Pygame

Tic-Tac-Toe AI with Minimax Algorithm

Tic-Tac-Toe AI gameplay demo

An intelligent Tic-Tac-Toe game built using Python and Pygame, featuring an unbeatable AI opponent powered by the Minimax algorithm. The game demonstrates core concepts of game theory, AI search algorithms, and state-based decision-making.


Overview

This project simulates a Tic-Tac-Toe match between a human player and an AI agent.
The AI uses the Minimax Algorithm to evaluate all possible game states and make the optimal move making it impossible to defeat, though draws are possible if you play optimally.


Features

  • Interactive GUI built with Pygame
  • AI implemented using Minimax (no libraries used)
  • Pure game logic functions

How to run

Clone the repository:

git clone https://github.com/ari7hkm/tic-tac-toe-ai.git
cd tic-tac-toe-ai

Install dependencies:

pip install -r requirements.txt

Run the game:

python3 tictactoe.py

Play against the AI - and try not to lose.

Tech Stack

  • Language: Python
  • Libraries: Pygame
  • Algorithm: Minimax (Implemented manually)

Screenshots

Game Start Screen Game in progress

AI thinking

Languages

Python100.0%

Contributors

MIT License
Created October 6, 2025
Updated October 7, 2025