← Back to full index
# AI Tic-Tac-Toe Game

A Tic-Tac-Toe game with a Tkinter interface, a single-player mode against a minimax AI and a two-player mode, with a persistent scoreboard and data analysis of game results.

- Role: Sole Developer
- Date: Feb 2024 – Mar 2024
- Categories: project
- Tech: Python, Tkinter, Pandas, Matplotlib, CSV
- GitHub: https://github.com/AmulyaJain2004/Tic-Tac-Toe-Game

## Overview

This project implements Tic-Tac-Toe as a desktop application, and uses the small game as a vehicle for practising several fundamentals together: object-oriented design, graphical interfaces, file handling, adversarial search and data analysis.

## Features

- **Two modes:** play against the computer or against another player.
- **AI opponent:** the computer chooses moves with the minimax algorithm, so it never loses a game it can avoid losing.
- **Scoreboard:** results are recorded and tracked across games.
- **Analysis:** game records are stored in CSV files and analysed with pandas, with matplotlib used to visualise the outcomes.

## System Design

```mermaid
flowchart TD
    Menu["TicTacToe<br/>main menu"] --> Mode{"Mode"}
    Mode -->|"single player"| Board["TicTacToeBoard<br/>Tkinter grid of 9 buttons"]
    Mode -->|"multiplayer"| Board
    Board -->|"computer's turn"| AI["min_max()<br/>recursive search over remaining moves"]
    AI --> Board
    Board -->|"game over"| CSV[("scoreboard.csv")]
    Menu --> Scores["Scoreboard<br/>game history"]
    Menu --> Analyzer["DataAnalyzer<br/>pandas + matplotlib pie chart"]
    Scores --> CSV
    Analyzer --> CSV
```

The program is split into four classes. `TicTacToe` is the menu, `TicTacToeBoard` owns the board state, turns and win detection, `Scoreboard` shows past results, and `DataAnalyzer` reads the CSV with pandas and plots win percentages with matplotlib. The board writes each finished game to the shared CSV file, which is the only link between the game and the analysis.

## What It Demonstrates

File handling, object-oriented programming, GUI development with Tkinter, data analysis with pandas and matplotlib, and the implementation of a game-playing algorithm (minimax).

## Status

A small learning project. It is a desktop application and has no hosted demo.

---

Back to the full index: /agent