Making the A.I. fortify bottlenecks - part 3
Tuesday, August 26th, 2008Fortifying bottlenecks is now working!
I’ve got all the basics working. Each A.I.-controlled base now:
- examines the terrain around the base,
- analyzes it into passages and junctions,
- stores the passages and junctions into a Boost graph object,
- culls passages that are dead ends (i.e. passages that don’t lead to danger)
- semi-randomly picks a frontier among the remaining passage(s),
- evaluates the frontier of passages for its merit,
- repeats steps 5.-6. until a “high-merit” frontier is found; and finally
- builds towers to fortify that frontier
It works beautifully. I’ve been trying to take some screenshots that show it in action (somewhat tricky to do):
- - - -
Here’s a purple base (far left) facing off against an orange base (right). The orange squares show the orange base’s defensive frontier:
pardon all the debugging text!
You can see the orange base keeps its defensive frontier just out-of-range of Purple’s towers. (The one tower in the middle is Orange’s, not Purple’s).
- - - -
A screenshot from later in the game. Notice that purple has moved his line of towers forward. The A.I. dynamically adjusts its defensive frontier as conditions change in the game, and has a tendency to “push” a line of towers forward, just like a real RTS player often does.
- - - -
Another screenshot, showing the nodes and edges of the Orange base’s defensive graph. The graph reflects the topology of the terrain, though you have to squint to see that.
- - - -
Here, the thick green squares represent the green player’s defensive frontier. The A.I. did a great job in this case - the chosen frontier is (almost) the narrowest point of the entrance onto Green’s plateau. In other words, the A.I. correctly picked the best location.
Picking an optimal defensive location may be obvious and easy to a human player, but getting the A.I. to do it is hard! Sometime, I’d like to post screenshots from other RTS games — AAA ones at that — that don’t choose defensive spots this well! If you’re a long-time RTS player, I’m sure you know what I’m talking about.
- - - -
Another nice defensive line, guarding the approach to a red base.
- - - -
Here’s a screenshot from the greatest game of Orcs vs. Martians I’ve played to date. The random map was fantastic, every A.I. player played well, the defensive frontiers were great, and a huge drawn-out battle developed in the valley at the center-top of the screen.
As you can see, the blue A.I. went a little hog-wild with his defensive towers. Earlier, there was an enemy to his lower-left, which is why all those blue towers are there.
- - - -
The A.I. charging into the “valley of death”.
The reason why so many towers are everywhere, is that the defensive frontier(s) moved several times, so the A.I. kept building new lines of towers.
There’s still some work left to do on this feature. For example, preventing the A.I. from over-fortifying beyond what the A.I. really needs. But all the basics are implemented, and the feature is working great :-)
I feel like this feature really adds to the quality of the gameplay. The A.I. now fights with towers, not just troops! The A.I. can try to push you back using mostly towers, like human players do. Also, I’ve noticed that pitched battles develop much more frequently now. I LOVE pitched battles, with the sieging of some strategic map location, that requires one side to come up with a breakthrough, in either technology or tactics.
So, a big step forward!
The next step is to make the A.I. fortify bases cooperatively. Right now, each base thinks and fortifies independently. That causes a certain amount of unnecessary fortification, i.e. between friendly bases. It’d be more efficient for multiple bases to think together and choose a common frontier that surrounds all friendly bases, assuming they’re close enough. Such a “cooperative” defense frontier could even encompass bases of different players. Even bases of both human and A.I. players.
…Which has some pretty neat implications. Picture yourself located on the front lines in a game, struggling to stay alive…and your A.I. ally(s) come up and start helping you to fortify your base! How often does that happen in an RTS game? Usually, A.I. allies act as though you don’t exist, or worse! With cooperative defense, your A.I. allies would proactively come help you, if they perceive your defenses to be the weakest link. How cool would that be.
Ah…
Can you tell I’m happy about this :-)












