|
ProtoBot
|
ScoutingObserver Controls scouting behavior for a Protoss Observer. Maintains vision over key enemy locations, avoids detection threats, and monitors expansions using a slot-based system. Observers either hold fixed positions near the enemy base or dynamically patrol expansion locations to provide map awareness. More...
#include <ScoutingObserver.h>
Public Member Functions | |
| ScoutingObserver (ProtoBotCommander *cmd=nullptr, ScoutingManager *mgr=nullptr) | |
| void | onStart () |
| Initializes the observer scouting state. | |
| void | onFrame () |
| Main update loop executed every frame. | |
| void | onUnitDestroy (BWAPI::Unit u) |
| Handles observer destruction. | |
| void | assign (BWAPI::Unit u) |
| Assigns a unit as the scouting observer. | |
| void | setEnemyMain (const BWAPI::TilePosition &tp) |
| Sets the enemy main base and recomputes observation posts. | |
| void | setObserverSlot (int idx) |
| void | drawDebug () const |
| Draws debug information for the observer on the map. | |
Private Types | |
| enum class | State { Idle , MoveToPost , Hold , AvoidDetection , Done } |
Private Member Functions | |
| void | computePosts () |
| Computes observation posts around the enemy base. | |
| BWAPI::Position | postTarget () const |
| Returns the current target position for this observer. | |
| void | issueMove (const BWAPI::Position &p, bool force=false, int reissueDist=64) |
| Issues a movement command to the observer. | |
| bool | detectorThreat (BWAPI::Position &avoidTo) const |
| Detects nearby enemy detectors and computes a safe escape position. | |
| bool | isUnsafe (const BWAPI::Position &p) const |
| Determines if a position is unsafe based on threat data. | |
| BWAPI::Position | pickDetourToward (const BWAPI::Position &target) const |
| Selects a safe detour toward a target position. | |
| bool | haveVisionAt (const BWAPI::Position &p, int radiusPx) const |
| Checks whether the bot currently has vision at a position. | |
| void | rebuildSlot3Checkpoints () |
| Rebuilds roaming checkpoints for slot 3 observers. | |
Static Private Member Functions | |
| static int | detectionRadiusFor (const BWAPI::UnitType &t) |
| static BWAPI::Position | clampToMapPx (const BWAPI::Position &p, int margin=16) |
| static double | groundPathLengthPx (const BWAPI::Position &from, const BWAPI::Position &to) |
Private Attributes | |
| ProtoBotCommander * | commanderRef = nullptr |
| ScoutingManager * | manager = nullptr |
| BWAPI::Unit | observer { nullptr } |
| State | state = State::Idle |
| std::vector< BWAPI::Position > | posts |
| int | slotIndex = -1 |
| std::optional< BWAPI::TilePosition > | enemyMainTile |
| BWAPI::Position | enemyMainPos = BWAPI::Positions::Invalid |
| int | lastMoveFrame = 0 |
| int | lastThreatFrame = -10000 |
| BWAPI::Position | slot3Home = BWAPI::Positions::Invalid |
| bool | slot3HomeSet = false |
| bool | slot3ReturningHome = false |
| std::vector< BWAPI::Position > | slot3Checkpoints |
| int | slot3NextRebuildFrame = 0 |
| bool | slot3NeedsRebuild = false |
| int | slot3NextIdx = 0 |
| int | slot3NextMoveFrame = 0 |
| BWAPI::Position | slot3CurTarget = BWAPI::Positions::Invalid |
Static Private Attributes | |
| static constexpr int | kMoveCooldown = 6 |
| static constexpr int | kSafeFramesToReturn = 48 |
| static constexpr int | kEdgeMarginPx = 8 |
| static constexpr int | kHoldReissueDist = 16 |
| static constexpr int | kAirThreatThreshold = 40 |
| static constexpr int | kDetectReactBufferPx = 48 |
| static constexpr int | kSlot3RebuildEveryFrames = 24 * 6 |
| static constexpr int | kSlot3MinBetweenMoves = 24 |
| static constexpr int | kSlot3ArriveDist = 96 |
ScoutingObserver Controls scouting behavior for a Protoss Observer. Maintains vision over key enemy locations, avoids detection threats, and monitors expansions using a slot-based system. Observers either hold fixed positions near the enemy base or dynamically patrol expansion locations to provide map awareness.
Definition at line 22 of file ScoutingObserver.h.
|
strongprivate |
Definition at line 42 of file ScoutingObserver.h.
|
inlineexplicit |
Definition at line 25 of file ScoutingObserver.h.
| void ScoutingObserver::assign | ( | BWAPI::Unit | u | ) |
Assigns a unit as the scouting observer.
Initializes behavior based on assigned slot:
| u | Observer unit |
Definition at line 68 of file ScoutingObserver.cpp.
|
staticprivate |
Definition at line 462 of file ScoutingObserver.cpp.
|
private |
Computes observation posts around the enemy base.
Selects:
Ensures posts are reachable and valid positions.
Definition at line 313 of file ScoutingObserver.cpp.
|
staticprivate |
Definition at line 449 of file ScoutingObserver.cpp.
|
private |
Detects nearby enemy detectors and computes a safe escape position.
| avoidTo | Output position to move away from detection |
Definition at line 407 of file ScoutingObserver.cpp.
| void ScoutingObserver::drawDebug | ( | ) | const |
Draws debug information for the observer on the map.
Displays:
Definition at line 799 of file ScoutingObserver.cpp.
|
staticprivate |
Definition at line 469 of file ScoutingObserver.cpp.
|
private |
Checks whether the bot currently has vision at a position.
| p | Position to check |
| radiusPx | Search radius |
Definition at line 617 of file ScoutingObserver.cpp.
|
private |
Issues a movement command to the observer.
Includes throttling to prevent excessive command spam.
| p | Target position |
| force | Force movement regardless of cooldown |
| reissueDist | Minimum distance to reissue move |
Definition at line 388 of file ScoutingObserver.cpp.
|
private |
Determines if a position is unsafe based on threat data.
| p | Position to evaluate |
Definition at line 493 of file ScoutingObserver.cpp.
| void ScoutingObserver::onFrame | ( | ) |
Main update loop executed every frame.
Handles:
Slot behavior:
Definition at line 141 of file ScoutingObserver.cpp.
| void ScoutingObserver::onStart | ( | ) |
Initializes the observer scouting state.
Resets movement tracking, threat tracking, and clears any existing observation posts.
Definition at line 52 of file ScoutingObserver.cpp.
| void ScoutingObserver::onUnitDestroy | ( | BWAPI::Unit | u | ) |
Handles observer destruction.
Clears the assigned unit and marks behavior as complete.
| u | Destroyed unit |
Definition at line 121 of file ScoutingObserver.cpp.
|
private |
Selects a safe detour toward a target position.
Attempts alternative paths to avoid threats while still progressing toward the goal.
| target | Target position |
Definition at line 521 of file ScoutingObserver.cpp.
|
private |
Returns the current target position for this observer.
Definition at line 372 of file ScoutingObserver.cpp.
|
private |
Rebuilds roaming checkpoints for slot 3 observers.
Selects expansion locations to patrol while:
Definition at line 676 of file ScoutingObserver.cpp.
| void ScoutingObserver::setEnemyMain | ( | const BWAPI::TilePosition & | tp | ) |
Sets the enemy main base and recomputes observation posts.
Transitions the observer from Idle to active scouting if a valid slot is assigned.
| tp | Enemy main tile position |
Definition at line 107 of file ScoutingObserver.cpp.
|
inline |
Definition at line 37 of file ScoutingObserver.h.
|
private |
Definition at line 44 of file ScoutingObserver.h.
|
private |
Definition at line 55 of file ScoutingObserver.h.
|
private |
Definition at line 54 of file ScoutingObserver.h.
|
staticconstexprprivate |
Definition at line 65 of file ScoutingObserver.h.
|
staticconstexprprivate |
Definition at line 66 of file ScoutingObserver.h.
|
staticconstexprprivate |
Definition at line 63 of file ScoutingObserver.h.
|
staticconstexprprivate |
Definition at line 64 of file ScoutingObserver.h.
|
staticconstexprprivate |
Definition at line 61 of file ScoutingObserver.h.
|
staticconstexprprivate |
Definition at line 62 of file ScoutingObserver.h.
|
staticconstexprprivate |
Definition at line 70 of file ScoutingObserver.h.
|
staticconstexprprivate |
Definition at line 69 of file ScoutingObserver.h.
|
staticconstexprprivate |
Definition at line 68 of file ScoutingObserver.h.
|
private |
Definition at line 57 of file ScoutingObserver.h.
|
private |
Definition at line 58 of file ScoutingObserver.h.
|
private |
Definition at line 45 of file ScoutingObserver.h.
|
private |
Definition at line 47 of file ScoutingObserver.h.
|
private |
Definition at line 51 of file ScoutingObserver.h.
|
private |
Definition at line 76 of file ScoutingObserver.h.
|
private |
Definition at line 81 of file ScoutingObserver.h.
|
private |
Definition at line 73 of file ScoutingObserver.h.
|
private |
Definition at line 74 of file ScoutingObserver.h.
|
private |
Definition at line 78 of file ScoutingObserver.h.
|
private |
Definition at line 79 of file ScoutingObserver.h.
|
private |
Definition at line 80 of file ScoutingObserver.h.
|
private |
Definition at line 77 of file ScoutingObserver.h.
|
private |
Definition at line 75 of file ScoutingObserver.h.
|
private |
Definition at line 52 of file ScoutingObserver.h.
|
private |
Definition at line 48 of file ScoutingObserver.h.