# 8altair/tic-tac-toe architecture

> Architecture diagram of the GitHub repository 8altair/tic-tac-toe, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/8altair/tic-tac-toe
- Repository: https://github.com/8altair/tic-tac-toe

## Overview

This is a small Tkinter/CustomTkinter Tic-Tac-Toe game whose main workflow is: the player chooses a symbol, AI mode, and difficulty; plays moves on the board; and receives a win or draw result. The GUI dispatches AI turns to either plain Minimax or alpha-beta search, then uses game rules to evaluate positions and legal moves. Difficulty also affects search depth and move choice. The graph follows the README and shown source; it does not inspect the executable or unsampled source sections.

Main entry points: [`main.py`](https://github.com/8altair/tic-tac-toe/blob/master/main.py) (Board interaction), [`algorithm_functions.py`](https://github.com/8altair/tic-tac-toe/blob/master/algorithm_functions.py) (Minimax search), [`game_functions.py`](https://github.com/8altair/tic-tac-toe/blob/master/game_functions.py) (Board evaluation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gui["Game interface"]
  node_setup["Game setup<br/>[main.py]"]
  node_board["Board interaction<br/>[main.py]"]
  node_results["Game results<br/>[main.py]"]
end

subgraph group_ai["AI opponent"]
  node_move_choice["Move selection"]
  node_search["Minimax search"]
end

subgraph group_rules["Game rules"]
  node_rule_checks["Board evaluation<br/>[game_functions.py]"]
  node_move_order["Move ordering<br/>[game_functions.py]"]
end

node_player(("Player"))

node_player -->|"chooses options"| node_setup
node_player -->|"plays moves"| node_board
node_setup -->|"starts game"| node_board
node_board -->|"requests AI move"| node_move_choice
node_move_choice -->|"scores candidates"| node_search
node_search -->|"evaluates positions"| node_rule_checks
node_search -->|"orders moves"| node_move_order
node_board -->|"checks for moves"| node_rule_checks
node_board -->|"checks winning lines"| node_results
node_results -->|"announces outcome"| node_player

click node_setup "https://github.com/8altair/tic-tac-toe/blob/master/main.py"
click node_board "https://github.com/8altair/tic-tac-toe/blob/master/main.py"
click node_results "https://github.com/8altair/tic-tac-toe/blob/master/main.py"
click node_move_choice "https://github.com/8altair/tic-tac-toe/blob/master/algorithm_functions.py"
click node_search "https://github.com/8altair/tic-tac-toe/blob/master/algorithm_functions.py"
click node_rule_checks "https://github.com/8altair/tic-tac-toe/blob/master/game_functions.py"
click node_move_order "https://github.com/8altair/tic-tac-toe/blob/master/game_functions.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_setup,node_board,node_results toneBlue
class node_move_choice,node_search toneAmber
class node_rule_checks,node_move_order toneMint
class node_player toneIndigo
```

## Components

### Game interface

- [Game setup](https://github.com/8altair/tic-tac-toe/blob/master/main.py): `main.py`
- [Board interaction](https://github.com/8altair/tic-tac-toe/blob/master/main.py): `main.py`
- [Game results](https://github.com/8altair/tic-tac-toe/blob/master/main.py): `main.py`

### AI opponent

- [Move selection](https://github.com/8altair/tic-tac-toe/blob/master/algorithm_functions.py): `algorithm_functions.py`
- [Minimax search](https://github.com/8altair/tic-tac-toe/blob/master/algorithm_functions.py): `algorithm_functions.py`

### Game rules

- [Board evaluation](https://github.com/8altair/tic-tac-toe/blob/master/game_functions.py): `game_functions.py`
- [Move ordering](https://github.com/8altair/tic-tac-toe/blob/master/game_functions.py): `game_functions.py`

### Other components

- **Player**

## Connections

- Player → Game setup: chooses options (evidence: `README.md`)
- Player → Board interaction: plays moves (evidence: `README.md`)
- Game setup → Board interaction: starts game (evidence: `main.py`)
- Board interaction → Move selection: requests AI move (evidence: `main.py`)
- Move selection → Minimax search: scores candidates (evidence: `algorithm_functions.py`)
- Minimax search → Board evaluation: evaluates positions (evidence: `algorithm_functions.py`)
- Minimax search → Move ordering: orders moves (evidence: `algorithm_functions.py`)
- Board interaction → Board evaluation: checks for moves (evidence: `main.py`)
- Board interaction → Game results: checks winning lines (evidence: `main.py`)
- Game results → Player: announces outcome (evidence: `README.md`)
