# rychek4/playerbots architecture

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

- Interactive diagram: https://gitdiagram.com/rychek4/playerbots
- Repository: https://github.com/rychek4/playerbots

## Overview

Playerbots is a CMaNGOS module that creates and operates autonomous player characters, including random world/BG populations and alts directed by player commands. The main behavior loop turns events and strategies into prioritized actions, which act in the game world; specialized systems cover combat, travel, PvE, and item behavior. Separate branches manage bot population and auction-house behavior, while a JSON bridge and LLM interface represent integrations. The README documents major capabilities; unsampled subsystem wiring is represented cautiously rather than as a detailed call graph.

Main entry points: [`playerbot/strategy/actions`](https://github.com/rychek4/playerbots/tree/master/playerbot/strategy/actions) (Game actions), [`playerbot/PlayerbotAI.cpp`](https://github.com/rychek4/playerbots/blob/master/playerbot/PlayerbotAI.cpp) (Playerbot AI), [`playerbot/strategy/Engine.cpp`](https://github.com/rychek4/playerbots/blob/master/playerbot/strategy/Engine.cpp) (Strategy engine), [`playerbot/RandomPlayerbotMgr.cpp`](https://github.com/rychek4/playerbots/blob/master/playerbot/RandomPlayerbotMgr.cpp) (Random bot manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Bot control"]
  node_ai_mgr["Bot manager<br/>[PlayerbotMgr.cpp]"]
  node_ai["Playerbot AI<br/>[PlayerbotAI.cpp]"]
  node_login["Bot login"]
  node_commands["Chat commands"]
end

subgraph group_behavior["AI behavior"]
  node_engine["Strategy engine<br/>[Engine.cpp]"]
  node_reaction["Reaction engine<br/>[ReactionEngine.cpp]"]
  node_strategy["Strategies<br/>[Strategy.cpp]"]
  node_actions["Game actions"]
  node_class_ai["Class strategies"]
end

subgraph group_world["Game activity"]
  node_travel["Travel and maps<br/>[TravelMgr.cpp]"]
  node_flee["Combat movement<br/>[FleeManager.cpp]"]
  node_ah["Auction-house bot<br/>[AhBot.cpp]"]
end

subgraph group_population["Bot population"]
  node_random_mgr["Random bot manager"]
  node_factory["Character factory"]
  node_db[("Bot database access")]
end

subgraph group_integrations["External interfaces"]
  node_bridge["JSON bridge<br/>[BridgeServer.cpp]"]
  node_llm["LLM interface"]
end

node_master(("Player / master"))
node_server(("CMaNGOS world"))
node_bridge_client(("Bridge client"))

node_master -->|"sends commands"| node_commands
node_commands -->|"queues actions"| node_engine
node_ai_mgr -->|"manages bots"| node_ai
node_ai_mgr -->|"requests login"| node_login
node_ai -->|"runs decisions"| node_engine
node_engine -->|"evaluates strategies"| node_strategy
node_engine -->|"dispatches actions"| node_actions
node_reaction -->|"executes reactions"| node_actions
node_class_ai -->|"provides behavior"| node_strategy
node_actions -->|"acts in world"| node_server
node_travel -->|"supports navigation"| node_actions
node_flee -->|"selects destinations"| node_actions
node_random_mgr -->|"generates bots"| node_factory
node_random_mgr -->|"loads bot data"| node_db
node_factory -->|"stores bot data"| node_db
node_random_mgr -->|"populates world"| node_server
node_ah -->|"trades items"| node_server
node_bridge_client -.->|"sends JSON"| node_bridge
node_bridge -.->|"forwards commands"| node_ai
node_ai -.->|"requests responses"| node_llm

click node_ai_mgr "https://github.com/rychek4/playerbots/blob/master/playerbot/PlayerbotMgr.cpp"
click node_ai "https://github.com/rychek4/playerbots/blob/master/playerbot/PlayerbotAI.cpp"
click node_login "https://github.com/rychek4/playerbots/blob/master/playerbot/PlayerbotLoginMgr.cpp"
click node_commands "https://github.com/rychek4/playerbots/blob/master/playerbot/strategy/generic/ChatCommandHandlerStrategy.cpp"
click node_engine "https://github.com/rychek4/playerbots/blob/master/playerbot/strategy/Engine.cpp"
click node_reaction "https://github.com/rychek4/playerbots/blob/master/playerbot/strategy/ReactionEngine.cpp"
click node_strategy "https://github.com/rychek4/playerbots/blob/master/playerbot/strategy/Strategy.cpp"
click node_actions "https://github.com/rychek4/playerbots/tree/master/playerbot/strategy/actions"
click node_class_ai "https://github.com/rychek4/playerbots/tree/master/playerbot/strategy"
click node_travel "https://github.com/rychek4/playerbots/blob/master/playerbot/TravelMgr.cpp"
click node_flee "https://github.com/rychek4/playerbots/blob/master/playerbot/FleeManager.cpp"
click node_ah "https://github.com/rychek4/playerbots/blob/master/ahbot/AhBot.cpp"
click node_random_mgr "https://github.com/rychek4/playerbots/blob/master/playerbot/RandomPlayerbotMgr.cpp"
click node_factory "https://github.com/rychek4/playerbots/blob/master/playerbot/RandomPlayerbotFactory.cpp"
click node_db "https://github.com/rychek4/playerbots/blob/master/playerbot/PlayerbotDbStore.cpp"
click node_bridge "https://github.com/rychek4/playerbots/blob/master/playerbot/bridge/BridgeServer.cpp"
click node_llm "https://github.com/rychek4/playerbots/blob/master/playerbot/PlayerbotLLMInterface.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_ai_mgr,node_ai,node_login,node_commands,node_bridge_client toneBlue
class node_engine,node_reaction,node_strategy,node_actions,node_class_ai toneAmber
class node_travel,node_flee,node_ah toneMint
class node_random_mgr,node_factory,node_db toneRose
class node_bridge,node_llm,node_master,node_server toneIndigo
```

## Components

### Bot control

- [Bot manager](https://github.com/rychek4/playerbots/blob/master/playerbot/PlayerbotMgr.cpp): `playerbot/PlayerbotMgr.cpp`
- [Playerbot AI](https://github.com/rychek4/playerbots/blob/master/playerbot/PlayerbotAI.cpp): `playerbot/PlayerbotAI.cpp`
- [Bot login](https://github.com/rychek4/playerbots/blob/master/playerbot/PlayerbotLoginMgr.cpp): `playerbot/PlayerbotLoginMgr.cpp`
- [Chat commands](https://github.com/rychek4/playerbots/blob/master/playerbot/strategy/generic/ChatCommandHandlerStrategy.cpp): `playerbot/strategy/generic/ChatCommandHandlerStrategy.cpp`

### AI behavior

- [Strategy engine](https://github.com/rychek4/playerbots/blob/master/playerbot/strategy/Engine.cpp): `playerbot/strategy/Engine.cpp`
- [Reaction engine](https://github.com/rychek4/playerbots/blob/master/playerbot/strategy/ReactionEngine.cpp): `playerbot/strategy/ReactionEngine.cpp`
- [Strategies](https://github.com/rychek4/playerbots/blob/master/playerbot/strategy/Strategy.cpp): `playerbot/strategy/Strategy.cpp`
- [Game actions](https://github.com/rychek4/playerbots/tree/master/playerbot/strategy/actions): `playerbot/strategy/actions`
- [Class strategies](https://github.com/rychek4/playerbots/tree/master/playerbot/strategy): `playerbot/strategy`

### Game activity

- [Travel and maps](https://github.com/rychek4/playerbots/blob/master/playerbot/TravelMgr.cpp): `playerbot/TravelMgr.cpp`
- [Combat movement](https://github.com/rychek4/playerbots/blob/master/playerbot/FleeManager.cpp): `playerbot/FleeManager.cpp`
- [Auction-house bot](https://github.com/rychek4/playerbots/blob/master/ahbot/AhBot.cpp): `ahbot/AhBot.cpp`

### Bot population

- [Random bot manager](https://github.com/rychek4/playerbots/blob/master/playerbot/RandomPlayerbotMgr.cpp): `playerbot/RandomPlayerbotMgr.cpp`
- [Character factory](https://github.com/rychek4/playerbots/blob/master/playerbot/RandomPlayerbotFactory.cpp): `playerbot/RandomPlayerbotFactory.cpp`
- [Bot database access](https://github.com/rychek4/playerbots/blob/master/playerbot/PlayerbotDbStore.cpp): `playerbot/PlayerbotDbStore.cpp`

### External interfaces

- [JSON bridge](https://github.com/rychek4/playerbots/blob/master/playerbot/bridge/BridgeServer.cpp): `playerbot/bridge/BridgeServer.cpp`
- [LLM interface](https://github.com/rychek4/playerbots/blob/master/playerbot/PlayerbotLLMInterface.cpp): `playerbot/PlayerbotLLMInterface.cpp`

### Other components

- **Player / master**
- **CMaNGOS world**
- **Bridge client**

## Connections

- Player / master → Chat commands: sends commands
- Chat commands → Strategy engine: queues actions
- Bot manager → Playerbot AI: manages bots
- Bot manager → Bot login: requests login
- Playerbot AI → Strategy engine: runs decisions
- Strategy engine → Strategies: evaluates strategies
- Strategy engine → Game actions: dispatches actions
- Reaction engine → Game actions: executes reactions
- Class strategies → Strategies: provides behavior
- Game actions → CMaNGOS world: acts in world
- Travel and maps → Game actions: supports navigation
- Combat movement → Game actions: selects destinations
- Random bot manager → Character factory: generates bots
- Random bot manager → Bot database access: loads bot data
- Character factory → Bot database access: stores bot data
- Random bot manager → CMaNGOS world: populates world
- Auction-house bot → CMaNGOS world: trades items
- Bridge client → JSON bridge: sends JSON
- JSON bridge → Playerbot AI: forwards commands
- Playerbot AI → LLM interface: requests responses
