A few obstacles to coding a good AI
Coding AI for Human Extinction Simulator is an eye opener. Coding the AI for Bret Airborne was relatively simple as there were few parameters to consider and the flow in a match-3 is quite fast that even if the AI isn’t perfect you don’t really notice it or just barely. In a much slower turn-based strategy game though …
Here’s a few obstacles I noticed while coding the “hunter” behavior in HES. The “hunter” behavior means a ship will avoid danger at all cost and ignore all other targets beside the one it’s hunting unless the AI has already moved and have nothing better to do than to shoot the first target available.
Not providing the necessary tools to perform a task
I’m been trying to apply the “hunter” behavior to a frail fighter so it means that most of the time it’s trying to avoid destruction instead of hunting it’s target. It makes sense because that’s actually what I want from the “hunter” behavior but because the fighter is so fragile it seems to just wander around with no actual goal.
This problem wouldn’t be as bad though if the fighter would be able to move longer distances each turns. Its limited range of action means that it can’t pass dangerous zones in a single turn so it just end up looking like it’s fleeing it’s target.
So the AI reacts exactly like how I want it to react but because the fighter has limited movements and is too fragile it seems to be just dumb.
It’s boring when you see the AI trying to use a long-term plan
The fighter would eventually safely reach its target but after so many turns that by now the player can’t see it was the plan all along. When the player is the one making elaborated strategy he sees his plan comes into execution. When the AI do the same you just feel like it doesn’t know what it’s doing.
It also give the player way too much time to change his strategy and making the fighter useless in the end because it won’t have been able to attack anything in time and it’s left alone in the map.
Cornering the AI into an impossible situation
The scenario I’m testing this AI in is probably not the right one. It’s a fairly small map in which the AI and player both have 3 ships. Since the fighter wants to avoid danger at all cost it leaves the AI with only 2 ships that can deliver early damage. Because the map is too small it gives no good options for the fighter to avoid danger. The player can then assume a defensive position that’s able to neutralize the fighter completely.
What can be done
I can allow the fighter to move on greater distances. It do raises the problem that the AI fighter would be stronger than the player fighter. I was hoping to avoid such things but I might not have a choice. I could also make it tougher but then it still end up more powerful than the player’s fighter.
I could not use this type of behavior on a fighter for this map.
I could give more ships to the AI to put more pressure on the player and allow the “hunter” behavior to operate in an optimize fashion.
The more I test this behavior the more I realize that it’s exactly doing what I want but I’m trying to test it in an impossible situation. The same behavior in a different context could become a devastating weapon for the AI but in my testing scenario it’s just a liability.
I spent quite some time trying to figure what was wrong with this behavior. Tweaking it, refactoring it, not understanding why it was so dumb. So basically coding the behavior was quite simple but figuring out how to use was quite complicated.
Coding the AI is one thing. Knowing how to use it is another. Content creation really isn’t that easy.