# bangtri/gamecaro architecture

> Architecture diagram of the GitHub repository bangtri/gamecaro, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bangtri/gamecaro
- Repository: https://github.com/bangtri/gamecaro

## Overview

GameCaRo is a desktop Caro (five-in-a-row) game. A player selects a cell in the Swing interface; the interface updates the board, checks for a win, and—when it is the AI’s turn—asks the search engine for a move and displays it. The AI evaluates candidate positions and searches board states with alpha-beta pruning. The excerpts show these core interactions; other documented capabilities are not described in the README, so none are inferred.

Main entry points: [`src/gamecaro/AlphaBetaPrunning.java`](https://github.com/bangtri/gamecaro/blob/master/src/gamecaro/AlphaBetaPrunning.java) (Move search), [`src/gamecaro/MainView.java`](https://github.com/bangtri/gamecaro/blob/master/src/gamecaro/MainView.java) (Swing game view), [`src/gamecaro/CaroBoard.java`](https://github.com/bangtri/gamecaro/blob/master/src/gamecaro/CaroBoard.java) (Caro board), [`src/gamecaro/State.java`](https://github.com/bangtri/gamecaro/blob/master/src/gamecaro/State.java) (Move state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Game interface"]
  node_view["Swing game view<br/>[MainView.java]"]
end

subgraph group_game["Game state"]
  node_board["Caro board<br/>[CaroBoard.java]"]
end

subgraph group_ai["AI engine"]
  node_search["Move search"]
  node_state["Move state<br/>[State.java]"]
end

node_player(("Human player"))

node_player -->|"selects move"| node_view
node_view -->|"updates board"| node_board
node_view -->|"requests move"| node_search
node_search -->|"evaluates positions"| node_board
node_search -->|"creates candidates"| node_state
node_search -->|"returns move"| node_view

click node_view "https://github.com/bangtri/gamecaro/blob/master/src/gamecaro/MainView.java"
click node_board "https://github.com/bangtri/gamecaro/blob/master/src/gamecaro/CaroBoard.java"
click node_search "https://github.com/bangtri/gamecaro/blob/master/src/gamecaro/AlphaBetaPrunning.java"
click node_state "https://github.com/bangtri/gamecaro/blob/master/src/gamecaro/State.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_view toneBlue
class node_board toneAmber
class node_search,node_state toneMint
class node_player toneIndigo
```

## Components

### Game interface

- [Swing game view](https://github.com/bangtri/gamecaro/blob/master/src/gamecaro/MainView.java): `src/gamecaro/MainView.java`

### Game state

- [Caro board](https://github.com/bangtri/gamecaro/blob/master/src/gamecaro/CaroBoard.java): `src/gamecaro/CaroBoard.java`

### AI engine

- [Move search](https://github.com/bangtri/gamecaro/blob/master/src/gamecaro/AlphaBetaPrunning.java): `src/gamecaro/AlphaBetaPrunning.java`
- [Move state](https://github.com/bangtri/gamecaro/blob/master/src/gamecaro/State.java): `src/gamecaro/State.java`

### Other components

- **Human player**

## Connections

- Human player → Swing game view: selects move
- Swing game view → Caro board: updates board
- Swing game view → Move search: requests move
- Move search → Caro board: evaluates positions
- Move search → Move state: creates candidates
- Move search → Swing game view: returns move
