# massa7ca/tic-tac-toe-minimax-alpha-beta architecture

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

- Interactive diagram: https://gitdiagram.com/massa7ca/tic-tac-toe-minimax-alpha-beta
- Repository: https://github.com/massa7ca/tic-tac-toe-minimax-alpha-beta

## Overview

This is a Java Swing tic-tac-toe game with configurable board and win length, where a player interacts with the board and the game asks a minimax alpha-beta AI to choose moves. The Game component builds winning combinations, tracks and draws the board, and dispatches moves to the AI; the AI evaluates positions using Score and caches states with ByteArray keys. The README gives no further capability details. Relationships shown are limited to calls and construction visible in the supplied source excerpts.

Main entry points: [`src/com/company/Ai.java`](https://github.com/massa7ca/tic-tac-toe-minimax-alpha-beta/blob/master/src/com/company/Ai.java) (Minimax search), [`src/com/company/Game.java`](https://github.com/massa7ca/tic-tac-toe-minimax-alpha-beta/blob/master/src/com/company/Game.java) (Board and input), [`src/com/company/Main.java`](https://github.com/massa7ca/tic-tac-toe-minimax-alpha-beta/blob/master/src/com/company/Main.java) (Launcher), [`src/com/company/Utils.java`](https://github.com/massa7ca/tic-tac-toe-minimax-alpha-beta/blob/master/src/com/company/Utils.java) (Array helpers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Game application"]
  node_main["Launcher<br/>[Main.java]"]
  node_game["Board and input<br/>[Game.java]"]
end

subgraph group_ai["AI search"]
  node_ai_engine["Minimax search<br/>[Ai.java]"]
  node_scoring["Position scoring<br/>[Score.java]"]
end

subgraph group_support["Search support"]
  node_state_key["State key<br/>[ByteArray.java]"]
  node_utils["Array helpers<br/>[Utils.java]"]
end

node_player(("Player"))

node_player -->|"starts game"| node_main
node_player -->|"clicks board"| node_game
node_main -->|"creates"| node_game
node_game -->|"requests move"| node_ai_engine
node_game -->|"converts combinations"| node_utils
node_ai_engine -->|"evaluates positions"| node_scoring
node_ai_engine -->|"wraps board state"| node_state_key
node_ai_engine -->|"removes rows"| node_utils

click node_main "https://github.com/massa7ca/tic-tac-toe-minimax-alpha-beta/blob/master/src/com/company/Main.java"
click node_game "https://github.com/massa7ca/tic-tac-toe-minimax-alpha-beta/blob/master/src/com/company/Game.java"
click node_ai_engine "https://github.com/massa7ca/tic-tac-toe-minimax-alpha-beta/blob/master/src/com/company/Ai.java"
click node_scoring "https://github.com/massa7ca/tic-tac-toe-minimax-alpha-beta/blob/master/src/com/company/Score.java"
click node_state_key "https://github.com/massa7ca/tic-tac-toe-minimax-alpha-beta/blob/master/src/com/company/ByteArray.java"
click node_utils "https://github.com/massa7ca/tic-tac-toe-minimax-alpha-beta/blob/master/src/com/company/Utils.java"

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_main,node_game toneBlue
class node_ai_engine,node_scoring toneAmber
class node_state_key,node_utils toneMint
class node_player toneIndigo
```

## Components

### Game application

- [Launcher](https://github.com/massa7ca/tic-tac-toe-minimax-alpha-beta/blob/master/src/com/company/Main.java): `src/com/company/Main.java`
- [Board and input](https://github.com/massa7ca/tic-tac-toe-minimax-alpha-beta/blob/master/src/com/company/Game.java): `src/com/company/Game.java`

### AI search

- [Minimax search](https://github.com/massa7ca/tic-tac-toe-minimax-alpha-beta/blob/master/src/com/company/Ai.java): `src/com/company/Ai.java`
- [Position scoring](https://github.com/massa7ca/tic-tac-toe-minimax-alpha-beta/blob/master/src/com/company/Score.java): `src/com/company/Score.java`

### Search support

- [State key](https://github.com/massa7ca/tic-tac-toe-minimax-alpha-beta/blob/master/src/com/company/ByteArray.java): `src/com/company/ByteArray.java`
- [Array helpers](https://github.com/massa7ca/tic-tac-toe-minimax-alpha-beta/blob/master/src/com/company/Utils.java): `src/com/company/Utils.java`

### Other components

- **Player**

## Connections

- Player → Launcher: starts game (evidence: `src/com/company/Main.java`)
- Player → Board and input: clicks board (evidence: `src/com/company/Game.java`)
- Launcher → Board and input: creates (evidence: `src/com/company/Main.java`)
- Board and input → Minimax search: requests move (evidence: `src/com/company/Game.java`)
- Board and input → Array helpers: converts combinations (evidence: `src/com/company/Game.java`)
- Minimax search → Position scoring: evaluates positions (evidence: `src/com/company/Ai.java`)
- Minimax search → State key: wraps board state (evidence: `src/com/company/Ai.java`)
- Minimax search → Array helpers: removes rows (evidence: `src/com/company/Ai.java`)
