Tic tac toe, unbeatable minimax
š® Tic Tac Toe AI
Tic Tac Toe with Player vs Player & Player vs AI mode. AI uses Minimax for perfect play.

Documentation
š® Tic Tac Toe AI (with Minimax) using Pygame
This project is a Tic Tac Toe game implemented in Python using Pygame, with support for both Player vs Player and Player vs AI modes. The AI uses the Minimax algorithm for perfect play.

š Features
- āļø Single-player vs AI with difficulty levels:
- Level 0: Random moves
- Level 1: Minimax AI (unbeatable)
- š§ Minimax algorithm implementation with recursive backtracking
- š® Player vs Player mode
- š Reset and game mode toggle with keyboard
- š¼ļø Graphical interface using
pygame
š ļø Installation
Requirements
- Python 3.6+
- Pygame
- NumPy
Install dependencies
pip install pygame numpy
ā¶ļø Run the Game
python main.py
Make sure you have all necessary files including
constants.py.
š® Controls
| Action | Key/Mouse |
|---|---|
| Make a move | Mouse click |
| Reset the game | R |
| Toggle game mode (PvP/AI) | G |
| Set AI to random mode | 0 |
| Set AI to minimax mode | 1 |
š§ AI Logic
The AI uses a classic Minimax algorithm that:
- Evaluates all possible moves recursively
- Chooses the move with the highest score (maximizing for AI, minimizing for player)
- Always plays optimally
š File Structure
.
āāā main.py # Main game logic
āāā constants.py # UI and game settings (colors, sizes)
āāā images/
ā āāā screenshot.png # Screenshot of the game (optional)
āāā README.md
š§āš» Author
Made by Hitesh-s0lanki. Feel free to fork and enhance!
š License
This project is licensed under the MIT License. See LICENSE for details.
Keep exploring
Related work

Agent AI Use-cases Example
A Streamlit-powered application showcasing multiple agentic AI use cases using LangGraph, Tavily, OpenAI, Groq, and LangChain.

ReAct Agent
This project demonstrates a ReAct (Reason + Act) agent implemented using LangChain, integrated with real-world tools like Arxiv, Wikipedia, and Tavily to search, reason, and respond to complex user queries.

āļø Chess (Python + Pygame)
A visually interactive chess engine with drag-and-drop movement and theming.