# nhan2892005/gamebot-codingame architecture

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

- Interactive diagram: https://gitdiagram.com/nhan2892005/gamebot-codingame
- Repository: https://github.com/nhan2892005/gamebot-codingame

## Overview

This repository contains three independent game-playing programs: a Ghost in the Cell strategy bot, a Mad Pod Racing bot, and a Tic-Tac-Toe bot. Each reads a game-engine turn, selects actions using game-specific state and strategy, and emits a response. The Ghost bot also models factories, troops, orders, and turn simulation; the other two use checkpoint-based driving logic and board-search logic, respectively. Source excerpts are partial and the READMEs provide no usable architecture detail, so unsampled connections are omitted.

Main entry points: [`MadPodRace/Player.java`](https://github.com/nhan2892005/gamebot-codingame/blob/main/MadPodRace/Player.java) (Player Loop), [`GhostInCell/game.py`](https://github.com/nhan2892005/gamebot-codingame/blob/main/GhostInCell/game.py) (Game Turn Loop), [`Tic-Tac-Toe/main.cpp`](https://github.com/nhan2892005/gamebot-codingame/blob/main/Tic-Tac-Toe/main.cpp) (Game Loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ghost["Ghost Strategy"]
  node_ghost_game["Game Turn Loop<br/>[game.py]"]
  node_ghost_state["Game State<br/>[game.py]"]
  node_ghost_factory["Factory Model<br/>[game.py]"]
  node_ghost_troop["Troop Model<br/>[game.py]"]
  node_ghost_strategy["Order Strategy<br/>[game.py]"]
  node_ghost_sim["Turn Simulation<br/>[game.py]"]
  node_ghost_output["Order Output<br/>[game.py]"]
end

subgraph group_madpod["Pod Racing"]
  node_pod_player["Player Loop<br/>[Player.java]"]
  node_pod_checkpoint["Checkpoint Tracker<br/>[Player.java]"]
  node_pod_safety["Shield Check<br/>[Player.java]"]
  node_pod_action["Driving Action<br/>[Player.java]"]
end

subgraph group_ttt["Tic-Tac-Toe"]
  node_ttt_main["Game Loop<br/>[main.cpp]"]
  node_ttt_board["Board State<br/>[main.cpp]"]
  node_ttt_moves["Move Generation<br/>[main.cpp]"]
  node_ttt_search["Alpha-Beta Search<br/>[main.cpp]"]
  node_ttt_scoring["Position Scoring<br/>[main.cpp]"]
end

node_ghost_engine(("Game Engine"))
node_pod_engine(("Game Engine"))
node_ttt_engine(("Game Engine"))

node_ghost_engine -->|"sends turn"| node_ghost_game
node_ghost_game -->|"updates state"| node_ghost_state
node_ghost_game -->|"selects orders"| node_ghost_strategy
node_ghost_strategy -->|"reads factory data"| node_ghost_factory
node_ghost_strategy -->|"simulates turn"| node_ghost_sim
node_ghost_sim -->|"resolves battles"| node_ghost_factory
node_ghost_sim -->|"tracks troops"| node_ghost_troop
node_ghost_game -->|"prints orders"| node_ghost_output
node_pod_engine -->|"sends turn"| node_pod_player
node_pod_player -->|"tracks checkpoints"| node_pod_checkpoint
node_pod_player -->|"checks collision"| node_pod_safety
node_pod_player -->|"checks boost"| node_pod_checkpoint
node_pod_player -->|"chooses action"| node_pod_action
node_pod_player -->|"prints command"| node_pod_engine
node_ttt_engine -->|"sends turn"| node_ttt_main
node_ttt_main -->|"updates board"| node_ttt_board
node_ttt_main -->|"requests move"| node_ttt_search
node_ttt_search -->|"generates moves"| node_ttt_moves
node_ttt_search -->|"plays moves"| node_ttt_board
node_ttt_search -->|"scores positions"| node_ttt_scoring
node_ttt_main -->|"prints move"| node_ttt_engine

click node_ghost_game "https://github.com/nhan2892005/gamebot-codingame/blob/main/GhostInCell/game.py"
click node_ghost_state "https://github.com/nhan2892005/gamebot-codingame/blob/main/GhostInCell/game.py"
click node_ghost_factory "https://github.com/nhan2892005/gamebot-codingame/blob/main/GhostInCell/game.py"
click node_ghost_troop "https://github.com/nhan2892005/gamebot-codingame/blob/main/GhostInCell/game.py"
click node_ghost_strategy "https://github.com/nhan2892005/gamebot-codingame/blob/main/GhostInCell/game.py"
click node_ghost_sim "https://github.com/nhan2892005/gamebot-codingame/blob/main/GhostInCell/game.py"
click node_ghost_output "https://github.com/nhan2892005/gamebot-codingame/blob/main/GhostInCell/game.py"
click node_pod_player "https://github.com/nhan2892005/gamebot-codingame/blob/main/MadPodRace/Player.java"
click node_pod_checkpoint "https://github.com/nhan2892005/gamebot-codingame/blob/main/MadPodRace/Player.java"
click node_pod_safety "https://github.com/nhan2892005/gamebot-codingame/blob/main/MadPodRace/Player.java"
click node_pod_action "https://github.com/nhan2892005/gamebot-codingame/blob/main/MadPodRace/Player.java"
click node_ttt_main "https://github.com/nhan2892005/gamebot-codingame/blob/main/Tic-Tac-Toe/main.cpp"
click node_ttt_board "https://github.com/nhan2892005/gamebot-codingame/blob/main/Tic-Tac-Toe/main.cpp"
click node_ttt_moves "https://github.com/nhan2892005/gamebot-codingame/blob/main/Tic-Tac-Toe/main.cpp"
click node_ttt_search "https://github.com/nhan2892005/gamebot-codingame/blob/main/Tic-Tac-Toe/main.cpp"
click node_ttt_scoring "https://github.com/nhan2892005/gamebot-codingame/blob/main/Tic-Tac-Toe/main.cpp"

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_ghost_game,node_ghost_state,node_ghost_factory,node_ghost_troop,node_ghost_strategy,node_ghost_sim,node_ghost_output toneBlue
class node_pod_player,node_pod_checkpoint,node_pod_safety,node_pod_action toneAmber
class node_ttt_main,node_ttt_board,node_ttt_moves,node_ttt_search,node_ttt_scoring toneMint
class node_ghost_engine,node_pod_engine,node_ttt_engine toneIndigo
```

## Components

### Ghost Strategy

- [Game Turn Loop](https://github.com/nhan2892005/gamebot-codingame/blob/main/GhostInCell/game.py): `GhostInCell/game.py`
- [Game State](https://github.com/nhan2892005/gamebot-codingame/blob/main/GhostInCell/game.py): `GhostInCell/game.py`
- [Factory Model](https://github.com/nhan2892005/gamebot-codingame/blob/main/GhostInCell/game.py): `GhostInCell/game.py`
- [Troop Model](https://github.com/nhan2892005/gamebot-codingame/blob/main/GhostInCell/game.py): `GhostInCell/game.py`
- [Order Strategy](https://github.com/nhan2892005/gamebot-codingame/blob/main/GhostInCell/game.py): `GhostInCell/game.py`
- [Turn Simulation](https://github.com/nhan2892005/gamebot-codingame/blob/main/GhostInCell/game.py): `GhostInCell/game.py`
- [Order Output](https://github.com/nhan2892005/gamebot-codingame/blob/main/GhostInCell/game.py): `GhostInCell/game.py`

### Pod Racing

- [Player Loop](https://github.com/nhan2892005/gamebot-codingame/blob/main/MadPodRace/Player.java): `MadPodRace/Player.java`
- [Checkpoint Tracker](https://github.com/nhan2892005/gamebot-codingame/blob/main/MadPodRace/Player.java): `MadPodRace/Player.java`
- [Shield Check](https://github.com/nhan2892005/gamebot-codingame/blob/main/MadPodRace/Player.java): `MadPodRace/Player.java`
- [Driving Action](https://github.com/nhan2892005/gamebot-codingame/blob/main/MadPodRace/Player.java): `MadPodRace/Player.java`

### Tic-Tac-Toe

- [Game Loop](https://github.com/nhan2892005/gamebot-codingame/blob/main/Tic-Tac-Toe/main.cpp): `Tic-Tac-Toe/main.cpp`
- [Board State](https://github.com/nhan2892005/gamebot-codingame/blob/main/Tic-Tac-Toe/main.cpp): `Tic-Tac-Toe/main.cpp`
- [Move Generation](https://github.com/nhan2892005/gamebot-codingame/blob/main/Tic-Tac-Toe/main.cpp): `Tic-Tac-Toe/main.cpp`
- [Alpha-Beta Search](https://github.com/nhan2892005/gamebot-codingame/blob/main/Tic-Tac-Toe/main.cpp): `Tic-Tac-Toe/main.cpp`
- [Position Scoring](https://github.com/nhan2892005/gamebot-codingame/blob/main/Tic-Tac-Toe/main.cpp): `Tic-Tac-Toe/main.cpp`

### Other components

- **Game Engine**
- **Game Engine**
- **Game Engine**

## Connections

- Game Engine → Game Turn Loop: sends turn (evidence: `GhostInCell/game.py`)
- Game Turn Loop → Game State: updates state (evidence: `GhostInCell/game.py`)
- Game Turn Loop → Order Strategy: selects orders (evidence: `GhostInCell/game.py`)
- Order Strategy → Factory Model: reads factory data (evidence: `GhostInCell/game.py`)
- Order Strategy → Turn Simulation: simulates turn (evidence: `GhostInCell/game.py`)
- Turn Simulation → Factory Model: resolves battles (evidence: `GhostInCell/game.py`)
- Turn Simulation → Troop Model: tracks troops (evidence: `GhostInCell/game.py`)
- Game Turn Loop → Order Output: prints orders (evidence: `GhostInCell/game.py`)
- Game Engine → Player Loop: sends turn (evidence: `MadPodRace/Player.java`)
- Player Loop → Checkpoint Tracker: tracks checkpoints (evidence: `MadPodRace/Player.java`)
- Player Loop → Shield Check: checks collision (evidence: `MadPodRace/Player.java`)
- Player Loop → Checkpoint Tracker: checks boost (evidence: `MadPodRace/Player.java`)
- Player Loop → Driving Action: chooses action (evidence: `MadPodRace/Player.java`)
- Player Loop → Game Engine: prints command (evidence: `MadPodRace/Player.java`)
- Game Engine → Game Loop: sends turn (evidence: `Tic-Tac-Toe/main.cpp`)
- Game Loop → Board State: updates board (evidence: `Tic-Tac-Toe/main.cpp`)
- Game Loop → Alpha-Beta Search: requests move (evidence: `Tic-Tac-Toe/main.cpp`)
- Alpha-Beta Search → Move Generation: generates moves (evidence: `Tic-Tac-Toe/main.cpp`)
- Alpha-Beta Search → Board State: plays moves (evidence: `Tic-Tac-Toe/main.cpp`)
- Alpha-Beta Search → Position Scoring: scores positions (evidence: `Tic-Tac-Toe/main.cpp`)
- Game Loop → Game Engine: prints move (evidence: `Tic-Tac-Toe/main.cpp`)
