Why am I Writing an AI now?!
At first I was going to make some random target drones spawn to create and test unit combat behaviors on...And I decided that was boring. So I wanted to test my guns on something a little bit more fun, a base that the computer frantically built for me.
So, I wrote an AI. The AI class is a derivative of the Player class, except the AI has its own internal decision making engine (and, unlike the player, it has an internal copy of all its units. This way it can modify them and send them back to the main game loop instead of uglier options).
AIs in other RTS Games
A common complain with RTS games is that the AI is not hard enough. Mods are created to try and make AIs harder, often by simply removing their economy limits so they can expand freely. This is lame. I have decided that my AI is going to be a very special animal.
How Smart is it?
Totally unintelligent at this time. I bet the gnat buzzing around my room could outthink it, if it was pure thought involved. However, the AI has the ability to instantly make choices and place structures, outpacing the player at developing a base and attacking. For a really good example, check out this YouTube video (note: for best results, watch fullscreen on maximum quality).
Trying to out produce the AI on maximum difficulty would be like trying to race a Cheetah.
(And the song is not in the game, it was added to make watching this possible. As of now, BoS is still a silent movie.)
How does it work?
The AI is divided into 4 game stages: Early game, early mid-game, late mid-game, and late game. The early game segment is complete. Notice that it prevents its economy from stalling by building power generators before the power level even becomes an issue.
In this stage, it follows this loop:
- Do I need more energy? If so, build a power plant first.
- If I have sufficient power, make a frigate factory and missile defense.
Did you expect more? More is not better. Most experienced online RTS players will tell you that staging to outproduce your opponent is the best way to win later. People who go directly for leveling up technology tend to get smashed quickly by them.
How Smart will it be?
Quite smart. There are several interesting techniques for making AIs have basic understanding of their environment. The most promising is the death tile. Basically, the AI has a mental map of tiles that stand for segments of the map. Every time one of its units dies in a segment, it charts it. A tile that has a bad kill death ratio becomes an avoid point.
This means that it will be able to probe for and remember weak points in your base defenses and fleets. It also means that any artificial choke points you attempt to create will be mapped by scouts upon death.
In addition to that, I plan to implement:
- Counting of your base defenses to determine what planets are most vulnerable instead of merely attacking by proximity.
- Creating fleets specifically to intercept fleets you send, instead of using the attack force it has been building.
- Theft of your ship fittings that get the most kills, and your top-used fittings.
- Intelligent research structure that does research relevant to what it is fielding. If you are only using missiles why research better particle weapons?
- Any other evil features I can think of.
For those new to the game, you will be able to scale down the difficulty by selecting the amount of time in seconds the AI must wait before doing something else in its list. 0 (shown in the video) is hardest, while 20 will be easiest.