|
ProtoBot
|
ScoutingProbe handles the initial scouting of the enemy base. The probe then steals gas if available and then starts a cycle of harassing enemy workers then orbiting their base. More...
#include <ScoutingProbe.h>
Public Member Functions | |
| ScoutingProbe (ProtoBotCommander *commander, ScoutingManager *manager) | |
| void | onStart () |
| Initializes the scouting probe state. | |
| void | onFrame () |
| Main update loop executed every frame. | |
| void | onUnitDestroy (BWAPI::Unit unit) |
| void | setEnemyMain (const BWAPI::TilePosition &tp) |
| void | assign (BWAPI::Unit unit) |
| Assigns a unit as the scouting probe. | |
| bool | hasScout () const |
| void | drawDebug () const |
| Draws debug information on the game map. | |
Private Types | |
| enum class | State { Search , GasSteal , Harass , Orbit , ReturningCargo , Done } |
Private Member Functions | |
| void | buildStartTargets () |
| void | issueMoveToward (const BWAPI::Position &p, int reissueDist=32, bool force=false) |
| bool | seeAnyEnemyBuildingNear (const BWAPI::Position &p, int radius) const |
| bool | anyRefineryOn (BWAPI::Unit geyser) const |
| bool | tryGasSteal () |
| Attempts to perform a gas steal on the enemy geyser. | |
| bool | tryHarassWorker () |
| Attempts to harass nearby enemy workers. | |
| void | ensureOrbitWaypoints () |
| Generates orbit waypoints around the enemy base. | |
| BWAPI::Position | currentOrbitPoint () const |
| void | advanceOrbitIfArrived () |
| bool | threatenedNow () const |
| BWAPI::Position | getAvgPosition () |
| bool | planTerrainPathTo (const BWAPI::Position &goal) |
| bool | hasPlannedPath () const |
| BWAPI::Position | currentPlannedWaypoint () const |
| BWAPI::Position | computeSidestepTarget (const BWAPI::Position &goal) |
| bool | isStuck (int now) |
| Detects whether the probe is stuck. | |
| BWAPI::Position | computeEscapeGoal () const |
| BWAPI::Unit | findAssimilatorOnTargetGeyser () const |
| bool | tryConfirmEnemyMainByStartLocations () |
| void | handleReturningCargoState () |
| BWAPI::Unit | findClosestDepot (const BWAPI::Position &from) const |
| BWAPI::Position | computeOrbitCenter () const |
| bool | planAStarPathTo (const BWAPI::Position &goal, bool interactableEndpoint=false) |
| Generates an A* path to a target position. | |
| void | followPlannedPath (const BWAPI::Position &finalGoal, int reissueDist=48) |
Static Private Member Functions | |
| static int | angleDeg (const BWAPI::Position &from, const BWAPI::Position &to) |
| static int | normDeg (int d) |
| static BWAPI::Position | clampToMapPx (const BWAPI::Position &p, int marginPx=32) |
| static BWAPI::Position | snapToNearestWalkable (BWAPI::Position p, int maxRadiusPx=128) |
| static BWAPI::Position | snapToNearestWalkableClear (BWAPI::Position p, BWAPI::UnitType ut, int maxRadiusPx=128) |
Private Attributes | |
| ProtoBotCommander * | commanderRef = nullptr |
| ScoutingManager * | manager = nullptr |
| BWAPI::Unit | scout = nullptr |
| std::optional< BWAPI::TilePosition > | enemyMainTile |
| BWAPI::Position | enemyMainPos = BWAPI::Positions::Invalid |
| std::vector< BWAPI::TilePosition > | startTargets |
| std::size_t | nextTarget = 0 |
| State | state = State::Done |
| bool | gasStealDone = false |
| BWAPI::Unit | targetGeyser = nullptr |
| int | nextGasStealRetryFrame = 0 |
| bool | gasStealRequested = false |
| bool | gasStealApproved = false |
| int | gasStealRequestFrame = 0 |
| int | nextCheesePollFrame = 0 |
| bool | gasStealHoldingForMinerals = false |
| int | nextMineralCheckFrame = 0 |
| int | lastMoveIssueFrame = 0 |
| int | lastHP = -1 |
| int | lastShields = -1 |
| int | lastThreatFrame = -999999 |
| BWAPI::Position | lastPos = BWAPI::Positions::Invalid |
| int | lastProgressFrame = 0 |
| int | lastProgressDist = INT_MAX |
| int | sidestepDir = 1 |
| int | sidestepAttempts = 0 |
| int | nextReplanFrame = 0 |
| BWAPI::Position | lastPlannedGoal = BWAPI::Positions::Invalid |
| BWAPI::Position | currentMoveGoal = BWAPI::Positions::Invalid |
| int | aStarEscapeUntilFrame = 0 |
| BWAPI::Position | aStarEscapeGoal = BWAPI::Positions::Invalid |
| BWAPI::Position | lastStuckPos = BWAPI::Positions::Invalid |
| int | lastStuckCheckFrame = 0 |
| int | stuckFrames = 0 |
| std::vector< BWAPI::Position > | orbitWaypoints |
| std::vector< BWAPI::Position > | plannedPath |
| std::size_t | orbitIdx = 0 |
| int | dwellUntilFrame = 0 |
| int | dbgLastOrbitPrintFrame = 0 |
| int | dbgLastOrbitBuildMs = 0 |
| int | dbgLastOrbitReplanMs = 0 |
| int | dbgLastAStarMs = 0 |
| int | dbgLastSnapMs = 0 |
Static Private Attributes | |
| static constexpr int | kCloseEnoughToTarget = 96 |
| static constexpr int | kMoveCooldownFrames = 8 |
| static constexpr int | kOrbitRadius = 350 |
| static constexpr int | kGasStealRetryCooldown = 24 |
| static constexpr int | kHarassRadiusFromMain = 320 |
| static constexpr int | kThreatRearmFrames = 8 |
| static constexpr int | kCalmFramesToResumeHarass = 72 |
| static constexpr int | kReplanFrames = 24 |
| static constexpr int | kGoalChangeReplanDist = 96 |
ScoutingProbe handles the initial scouting of the enemy base. The probe then steals gas if available and then starts a cycle of harassing enemy workers then orbiting their base.
Definition at line 18 of file ScoutingProbe.h.
|
strongprivate |
Definition at line 36 of file ScoutingProbe.h.
|
inlineexplicit |
Definition at line 20 of file ScoutingProbe.h.
|
private |
Definition at line 804 of file ScoutingProbe.cpp.
|
staticprivate |
Definition at line 852 of file ScoutingProbe.cpp.
|
private |
Definition at line 488 of file ScoutingProbe.cpp.
| void ScoutingProbe::assign | ( | BWAPI::Unit | unit | ) |
Assigns a unit as the scouting probe.
Initializes tracking values such as HP/shields and determines the starting state of the probe.
If the unit is carrying resources, transitions to ReturningCargo, otherwise begins scouting.
| unit | The unit to assign as the scout |
Definition at line 184 of file ScoutingProbe.cpp.
|
private |
Definition at line 414 of file ScoutingProbe.cpp.
|
staticprivate |
Definition at line 952 of file ScoutingProbe.cpp.
|
private |
Definition at line 1277 of file ScoutingProbe.cpp.
|
private |
Definition at line 857 of file ScoutingProbe.cpp.
|
private |
Definition at line 889 of file ScoutingProbe.cpp.
|
private |
Definition at line 799 of file ScoutingProbe.cpp.
|
private |
Definition at line 884 of file ScoutingProbe.cpp.
| void ScoutingProbe::drawDebug | ( | ) | const |
Draws debug information on the game map.
Displays:
Used for debugging and visualization.
Definition at line 1401 of file ScoutingProbe.cpp.
|
private |
Generates orbit waypoints around the enemy base.
Creates a circular set of safe positions around the enemy main to allow continuous movement while avoiding threats.
Waypoints are snapped to valid walkable positions.
Definition at line 725 of file ScoutingProbe.cpp.
|
private |
Definition at line 1068 of file ScoutingProbe.cpp.
|
private |
Definition at line 402 of file ScoutingProbe.cpp.
|
private |
Definition at line 1157 of file ScoutingProbe.cpp.
|
private |
Definition at line 840 of file ScoutingProbe.cpp.
|
private |
Definition at line 386 of file ScoutingProbe.cpp.
|
inlineprivate |
Definition at line 138 of file ScoutingProbe.h.
|
inline |
Definition at line 30 of file ScoutingProbe.h.
|
private |
Detects whether the probe is stuck.
Compares position changes over time to determine if the unit is not making meaningful movement.
| now | Current frame count |
Definition at line 1235 of file ScoutingProbe.cpp.
|
private |
Definition at line 432 of file ScoutingProbe.cpp.
|
inlinestaticprivate |
Definition at line 153 of file ScoutingProbe.h.
| void ScoutingProbe::onFrame | ( | ) |
Main update loop executed every frame.
Drives probe behavior using a finite state machine. Handles:
States handled:
Definition at line 225 of file ScoutingProbe.cpp.
| void ScoutingProbe::onStart | ( | ) |
Initializes the scouting probe state.
Sets up scouting targets and resets all internal state:
Definition at line 147 of file ScoutingProbe.cpp.
| void ScoutingProbe::onUnitDestroy | ( | BWAPI::Unit | unit | ) |
Definition at line 200 of file ScoutingProbe.cpp.
|
private |
Generates an A* path to a target position.
Ensures the path is valid and avoids obstacles. Optionally adjusts the goal to a safe reachable position.
| goal | Target position |
| interactableEndpoint | Whether the endpoint must be directly reachable |
Definition at line 1108 of file ScoutingProbe.cpp.
|
private |
Definition at line 871 of file ScoutingProbe.cpp.
|
private |
Definition at line 479 of file ScoutingProbe.cpp.
| void ScoutingProbe::setEnemyMain | ( | const BWAPI::TilePosition & | tp | ) |
Definition at line 379 of file ScoutingProbe.cpp.
|
staticprivate |
Definition at line 958 of file ScoutingProbe.cpp.
|
staticprivate |
Definition at line 984 of file ScoutingProbe.cpp.
|
private |
Definition at line 821 of file ScoutingProbe.cpp.
|
private |
Definition at line 1322 of file ScoutingProbe.cpp.
|
private |
Attempts to perform a gas steal on the enemy geyser.
Workflow:
Handles retries, movement, and fallback behavior.
Definition at line 513 of file ScoutingProbe.cpp.
|
private |
Attempts to harass nearby enemy workers.
Selects the closest valid worker near the enemy main base and issues an attack command.
Definition at line 697 of file ScoutingProbe.cpp.
|
private |
Definition at line 98 of file ScoutingProbe.h.
|
private |
Definition at line 97 of file ScoutingProbe.h.
|
private |
Definition at line 58 of file ScoutingProbe.h.
|
private |
Definition at line 94 of file ScoutingProbe.h.
|
private |
Definition at line 166 of file ScoutingProbe.h.
|
private |
Definition at line 164 of file ScoutingProbe.h.
|
private |
Definition at line 163 of file ScoutingProbe.h.
|
private |
Definition at line 165 of file ScoutingProbe.h.
|
private |
Definition at line 167 of file ScoutingProbe.h.
|
private |
Definition at line 110 of file ScoutingProbe.h.
|
private |
Definition at line 64 of file ScoutingProbe.h.
|
private |
Definition at line 63 of file ScoutingProbe.h.
|
private |
Definition at line 77 of file ScoutingProbe.h.
|
private |
Definition at line 73 of file ScoutingProbe.h.
|
private |
Definition at line 80 of file ScoutingProbe.h.
|
private |
Definition at line 76 of file ScoutingProbe.h.
|
private |
Definition at line 78 of file ScoutingProbe.h.
|
staticconstexprprivate |
Definition at line 119 of file ScoutingProbe.h.
|
staticconstexprprivate |
Definition at line 113 of file ScoutingProbe.h.
|
staticconstexprprivate |
Definition at line 116 of file ScoutingProbe.h.
|
staticconstexprprivate |
Definition at line 121 of file ScoutingProbe.h.
|
staticconstexprprivate |
Definition at line 117 of file ScoutingProbe.h.
|
staticconstexprprivate |
Definition at line 114 of file ScoutingProbe.h.
|
staticconstexprprivate |
Definition at line 115 of file ScoutingProbe.h.
|
staticconstexprprivate |
Definition at line 120 of file ScoutingProbe.h.
|
staticconstexprprivate |
Definition at line 118 of file ScoutingProbe.h.
|
private |
Definition at line 85 of file ScoutingProbe.h.
|
private |
Definition at line 84 of file ScoutingProbe.h.
|
private |
Definition at line 93 of file ScoutingProbe.h.
|
private |
Definition at line 87 of file ScoutingProbe.h.
|
private |
Definition at line 89 of file ScoutingProbe.h.
|
private |
Definition at line 88 of file ScoutingProbe.h.
|
private |
Definition at line 85 of file ScoutingProbe.h.
|
private |
Definition at line 102 of file ScoutingProbe.h.
|
private |
Definition at line 101 of file ScoutingProbe.h.
|
private |
Definition at line 86 of file ScoutingProbe.h.
|
private |
Definition at line 59 of file ScoutingProbe.h.
|
private |
Definition at line 79 of file ScoutingProbe.h.
|
private |
Definition at line 75 of file ScoutingProbe.h.
|
private |
Definition at line 81 of file ScoutingProbe.h.
|
private |
Definition at line 92 of file ScoutingProbe.h.
|
private |
Definition at line 69 of file ScoutingProbe.h.
|
private |
Definition at line 109 of file ScoutingProbe.h.
|
private |
Definition at line 107 of file ScoutingProbe.h.
|
private |
Definition at line 108 of file ScoutingProbe.h.
|
private |
Definition at line 60 of file ScoutingProbe.h.
|
private |
Definition at line 91 of file ScoutingProbe.h.
|
private |
Definition at line 90 of file ScoutingProbe.h.
|
private |
Definition at line 68 of file ScoutingProbe.h.
|
private |
Definition at line 70 of file ScoutingProbe.h.
|
private |
Definition at line 103 of file ScoutingProbe.h.
|
private |
Definition at line 74 of file ScoutingProbe.h.