# basilbarakat15/tic-tac-toe-ai-with-alpha-beta-and-evaluation-modes architecture

> Architecture diagram of the GitHub repository basilbarakat15/tic-tac-toe-ai-with-alpha-beta-and-evaluation-modes, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/basilbarakat15/tic-tac-toe-ai-with-alpha-beta-and-evaluation-modes
- Repository: https://github.com/basilbarakat15/tic-tac-toe-ai-with-alpha-beta-and-evaluation-modes

## Overview

This is a desktop Tic-Tac-Toe game with a human-facing Tkinter GUI and an AI opponent. The principal workflow is selecting a side, difficulty, and evaluation mode, then playing moves against the AI and seeing move scores. The AI supports random easy moves or alpha-beta search with heuristic or ML evaluation; the README also describes dataset-based RandomForest training. The tree lists test2.py as the core module, although the README says to run test.py. The app is monolithic; some GUI-to-AI and ML-training wiring is documented but not visible in the excerpts.

Main entry points: [`test2.py`](https://github.com/basilbarakat15/tic-tac-toe-ai-with-alpha-beta-and-evaluation-modes/blob/main/test2.py) (Game GUI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Game interaction"]
  node_gui["Game GUI<br/>[test2.py]"]
  node_board["Board state<br/>[test2.py]"]
end

subgraph group_strategy["AI strategy"]
  node_ai_move["AI move selection<br/>[test2.py]"]
  node_search["Alpha-beta search<br/>[test2.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_heuristic["Heuristic evaluation<br/>[test2.py]"]
  node_features["ML features<br/>[test2.py]"]
  node_ml_model["RandomForest model<br/>[test2.py]"]
  node_dataset["Training dataset"]
end

node_player(("Human player"))

node_player -->|"selects and plays"| node_gui
node_gui -->|"records moves"| node_board
node_gui -.->|"requests AI move"| node_ai_move
node_ai_move -->|"searches moves"| node_search
node_search -->|"evaluates states"| node_heuristic
node_search -.->|"evaluates states"| node_ml_model
node_ml_model -->|"predicts from"| node_features
node_features -->|"reads position"| node_board
node_dataset -.->|"trains model"| node_ml_model

click node_gui "https://github.com/basilbarakat15/tic-tac-toe-ai-with-alpha-beta-and-evaluation-modes/blob/main/test2.py"
click node_board "https://github.com/basilbarakat15/tic-tac-toe-ai-with-alpha-beta-and-evaluation-modes/blob/main/test2.py"
click node_ai_move "https://github.com/basilbarakat15/tic-tac-toe-ai-with-alpha-beta-and-evaluation-modes/blob/main/test2.py"
click node_search "https://github.com/basilbarakat15/tic-tac-toe-ai-with-alpha-beta-and-evaluation-modes/blob/main/test2.py"
click node_heuristic "https://github.com/basilbarakat15/tic-tac-toe-ai-with-alpha-beta-and-evaluation-modes/blob/main/test2.py"
click node_features "https://github.com/basilbarakat15/tic-tac-toe-ai-with-alpha-beta-and-evaluation-modes/blob/main/test2.py"
click node_ml_model "https://github.com/basilbarakat15/tic-tac-toe-ai-with-alpha-beta-and-evaluation-modes/blob/main/test2.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_gui,node_board toneBlue
class node_ai_move,node_search toneAmber
class node_heuristic,node_features,node_ml_model,node_dataset toneMint
class node_player toneIndigo
```

## Components

### Game interaction

- [Game GUI](https://github.com/basilbarakat15/tic-tac-toe-ai-with-alpha-beta-and-evaluation-modes/blob/main/test2.py): `test2.py`
- [Board state](https://github.com/basilbarakat15/tic-tac-toe-ai-with-alpha-beta-and-evaluation-modes/blob/main/test2.py): `test2.py`

### AI strategy

- [AI move selection](https://github.com/basilbarakat15/tic-tac-toe-ai-with-alpha-beta-and-evaluation-modes/blob/main/test2.py): `test2.py`
- [Alpha-beta search](https://github.com/basilbarakat15/tic-tac-toe-ai-with-alpha-beta-and-evaluation-modes/blob/main/test2.py): `test2.py`

### Evaluation

- [Heuristic evaluation](https://github.com/basilbarakat15/tic-tac-toe-ai-with-alpha-beta-and-evaluation-modes/blob/main/test2.py): `test2.py`
- [ML features](https://github.com/basilbarakat15/tic-tac-toe-ai-with-alpha-beta-and-evaluation-modes/blob/main/test2.py): `test2.py`
- [RandomForest model](https://github.com/basilbarakat15/tic-tac-toe-ai-with-alpha-beta-and-evaluation-modes/blob/main/test2.py): `test2.py`
- **Training dataset**

### Other components

- **Human player**

## Connections

- Human player → Game GUI: selects and plays (evidence: `README.md`)
- Game GUI → Board state: records moves (evidence: `test2.py`)
- Game GUI → AI move selection: requests AI move (evidence: `test2.py`)
- AI move selection → Alpha-beta search: searches moves (evidence: `test2.py`)
- Alpha-beta search → Heuristic evaluation: evaluates states (evidence: `test2.py`)
- Alpha-beta search → RandomForest model: evaluates states (evidence: `test2.py`)
- RandomForest model → ML features: predicts from (evidence: `test2.py`)
- ML features → Board state: reads position (evidence: `test2.py`)
- Training dataset → RandomForest model: trains model (evidence: `README.md`)
