# tagadanar/tagadalive architecture

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

- Interactive diagram: https://gitdiagram.com/tagadanar/tagadalive
- Repository: https://github.com/tagadanar/tagadalive

## Overview

TAGADALIVE is a LeekScript combat AI for LeekWars, with selectable search modes that evaluate battle states and actions. A companion Tampermonkey analyzer visualizes fight logs, algorithm statistics, charts, and profiling information. The README documents the AI’s high-level dispatch and modeling layers; sampled browser-script excerpts show log acquisition, caching, parsing, and rendering behavior. Some connections are omitted because the AI implementation and parts of the analyzer were not sampled.

Main entry points: [`AI/Algorithms`](https://github.com/tagadanar/tagadalive/tree/master/AI/Algorithms) (Search algorithms), [`tampermonkey/lwa-core.user.js`](https://github.com/tagadanar/tagadalive/blob/master/tampermonkey/lwa-core.user.js) (Analyzer state), [`tampermonkey/lwa-main.user.js`](https://github.com/tagadanar/tagadalive/blob/master/tampermonkey/lwa-main.user.js) (Analyzer orchestration), [`tampermonkey/lwa-ui.user.js`](https://github.com/tagadanar/tagadalive/blob/master/tampermonkey/lwa-ui.user.js) (Analyzer panel)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_combat["Combat AI"]
  node_entry["Mode entry"]
  node_dispatcher["AI dispatcher"]
  node_search["Search algorithms"]
end

subgraph group_evaluation["Battle Evaluation"]
  node_battle["Battle state"]
  node_model["Game and combo model"]
  node_controllers["Fight and map control"]
  node_scoring["Scoring knowledge"]
end

subgraph group_analyzer["Fight Analyzer"]
  node_orchestrator["Analyzer orchestration<br/>[lwa-main.user.js]"]
  node_cache[("Fight log cache<br/>[lwa-core.user.js]")]
  node_parser["Log parser and stats<br/>[lwa-parser.user.js]"]
  node_state["Analyzer state<br/>[lwa-core.user.js]"]
end

subgraph group_visuals["Analysis Views"]
  node_ui["Analyzer panel<br/>[lwa-ui.user.js]"]
  node_charts["Charts and anomalies<br/>[lwa-charts.user.js]"]
  node_styles["Panel styling<br/>[lwa-styles.user.js]"]
end

node_player(("LeekWars player"))
node_page["LeekWars fight page"]

node_player -->|"selects mode"| node_entry
node_entry -->|"dispatches to"| node_dispatcher
node_dispatcher -->|"chooses search"| node_search
node_search -->|"uses battle state"| node_battle
node_search -->|"evaluates actions"| node_model
node_search -->|"uses controllers"| node_controllers
node_search -->|"scores choices"| node_scoring
node_page -->|"provides fight page"| node_orchestrator
node_orchestrator -->|"checks and loads"| node_cache
node_orchestrator -.->|"updates analyzer state"| node_state
node_parser -->|"reads turn data"| node_state
node_ui -->|"reads settings and state"| node_state
node_charts -->|"reads turn data"| node_state
node_ui -.->|"renders charts"| node_charts
node_styles -.->|"styles panel"| node_ui

click node_entry "https://github.com/tagadanar/tagadalive/blob/master/main"
click node_dispatcher "https://github.com/tagadanar/tagadalive/blob/master/AI/AI"
click node_search "https://github.com/tagadanar/tagadalive/tree/master/AI/Algorithms"
click node_battle "https://github.com/tagadanar/tagadalive/blob/master/Controlers/BattleState"
click node_model "https://github.com/tagadanar/tagadalive/tree/master/Model"
click node_controllers "https://github.com/tagadanar/tagadalive/tree/master/Controlers"
click node_scoring "https://github.com/tagadanar/tagadalive/blob/master/HiddenKnowledges/Scoring"
click node_orchestrator "https://github.com/tagadanar/tagadalive/blob/master/tampermonkey/lwa-main.user.js"
click node_cache "https://github.com/tagadanar/tagadalive/blob/master/tampermonkey/lwa-core.user.js"
click node_parser "https://github.com/tagadanar/tagadalive/blob/master/tampermonkey/lwa-parser.user.js"
click node_state "https://github.com/tagadanar/tagadalive/blob/master/tampermonkey/lwa-core.user.js"
click node_ui "https://github.com/tagadanar/tagadalive/blob/master/tampermonkey/lwa-ui.user.js"
click node_charts "https://github.com/tagadanar/tagadalive/blob/master/tampermonkey/lwa-charts.user.js"
click node_styles "https://github.com/tagadanar/tagadalive/blob/master/tampermonkey/lwa-styles.user.js"

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_entry,node_dispatcher,node_search toneBlue
class node_battle,node_model,node_controllers,node_scoring toneAmber
class node_orchestrator,node_cache,node_parser,node_state toneMint
class node_ui,node_charts,node_styles toneRose
class node_player,node_page toneIndigo
```

## Components

### Combat AI

- [Mode entry](https://github.com/tagadanar/tagadalive/blob/master/main): `main`
- [AI dispatcher](https://github.com/tagadanar/tagadalive/blob/master/AI/AI): `AI/AI`
- [Search algorithms](https://github.com/tagadanar/tagadalive/tree/master/AI/Algorithms): `AI/Algorithms`

### Battle Evaluation

- [Battle state](https://github.com/tagadanar/tagadalive/blob/master/Controlers/BattleState): `Controlers/BattleState`
- [Game and combo model](https://github.com/tagadanar/tagadalive/tree/master/Model): `Model`
- [Fight and map control](https://github.com/tagadanar/tagadalive/tree/master/Controlers): `Controlers`
- [Scoring knowledge](https://github.com/tagadanar/tagadalive/blob/master/HiddenKnowledges/Scoring): `HiddenKnowledges/Scoring`

### Fight Analyzer

- [Analyzer orchestration](https://github.com/tagadanar/tagadalive/blob/master/tampermonkey/lwa-main.user.js): `tampermonkey/lwa-main.user.js`
- [Fight log cache](https://github.com/tagadanar/tagadalive/blob/master/tampermonkey/lwa-core.user.js): `tampermonkey/lwa-core.user.js`
- [Log parser and stats](https://github.com/tagadanar/tagadalive/blob/master/tampermonkey/lwa-parser.user.js): `tampermonkey/lwa-parser.user.js`
- [Analyzer state](https://github.com/tagadanar/tagadalive/blob/master/tampermonkey/lwa-core.user.js): `tampermonkey/lwa-core.user.js`

### Analysis Views

- [Analyzer panel](https://github.com/tagadanar/tagadalive/blob/master/tampermonkey/lwa-ui.user.js): `tampermonkey/lwa-ui.user.js`
- [Charts and anomalies](https://github.com/tagadanar/tagadalive/blob/master/tampermonkey/lwa-charts.user.js): `tampermonkey/lwa-charts.user.js`
- [Panel styling](https://github.com/tagadanar/tagadalive/blob/master/tampermonkey/lwa-styles.user.js): `tampermonkey/lwa-styles.user.js`

### Other components

- **LeekWars player**
- **LeekWars fight page**

## Connections

- LeekWars player → Mode entry: selects mode (evidence: `readme.md`)
- Mode entry → AI dispatcher: dispatches to (evidence: `readme.md`)
- AI dispatcher → Search algorithms: chooses search (evidence: `readme.md`)
- Search algorithms → Battle state: uses battle state (evidence: `readme.md`)
- Search algorithms → Game and combo model: evaluates actions (evidence: `readme.md`)
- Search algorithms → Fight and map control: uses controllers (evidence: `readme.md`)
- Search algorithms → Scoring knowledge: scores choices (evidence: `readme.md`)
- LeekWars fight page → Analyzer orchestration: provides fight page (evidence: `tampermonkey/lwa-main.user.js`)
- Analyzer orchestration → Fight log cache: checks and loads (evidence: `tampermonkey/lwa-main.user.js`)
- Analyzer orchestration → Analyzer state: updates analyzer state
- Log parser and stats → Analyzer state: reads turn data (evidence: `tampermonkey/lwa-parser.user.js`)
- Analyzer panel → Analyzer state: reads settings and state (evidence: `tampermonkey/lwa-ui.user.js`)
- Charts and anomalies → Analyzer state: reads turn data (evidence: `tampermonkey/lwa-charts.user.js`)
- Analyzer panel → Charts and anomalies: renders charts
- Panel styling → Analyzer panel: styles panel
