archive by month
Skip to content

tracking enemy comsat scans

Today I implemented tracking of enemy scans in Steamhammer, a new feature allowed by BWAPI 4.4.0. Before, there was no way for a bot to know if the terran enemy had scanned you, except to notice that a burrowed or cloaked unit you had thought was undetected was suddenly being fired on.

It’s simple. An enemy comsat scan is represented as an unseen enemy detector unit (that potentially exists() from BWAPI’s point of view) with unit type Spell_Scanner_Sweep. To find the scans, iterate through BWAPI::Broodwar->enemy()->getUnits() and pick them out by unit type, done. The scan unit has the same sight range and the same detection range as a science vessel, 10 tiles or 320 pixels.

Unlike the disruption web unit and the dark swarm unit, the Spell_Scanner_Sweep unit is “flying”—the unit type returns true for isFlyer() (I assume that is what makes it equivalent to a science vessel). After realizing that, I searched for related bugs, and found some. One sneaky bug caused by the upgrade to BWAPI 4.4.0 was sending scourge to the location of a scan—“must shoot down the enemy air unit!” Another sneaky bug that was there all along was in analyzing the map: If the map had neutral dwebs or neutral dark swarms, then the tiles under those spells would be marked unwalkable in the internal representation; I never noticed, partly because few maps have permanent spells and partly because Steamhammer doesn’t implement pathfinding yet. I added checks for whether a given unit isSpell() in a number of places.

The scanner sweep unit has getRemoveTimer() so you can tell how long the scan will last. For enemy scans, it always returns 0 in my tests. That kind of makes sense, but it was not what I expected. I thought BWAPI would try to judge the visibility of the scan by whether you could see the swirling sparkles, which tells a human player both where and when the scan occurred, so it is enough information to judge duration. The change log says “the visibility of the scan is approximate and not accurate,” but nothing more.

Trackbacks

No Trackbacks

Comments

No comments

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Form options

Submitted comments will be subject to moderation before being displayed.