# a-eloiza/jogodaonca architecture

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

- Interactive diagram: https://gitdiagram.com/a-eloiza/jogodaonca
- Repository: https://github.com/a-eloiza/jogodaonca

## Overview

jogoDaOnca implements the Jogo da Onça board game, with a Redis-backed controller coordinating players and an AI player using minimax search. The main runtime loop sends the current game state to the active side, receives a move, validates and applies it, then checks for a winner and advances the turn. The game module also handles move generation and message formatting; the AI evaluates candidate moves using a heuristic. The excerpts show Redis list operations and the main calls, but do not establish how example clients are used.

Main entry points: [`src/jogo/jogo.c`](https://github.com/a-eloiza/jogodaonca/blob/main/src/jogo/jogo.c) (Rules and moves), [`src/jogador.c`](https://github.com/a-eloiza/jogodaonca/blob/main/src/jogador.c) (AI player), [`src/minimax/minimax.c`](https://github.com/a-eloiza/jogodaonca/blob/main/src/minimax/minimax.c) (Minimax search), [`src/controlador.c`](https://github.com/a-eloiza/jogodaonca/blob/main/src/controlador.c) (Game controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_coordination["Game coordination"]
  node_controller["Game controller<br/>[controlador.c]"]
end

subgraph group_client["Player client"]
  node_player["AI player<br/>[jogador.c]"]
  node_transport["Board transport<br/>[tabuleiro.c]"]
end

subgraph group_rules["Game rules"]
  node_game["Rules and moves<br/>[jogo.c]"]
end

subgraph group_ai["AI strategy"]
  node_search["Minimax search<br/>[minimax.c]"]
  node_heuristic["Position heuristic<br/>[heuristica.c]"]
end

node_redis["Redis lists"]

node_controller -->|"reads and writes"| node_redis
node_controller -->|"validates and applies"| node_game
node_player -->|"exchanges state"| node_transport
node_transport -->|"reads and writes"| node_redis
node_player -->|"parses and formats"| node_game
node_player -->|"selects move"| node_search
node_search -->|"generates and applies"| node_game
node_search -->|"scores positions"| node_heuristic
node_heuristic -->|"counts generated moves"| node_game

click node_controller "https://github.com/a-eloiza/jogodaonca/blob/main/src/controlador.c"
click node_player "https://github.com/a-eloiza/jogodaonca/blob/main/src/jogador.c"
click node_transport "https://github.com/a-eloiza/jogodaonca/blob/main/src/tabuleiro/tabuleiro.c"
click node_game "https://github.com/a-eloiza/jogodaonca/blob/main/src/jogo/jogo.c"
click node_search "https://github.com/a-eloiza/jogodaonca/blob/main/src/minimax/minimax.c"
click node_heuristic "https://github.com/a-eloiza/jogodaonca/blob/main/src/heuristica/heuristica.c"

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_controller toneBlue
class node_player,node_transport,node_redis toneAmber
class node_game toneMint
class node_search,node_heuristic toneRose
```

## Components

### Game coordination

- [Game controller](https://github.com/a-eloiza/jogodaonca/blob/main/src/controlador.c): `src/controlador.c`

### Player client

- [AI player](https://github.com/a-eloiza/jogodaonca/blob/main/src/jogador.c): `src/jogador.c`
- [Board transport](https://github.com/a-eloiza/jogodaonca/blob/main/src/tabuleiro/tabuleiro.c): `src/tabuleiro/tabuleiro.c`

### Game rules

- [Rules and moves](https://github.com/a-eloiza/jogodaonca/blob/main/src/jogo/jogo.c): `src/jogo/jogo.c`

### AI strategy

- [Minimax search](https://github.com/a-eloiza/jogodaonca/blob/main/src/minimax/minimax.c): `src/minimax/minimax.c`
- [Position heuristic](https://github.com/a-eloiza/jogodaonca/blob/main/src/heuristica/heuristica.c): `src/heuristica/heuristica.c`

### Other components

- **Redis lists**

## Connections

- Game controller → Redis lists: reads and writes (evidence: `src/controlador.c`)
- Game controller → Rules and moves: validates and applies (evidence: `src/controlador.c`)
- AI player → Board transport: exchanges state (evidence: `src/jogador.c`)
- Board transport → Redis lists: reads and writes (evidence: `src/tabuleiro/tabuleiro.c`)
- AI player → Rules and moves: parses and formats (evidence: `src/jogador.c`)
- AI player → Minimax search: selects move (evidence: `src/jogador.c`)
- Minimax search → Rules and moves: generates and applies (evidence: `src/minimax/minimax.c`)
- Minimax search → Position heuristic: scores positions (evidence: `src/minimax/minimax.c`)
- Position heuristic → Rules and moves: counts generated moves (evidence: `src/heuristica/heuristica.c`)
