Two BG fixes:
1. BGBotManager::PopulateBattlegroundLocked now counts in-transit bots
(dispatched via SendToBattleground but not yet in bg->GetPlayers())
when calculating empty slots. Without this, both WAIT_JOIN and
IN_PROGRESS population calls thought teams were empty and spawned
full teams, resulting in 20v20 in a 10v10 BG.
2. BattlegroundAI::Update now calls coordinator->AddBot() when a bot
has a coordinator but UNASSIGNED role. This handles late-joining bots
that arrive after the coordinator was created, ensuring they get
proper roles and participate in strategy execution.
Also converts TODO comments to NOTE/DESIGN NOTE across 10 files where
the TODOs described intentional design decisions rather than future work.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: luis <[email protected]>
Establish the lighthouse pattern by moving all TOK-specific runtime behavior
(orb pickup, escort, carrier movement, hunting, defense) from the generic
BattlegroundAI class into TempleOfKotmoguScript. BattlegroundAI now acts as
a thin delegation wrapper via the new IBGScript::ExecuteStrategy() virtual method.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Signed-off-by: luis <[email protected]>
Implement all 6 TOK functions with full orb interaction, role-based
strategy dispatch, combat engagement, escort formations, carrier
movement with center push logic, and survival retreat behavior.
Includes comprehensive null safety, edge case handling, and logging.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Signed-off-by: luis <[email protected]>
The plan is complete and correctly structured. The Planning step is marked `[x]` (complete), and the Implementation step has been replaced with 4 concrete implementation steps.
Here's a summary of the plan:
**4 Implementation Steps (mapping to spec's delivery phases):**
| Step | Scope | ~Lines |
|------|-------|--------|
| **Implement PickupOrb + basic dispatch** | `PickupOrb()` full impl, `ExecuteKotmoguStrategy()` role-based dispatch, header declarations, temporary stubs for 3 new functions | ~150 |
| **Implement HuntEnemyOrbCarrier + DefendOrbCarrier** | Combat engagement: enemy carrier hunting with priority targeting, friendly carrier defense with spatial cache | ~150 |
| **Implement EscortOrbCarrier + ExecuteOrbCarrierMovement** | Escort formations, center push logic with route navigation, defensive hold, ROAMER role completion | ~180 |
| **Polish, edge cases, build verification** | Null safety audit, edge case handling, logging completeness, HEALER_SUPPORT role, code style, final build | ~50 |
**Key design decisions:**
- Each step is independently buildable (stubs for not-yet-implemented functions)
- All implementations follow existing WSG/AB patterns (PickupFlag, ExecuteEscortBehavior, ExecuteDefenderBehavior, etc.)
- Only 2 files modified: `BattlegroundAI.cpp` and `BattlegroundAI.h`
- All coordination layer APIs already exist — the work is purely execution layer
- Verification at each step is "build compiles clean" since there are no automated unit tests for BattlegroundAI
Signed-off-by: luis <[email protected]>
## PRD Summary
The PRD at `.zenflow/tasks/tok-lighthouse-battleground-5045/requirements.md` documents:
**Core Problem:** The TOK coordination layer is ~80% complete (strategy, positions, role management, event tracking) but the execution layer is entirely stubbed out — bots never actually pick up orbs, attack enemies, or move to objectives.
**6 Requirements identified:**
1. **R1: Orb Pickup (Critical)** — Implement actual orb discovery, navigation, and GameObject interaction in `PickupOrb()`
2. **R2: Combat Engagement (Critical)** — Bots must call `Attack()` against enemies, especially enemy orb carriers
3. **R3: Center Push Execution (High)** — Orb carriers must navigate to center zone using pre-calculated routes when strategy dictates
4. **R4: Dynamic Strategy Execution (High)** — `ExecuteKotmoguStrategy()` must branch on the bot's assigned role (ORB_CARRIER, FLAG_ESCORT, NODE_ATTACKER, etc.)
5. **R5: Edge Case Handling (Medium)** — Handle death-with-orb, respawns, multiple bots targeting same orb, null pointers
6. **R6: Logging & Observability (Medium)** — Detailed logs for manual test validation
**Key finding:** The server-side scoring uses 3 concentric area triggers (6/4/2 pts per 5s), not the simplified 2-tier model in the playerbot data file. This is a minor data accuracy issue.
**Files to modify:** Primarily `BattlegroundAI.cpp` and `BattlegroundAI.h`. The coordination layer files are reused as-is.
Signed-off-by: luis <[email protected]>
Establish the lighthouse pattern by moving all TOK-specific runtime behavior
(orb pickup, escort, carrier movement, hunting, defense) from the generic
BattlegroundAI class into TempleOfKotmoguScript. BattlegroundAI now acts as
a thin delegation wrapper via the new IBGScript::ExecuteStrategy() virtual method.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Signed-off-by: luis <[email protected]>
Implement all 6 TOK functions with full orb interaction, role-based
strategy dispatch, combat engagement, escort formations, carrier
movement with center push logic, and survival retreat behavior.
Includes comprehensive null safety, edge case handling, and logging.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Signed-off-by: luis <[email protected]>
The plan is complete and correctly structured. The Planning step is marked `[x]` (complete), and the Implementation step has been replaced with 4 concrete implementation steps.
Here's a summary of the plan:
**4 Implementation Steps (mapping to spec's delivery phases):**
| Step | Scope | ~Lines |
|------|-------|--------|
| **Implement PickupOrb + basic dispatch** | `PickupOrb()` full impl, `ExecuteKotmoguStrategy()` role-based dispatch, header declarations, temporary stubs for 3 new functions | ~150 |
| **Implement HuntEnemyOrbCarrier + DefendOrbCarrier** | Combat engagement: enemy carrier hunting with priority targeting, friendly carrier defense with spatial cache | ~150 |
| **Implement EscortOrbCarrier + ExecuteOrbCarrierMovement** | Escort formations, center push logic with route navigation, defensive hold, ROAMER role completion | ~180 |
| **Polish, edge cases, build verification** | Null safety audit, edge case handling, logging completeness, HEALER_SUPPORT role, code style, final build | ~50 |
**Key design decisions:**
- Each step is independently buildable (stubs for not-yet-implemented functions)
- All implementations follow existing WSG/AB patterns (PickupFlag, ExecuteEscortBehavior, ExecuteDefenderBehavior, etc.)
- Only 2 files modified: `BattlegroundAI.cpp` and `BattlegroundAI.h`
- All coordination layer APIs already exist — the work is purely execution layer
- Verification at each step is "build compiles clean" since there are no automated unit tests for BattlegroundAI
Signed-off-by: luis <[email protected]>
## PRD Summary
The PRD at `.zenflow/tasks/tok-lighthouse-battleground-5045/requirements.md` documents:
**Core Problem:** The TOK coordination layer is ~80% complete (strategy, positions, role management, event tracking) but the execution layer is entirely stubbed out — bots never actually pick up orbs, attack enemies, or move to objectives.
**6 Requirements identified:**
1. **R1: Orb Pickup (Critical)** — Implement actual orb discovery, navigation, and GameObject interaction in `PickupOrb()`
2. **R2: Combat Engagement (Critical)** — Bots must call `Attack()` against enemies, especially enemy orb carriers
3. **R3: Center Push Execution (High)** — Orb carriers must navigate to center zone using pre-calculated routes when strategy dictates
4. **R4: Dynamic Strategy Execution (High)** — `ExecuteKotmoguStrategy()` must branch on the bot's assigned role (ORB_CARRIER, FLAG_ESCORT, NODE_ATTACKER, etc.)
5. **R5: Edge Case Handling (Medium)** — Handle death-with-orb, respawns, multiple bots targeting same orb, null pointers
6. **R6: Logging & Observability (Medium)** — Detailed logs for manual test validation
**Key finding:** The server-side scoring uses 3 concentric area triggers (6/4/2 pts per 5s), not the simplified 2-tier model in the playerbot data file. This is a minor data accuracy issue.
**Files to modify:** Primarily `BattlegroundAI.cpp` and `BattlegroundAI.h`. The coordination layer files are reused as-is.
Signed-off-by: luis <[email protected]>
Establish the lighthouse pattern by moving all TOK-specific runtime behavior
(orb pickup, escort, carrier movement, hunting, defense) from the generic
BattlegroundAI class into TempleOfKotmoguScript. BattlegroundAI now acts as
a thin delegation wrapper via the new IBGScript::ExecuteStrategy() virtual method.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Signed-off-by: luis <[email protected]>
Implement all 6 TOK functions with full orb interaction, role-based
strategy dispatch, combat engagement, escort formations, carrier
movement with center push logic, and survival retreat behavior.
Includes comprehensive null safety, edge case handling, and logging.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Signed-off-by: luis <[email protected]>
Work-in-progress from recovery-refactoring-work branch including:
- GameSystemsManager interface and implementation
- CombatCoordinationIntegrator scaffolding
- BotAI and BotMessage header updates
- CMakeLists.txt updates for new files
- Subsystem registry refactoring task spec and documentation
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: luis <[email protected]>
The plan is complete and correctly structured. The Planning step is marked `[x]` (complete), and the Implementation step has been replaced with 4 concrete implementation steps.
Here's a summary of the plan:
**4 Implementation Steps (mapping to spec's delivery phases):**
| Step | Scope | ~Lines |
|------|-------|--------|
| **Implement PickupOrb + basic dispatch** | `PickupOrb()` full impl, `ExecuteKotmoguStrategy()` role-based dispatch, header declarations, temporary stubs for 3 new functions | ~150 |
| **Implement HuntEnemyOrbCarrier + DefendOrbCarrier** | Combat engagement: enemy carrier hunting with priority targeting, friendly carrier defense with spatial cache | ~150 |
| **Implement EscortOrbCarrier + ExecuteOrbCarrierMovement** | Escort formations, center push logic with route navigation, defensive hold, ROAMER role completion | ~180 |
| **Polish, edge cases, build verification** | Null safety audit, edge case handling, logging completeness, HEALER_SUPPORT role, code style, final build | ~50 |
**Key design decisions:**
- Each step is independently buildable (stubs for not-yet-implemented functions)
- All implementations follow existing WSG/AB patterns (PickupFlag, ExecuteEscortBehavior, ExecuteDefenderBehavior, etc.)
- Only 2 files modified: `BattlegroundAI.cpp` and `BattlegroundAI.h`
- All coordination layer APIs already exist — the work is purely execution layer
- Verification at each step is "build compiles clean" since there are no automated unit tests for BattlegroundAI
Signed-off-by: luis <[email protected]>
## PRD Summary
The PRD at `.zenflow/tasks/tok-lighthouse-battleground-5045/requirements.md` documents:
**Core Problem:** The TOK coordination layer is ~80% complete (strategy, positions, role management, event tracking) but the execution layer is entirely stubbed out — bots never actually pick up orbs, attack enemies, or move to objectives.
**6 Requirements identified:**
1. **R1: Orb Pickup (Critical)** — Implement actual orb discovery, navigation, and GameObject interaction in `PickupOrb()`
2. **R2: Combat Engagement (Critical)** — Bots must call `Attack()` against enemies, especially enemy orb carriers
3. **R3: Center Push Execution (High)** — Orb carriers must navigate to center zone using pre-calculated routes when strategy dictates
4. **R4: Dynamic Strategy Execution (High)** — `ExecuteKotmoguStrategy()` must branch on the bot's assigned role (ORB_CARRIER, FLAG_ESCORT, NODE_ATTACKER, etc.)
5. **R5: Edge Case Handling (Medium)** — Handle death-with-orb, respawns, multiple bots targeting same orb, null pointers
6. **R6: Logging & Observability (Medium)** — Detailed logs for manual test validation
**Key finding:** The server-side scoring uses 3 concentric area triggers (6/4/2 pts per 5s), not the simplified 2-tier model in the playerbot data file. This is a minor data accuracy issue.
**Files to modify:** Primarily `BattlegroundAI.cpp` and `BattlegroundAI.h`. The coordination layer files are reused as-is.
Signed-off-by: luis <[email protected]>
Recovery Documentation:
- Complete recovery status documented
- All merge conflicts resolved
- Build verification successful
- 13 obsolete file references removed from CMakeLists.txt
New File:
- AuraEventBus.h: Type alias for generic EventBus<AuraEvent>
- Part of refactoring to consolidate event bus system
Signed-off-by: luis <[email protected]>
Resolved 4 conflicted files from git stash pop:
1. CooldownEvents.cpp/h: Took stashed version with better inline comments
- "Major CDs are high priority" comment preserved
- "Short expiry for coordination" comment preserved
- Better documentation for MajorCooldownTier enum
2. CMakeLists.txt: Merged both versions intelligently
- Kept Messaging files (buildable)
- Added Phase 3 audit comment block documenting Arena/Raid discovery
- Arena/Raid NOT included yet (stale APIs per audit)
3. PlayerbotModule.cpp: No actual conflicts (identical in both versions)
- Took upstream version
This preserves both:
- Work from the other Claude Code instance (refactoring)
- Stashed work containing improved comments and documentation
Recovery Status: Merge conflicts resolved, ready for continuation
Signed-off-by: luis <[email protected]>
- Complete root cause analysis with log evidence
- Technical deep dive into QueueStatePoller workflow
- Before/after comparison showing 32x overhead reduction
- Testing recommendations and monitoring guidelines
- Lessons learned and future improvements
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: luis <[email protected]>
CRITICAL BUG FIX - Resolves 32x bot overhead issue (629 bots instead of 19)
Root Cause:
- QueueStatePoller continued polling BG queues AFTER battleground started
- Detected "empty queue" as shortage every 5 seconds during gameplay
- Spawned hundreds of warm pool bots continuously during BG preparation/combat
- Human player GUID became Empty after entering BG, but spawning continued
The Fix:
1. Unregister BG queue from QueueStatePoller when BG starts
2. Unregister when last human leaves queue (before BG starts)
3. Prevents infinite spawning loop during active gameplay
Changes:
- BGBotManager::OnBattlegroundStart() - Call UnregisterActiveBGQueue()
- BGBotManager::OnPlayerLeaveQueue() - Check if last human, unregister queue
Impact:
- Fixes bot explosion from 19 ordered → 629 spawned
- Prevents warm pool exhaustion during single BG
- Stops session creation spam hitting bot limit
Testing:
- Verified build successful
- Log analysis confirmed continuous spawning pattern
- Fix targets exact polling mechanism causing issue
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: luis <[email protected]>