|
ProtoBot
|
ScoutingManager Manages all scouting units and their behaviors. Assigns units to the appropriate scouting behavior, updates them each frame, tracks enemy locations, and coordinates transitions between scouting and combat. More...
#include <ScoutingManager.h>
Public Member Functions | |
| ScoutingManager (ProtoBotCommander *commander=nullptr) | |
| Manages all scouting behavior in ProtoBot. | |
| void | onStart () |
| Called once at game start. | |
| void | onFrame () |
| Main update loop executed every frame. | |
| void | assignScout (BWAPI::Unit unit) |
| Assigns a unit as a scout and attaches the appropriate behavior. | |
| bool | hasScout () const |
| Checks if any scouting units are currently active. | |
| void | setEnemyMain (const BWAPI::TilePosition &tp) |
| Sets the enemy main base location and broadcasts it to all scouts. | |
| void | setEnemyNatural (const BWAPI::TilePosition &tp) |
| Sets the enemy natural expansion location. | |
| void | onUnitDestroy (BWAPI::Unit unit) |
| Handles cleanup when a unit is destroyed. | |
| std::optional< BWAPI::TilePosition > | getEnemyMain () const |
| std::optional< BWAPI::TilePosition > | getEnemyNatural () const |
| void | markScout (BWAPI::Unit u) |
| Marks a unit as a scout and tracks it by type. | |
| void | unmarkScout (BWAPI::Unit u) |
| Removes a unit from scout tracking structures. | |
| bool | isScout (BWAPI::Unit u) const |
| Checks whether a unit is currently assigned as a scout. | |
| bool | isCombatScout (BWAPI::Unit u) const |
| Checks if a unit is a combat scout (Zealot or Dragoon). | |
| bool | hasWorkerScout () const |
| void | drawDebug () const |
| Draws debug information for all scouting behaviors. | |
| void | drawGlobalDebugPanel () const |
| void | drawKnownEnemyLocations () const |
| void | drawScoutDebugFor (BWAPI::Unit unit) const |
| void | drawScoutTags () const |
| void | setCombatScoutingStarted (bool v) |
| bool | combatScoutingStarted () const |
| bool | canAcceptWorkerScout () const |
| bool | combatScoutLockActive () const |
| int | combatScoutLockFramesRemaining () const |
| void | maybeReturnCombatScoutsToCombat () |
| bool | tryReturnScoutToCombat (BWAPI::Unit unit) |
| Returns a combat scout unit back to combat control. | |
| bool | isNearActiveCombatSquad (BWAPI::Unit unit) const |
| void | lockCombatScoutAssignments (int frames) |
| bool | canAcceptCombatScout (BWAPI::UnitType t) const |
| bool | canAcceptObserverScout () const |
| int | numCombatScouts () const |
| BWAPI::Unit | getAvaliableDetectors () |
| Retrieves an available observer and removes it from scouting. | |
Public Attributes | |
| bool | scoutingDebugEnabled_ = false |
| int | combatScoutLockUntilFrame_ = 0 |
Static Public Attributes | |
| static constexpr int | kScoutReturnToCombatDistPx_ = 10 * 32 |
| static constexpr int | kCombatScoutLockFrames_ = 24 * 10 |
Private Member Functions | |
| BehaviorVariant | constructBehaviorFor (BWAPI::Unit unit) |
| Creates the appropriate scouting behavior for a unit. | |
| int | reserveObserverSlot (int unitId) |
| void | releaseObserverSlot (int unitId) |
Static Private Member Functions | |
| static BWAPI::Unit | findUnitById (int id) |
Private Attributes | |
| ProtoBotCommander * | commanderRef = nullptr |
| std::unordered_map< int, BehaviorVariant > | behaviors_ |
| std::vector< BWAPI::Unit > | scouts_ |
| BWAPI::Unit | workerScout_ { nullptr } |
| bool | combatScoutingStarted_ { false } |
| std::optional< BWAPI::TilePosition > | enemyMainCache_ |
| std::optional< BWAPI::TilePosition > | enemyNaturalCache_ |
| bool | inBehaviorFrame_ = false |
| std::optional< BWAPI::TilePosition > | pendingEnemyMain_ |
| int | maxZealotScouts_ { 2 } |
| int | maxDragoonScouts_ { 2 } |
| int | maxObserverScouts_ { 4 } |
| int | proxyPatrolZealotId_ = -1 |
| std::vector< BWAPI::Unit > | combatZealots_ |
| std::vector< BWAPI::Unit > | combatDragoons_ |
| std::vector< BWAPI::Unit > | observerScouts_ |
| int | observerSlotOwner_ [4] = { -1, -1, -1, -1 } |
| std::vector< BWAPI::Unit > | darkTemplarScouts_ |
ScoutingManager Manages all scouting units and their behaviors. Assigns units to the appropriate scouting behavior, updates them each frame, tracks enemy locations, and coordinates transitions between scouting and combat.
Definition at line 44 of file ScoutingManager.h.
|
explicit |
Manages all scouting behavior in ProtoBot.
Responsibilities:
Uses a BehaviorVariant system to support multiple scout types:
Initializes the ScoutingManager with a reference to the commander.
| commander | Pointer to ProtoBotCommander |
Definition at line 25 of file ScoutingManager.cpp.
| void ScoutingManager::assignScout | ( | BWAPI::Unit | unit | ) |
Assigns a unit as a scout and attaches the appropriate behavior.
Handles different unit types:
Also removes the unit from combat control.
| unit | Unit to assign as a scout |
Definition at line 134 of file ScoutingManager.cpp.
|
inline |
Definition at line 92 of file ScoutingManager.h.
|
inline |
Definition at line 117 of file ScoutingManager.h.
|
inline |
Definition at line 78 of file ScoutingManager.h.
|
inline |
Definition at line 76 of file ScoutingManager.h.
| bool ScoutingManager::combatScoutLockActive | ( | ) | const |
Definition at line 758 of file ScoutingManager.cpp.
| int ScoutingManager::combatScoutLockFramesRemaining | ( | ) | const |
Definition at line 763 of file ScoutingManager.cpp.
|
private |
Creates the appropriate scouting behavior for a unit.
Supports:
Falls back to Probe behavior if type is unsupported.
| unit | Unit to create behavior for |
Definition at line 377 of file ScoutingManager.cpp.
| void ScoutingManager::drawDebug | ( | ) | const |
Draws debug information for all scouting behaviors.
Includes:
Definition at line 601 of file ScoutingManager.cpp.
| void ScoutingManager::drawGlobalDebugPanel | ( | ) | const |
Definition at line 617 of file ScoutingManager.cpp.
| void ScoutingManager::drawKnownEnemyLocations | ( | ) | const |
Definition at line 666 of file ScoutingManager.cpp.
| void ScoutingManager::drawScoutDebugFor | ( | BWAPI::Unit | unit | ) | const |
Definition at line 678 of file ScoutingManager.cpp.
| void ScoutingManager::drawScoutTags | ( | ) | const |
Definition at line 731 of file ScoutingManager.cpp.
|
staticprivate |
Definition at line 426 of file ScoutingManager.cpp.
| BWAPI::Unit ScoutingManager::getAvaliableDetectors | ( | ) |
Retrieves an available observer and removes it from scouting.
Transfers control back to combat systems.
Definition at line 915 of file ScoutingManager.cpp.
|
inline |
Definition at line 60 of file ScoutingManager.h.
|
inline |
Definition at line 61 of file ScoutingManager.h.
| bool ScoutingManager::hasScout | ( | ) | const |
Checks if any scouting units are currently active.
Definition at line 208 of file ScoutingManager.cpp.
| bool ScoutingManager::hasWorkerScout | ( | ) | const |
Definition at line 560 of file ScoutingManager.cpp.
| bool ScoutingManager::isCombatScout | ( | BWAPI::Unit | u | ) | const |
Checks if a unit is a combat scout (Zealot or Dragoon).
| u | Unit to check |
Definition at line 550 of file ScoutingManager.cpp.
| bool ScoutingManager::isNearActiveCombatSquad | ( | BWAPI::Unit | unit | ) | const |
Definition at line 863 of file ScoutingManager.cpp.
| bool ScoutingManager::isScout | ( | BWAPI::Unit | u | ) | const |
Checks whether a unit is currently assigned as a scout.
| u | Unit to check |
Definition at line 533 of file ScoutingManager.cpp.
| void ScoutingManager::lockCombatScoutAssignments | ( | int | frames | ) |
Definition at line 902 of file ScoutingManager.cpp.
| void ScoutingManager::markScout | ( | BWAPI::Unit | u | ) |
Marks a unit as a scout and tracks it by type.
Adds the unit to the appropriate scouting collection.
| u | Unit to mark as scout |
Definition at line 440 of file ScoutingManager.cpp.
| void ScoutingManager::maybeReturnCombatScoutsToCombat | ( | ) |
Definition at line 769 of file ScoutingManager.cpp.
|
inline |
Definition at line 120 of file ScoutingManager.h.
| void ScoutingManager::onFrame | ( | ) |
Main update loop executed every frame.
Updates all active scouting behaviors and handles:
Definition at line 97 of file ScoutingManager.cpp.
| void ScoutingManager::onStart | ( | ) |
Called once at game start.
Used to initialize scouting systems.
Definition at line 36 of file ScoutingManager.cpp.
| void ScoutingManager::onUnitDestroy | ( | BWAPI::Unit | unit | ) |
Handles cleanup when a unit is destroyed.
Removes scouting behavior and updates tracking structures.
| unit | Destroyed unit |
Definition at line 310 of file ScoutingManager.cpp.
|
private |
Definition at line 358 of file ScoutingManager.cpp.
|
private |
Definition at line 348 of file ScoutingManager.cpp.
|
inline |
Definition at line 75 of file ScoutingManager.h.
| void ScoutingManager::setEnemyMain | ( | const BWAPI::TilePosition & | tp | ) |
Sets the enemy main base location and broadcasts it to all scouts.
If called during a behavior frame, the update is deferred to avoid modifying state mid-iteration.
| tp | Enemy main tile position |
Definition at line 258 of file ScoutingManager.cpp.
| void ScoutingManager::setEnemyNatural | ( | const BWAPI::TilePosition & | tp | ) |
Sets the enemy natural expansion location.
| tp | Enemy natural tile position |
Definition at line 297 of file ScoutingManager.cpp.
| bool ScoutingManager::tryReturnScoutToCombat | ( | BWAPI::Unit | unit | ) |
Returns a combat scout unit back to combat control.
Removes scouting behavior and reassigns the unit to CombatManager.
| unit | Unit to return |
Definition at line 813 of file ScoutingManager.cpp.
| void ScoutingManager::unmarkScout | ( | BWAPI::Unit | u | ) |
Removes a unit from scout tracking structures.
| u | Unit to remove |
Definition at line 489 of file ScoutingManager.cpp.
|
private |
Definition at line 131 of file ScoutingManager.h.
|
private |
Definition at line 154 of file ScoutingManager.h.
|
private |
Definition at line 139 of file ScoutingManager.h.
| int ScoutingManager::combatScoutLockUntilFrame_ = 0 |
Definition at line 88 of file ScoutingManager.h.
|
private |
Definition at line 153 of file ScoutingManager.h.
|
private |
Definition at line 128 of file ScoutingManager.h.
|
private |
Definition at line 165 of file ScoutingManager.h.
|
private |
Definition at line 140 of file ScoutingManager.h.
|
private |
Definition at line 141 of file ScoutingManager.h.
|
private |
Definition at line 143 of file ScoutingManager.h.
|
staticconstexpr |
Definition at line 90 of file ScoutingManager.h.
|
staticconstexpr |
Definition at line 89 of file ScoutingManager.h.
|
private |
Definition at line 148 of file ScoutingManager.h.
|
private |
Definition at line 149 of file ScoutingManager.h.
|
private |
Definition at line 147 of file ScoutingManager.h.
|
private |
Definition at line 158 of file ScoutingManager.h.
|
private |
Definition at line 159 of file ScoutingManager.h.
|
private |
Definition at line 144 of file ScoutingManager.h.
|
private |
Definition at line 151 of file ScoutingManager.h.
| bool ScoutingManager::scoutingDebugEnabled_ = false |
Definition at line 46 of file ScoutingManager.h.
|
private |
Definition at line 137 of file ScoutingManager.h.
|
private |
Definition at line 138 of file ScoutingManager.h.