|
ProtoBot
|
ThreatGrid Maintains spatial threat information for enemy units. Uses a grid-based system to efficiently query danger levels at any position, allowing units to avoid unsafe areas. More...
#include <ThreatGrid.h>
Classes | |
| struct | EnemyStamp |
| struct | GridData |
Public Member Functions | |
| void | onStart () |
| Initializes threat grids based on map dimensions. | |
| void | onFrameStart (int frame) |
| Updates the current frame reference for the grid. | |
| void | addOrUpdateEnemy (int id, BWAPI::UnitType type, BWAPI::Position pos, bool completed, bool burrowed, bool immobile) |
| Adds or updates an enemy unit's contribution to the threat grid. | |
| void | removeEnemy (int id) |
| Removes an enemy unit from the threat grid. | |
| int | groundThreatAt (BWAPI::Position p) const |
| Returns the ground threat value at a given position. | |
| int | detectionAt (BWAPI::Position p) const |
| Returns the detection threat value at a given position. | |
| int | airThreatAt (BWAPI::Position p) const |
| Returns the air threat value at a given position. | |
| int | getAirThreat (BWAPI::Position p) const |
| int | getDetection (BWAPI::Position p) const |
| Wrapper for retrieving detection threat at a position. | |
| int | airThreatValue (BWAPI::UnitType t) const |
| int | airThreatRangePx (BWAPI::UnitType t) const |
Private Member Functions | |
| void | paintDisc (GridData &g, BWAPI::Position center, int rangePx, int delta) |
| void | stampEnemy (const EnemyStamp &s, int delta) |
| int | detectorRadiusPx (BWAPI::UnitType t) const |
| int | groundThreatValue (BWAPI::UnitType t) const |
| int | groundThreatRangePx (BWAPI::UnitType t) const |
Static Private Member Functions | |
| static int | toWalkX (BWAPI::Position p) |
| static int | toWalkY (BWAPI::Position p) |
Private Attributes | |
| int | currentFrame_ = 0 |
| int | rangeBufferPx_ = 16 |
| GridData | groundThreat_ |
| GridData | airThreat_ |
| GridData | detection_ |
| std::unordered_map< int, EnemyStamp > | stamps_ |
ThreatGrid Maintains spatial threat information for enemy units. Uses a grid-based system to efficiently query danger levels at any position, allowing units to avoid unsafe areas.
Tracks and updates:
Definition at line 18 of file ThreatGrid.h.
| void ThreatGrid::addOrUpdateEnemy | ( | int | id, |
| BWAPI::UnitType | type, | ||
| BWAPI::Position | pos, | ||
| bool | completed, | ||
| bool | burrowed, | ||
| bool | immobile ) |
Adds or updates an enemy unit's contribution to the threat grid.
If the unit state has changed, its previous contribution is removed and recalculated.
| id | Unique unit ID |
| type | Unit type |
| pos | Unit position |
| completed | Whether the unit is complete |
| burrowed | Whether the unit is burrowed |
| immobile | Whether the unit is immobile |
Definition at line 94 of file ThreatGrid.cpp.
| int ThreatGrid::airThreatAt | ( | BWAPI::Position | p | ) | const |
Returns the air threat value at a given position.
| p | World position |
Definition at line 62 of file ThreatGrid.cpp.
| int ThreatGrid::airThreatRangePx | ( | BWAPI::UnitType | t | ) | const |
Definition at line 242 of file ThreatGrid.cpp.
| int ThreatGrid::airThreatValue | ( | BWAPI::UnitType | t | ) | const |
Definition at line 266 of file ThreatGrid.cpp.
| int ThreatGrid::detectionAt | ( | BWAPI::Position | p | ) | const |
Returns the detection threat value at a given position.
| p | World position |
Definition at line 51 of file ThreatGrid.cpp.
|
private |
Definition at line 178 of file ThreatGrid.cpp.
| int ThreatGrid::getAirThreat | ( | BWAPI::Position | p | ) | const |
Definition at line 67 of file ThreatGrid.cpp.
| int ThreatGrid::getDetection | ( | BWAPI::Position | p | ) | const |
Wrapper for retrieving detection threat at a position.
Definition at line 76 of file ThreatGrid.cpp.
| int ThreatGrid::groundThreatAt | ( | BWAPI::Position | p | ) | const |
Returns the ground threat value at a given position.
| p | World position |
Definition at line 40 of file ThreatGrid.cpp.
|
private |
Definition at line 191 of file ThreatGrid.cpp.
|
private |
Definition at line 215 of file ThreatGrid.cpp.
| void ThreatGrid::onFrameStart | ( | int | frame | ) |
Updates the current frame reference for the grid.
| frame | Current game frame |
Definition at line 29 of file ThreatGrid.cpp.
| void ThreatGrid::onStart | ( | ) |
Initializes threat grids based on map dimensions.
Creates walk-tile resolution grids for:
Definition at line 13 of file ThreatGrid.cpp.
|
private |
Definition at line 149 of file ThreatGrid.cpp.
| void ThreatGrid::removeEnemy | ( | int | id | ) |
Removes an enemy unit from the threat grid.
Clears its previously stamped threat values.
| id | Unit ID |
Definition at line 137 of file ThreatGrid.cpp.
|
private |
Definition at line 294 of file ThreatGrid.cpp.
|
inlinestaticprivate |
Definition at line 92 of file ThreatGrid.h.
|
inlinestaticprivate |
Definition at line 97 of file ThreatGrid.h.
|
private |
Definition at line 86 of file ThreatGrid.h.
|
private |
Definition at line 82 of file ThreatGrid.h.
|
private |
Definition at line 87 of file ThreatGrid.h.
|
private |
Definition at line 85 of file ThreatGrid.h.
|
private |
Definition at line 83 of file ThreatGrid.h.
|
private |
Definition at line 90 of file ThreatGrid.h.