threat-aware pathing
Of all the mistakes bots make, I think the worst is wandering blindly into enemy fire. If you know where the enemy is, then don’t get shot at for nothing—react to the threat one way or another.
Examples: Send an SCV to scout the zerg base, where the sunken kills it. Oops, no scout, send another. The sunken kills it. Oops, no scout, etc.
Or: The enemy is ravaging your expansion. You’ve lost all the workers. That’s not efficient, better balance your bases by sending more workers to the dying base, into the teeth of the attack. Or: Your main mines out and it’s time to transfer workers to a new base, but the enemy is at the gates. So what? Transfer workers through the enemy army.
Or: You’re sieging down static defense, but your attacking tanks/reavers wander too near. Or their supporting units do.
Or: The marine needs to get into the bunker, but a zealot is in the straight line path. Isn’t the straight path the only path?
Or: You’re making a drop. Or: You’re repositioning an overlord or an observer. And so on. I’ve seen bots make these blunders and more.
Bots just gotta be aware of threats. You can’t always know where enemy units are, but when you do, your pathfinding algorithm needs to take them into account. That’s threat-aware pathing. Or anything, as long as it has the same effect.
Leaving aside complications like cloaked units, when a unit or a squad sees enemy fire covering its future path, it has 4 possibilities: 1. It can go in and fight. 2. It can go around the enemy to reach its goal. 3. It can give up on its goal. 4. It can run by, accepting damage to reach its goal.
All four options are important and appear frequently in human games. In more detail:
1. Fight. This makes sense in a lot of cases, but not if your goal is to scout or to transfer workers.
2. Go around. Maybe you can transfer workers over a different bridge and avoid danger. That’s an elementary skill. Maybe you can get drop tech and fly around. That’s an advanced skill. Even if you are intending to fight, it makes sense to stay out of range of as much enemy fire as you can. Burrow the lurkers out of bunker range. Or, when the enemy tanks on high ground can only defend part of the enemy natural, you can slide dragoons into the far side and get shots in until the tanks are able to reposition. (You might want to consider that an issue of micro rather than pathing. Depends on your code.)
3. Give up. If the pather says there’s no safe path, maybe you shouldn’t try. Don’t transfer workers through the enemy army, leave them idle until you can develop a solution.
4. Run by. Bunker, meet rear view mirror. Or let the shuttle take hits, as long as the reaver drops into a good position. If you have a battle simulator that can estimate whether the runby will succeed, it will often be worth it to get in a scout or to aim for the mineral line. (In other words, a battle simulator is more useful if it can simulate runbys too.)
The old zerg bot Berkeley Overmind had threat-aware pathing in 2010. We can do it today too.
Comments