Some of the computer opponent’s stupidities have been bothering me for a long time. Although AI performs rather well in micro-level (aims quite accurately and even has some creativity with special modules), it completely lacks strategic thinking by taking stupid risks and wasting ammunition in harmless situations. The real challenge is, that AI should be less aggressive and suicidal, but not too careful. Otherwise battles tend to end up in a situation where AI refuses to do anything.
I made some improvements to make things better:
- AI is now better at calculating its close-combat strength relative to opponents, and taking advantage of it. It knows to keep the distance to stronger ships and rush towards weaker ones.
- Bonus objects aren’t prioritized as high as before. AI is less eager to reach them when the win is already on hand.
- AI has had a tendency to shoot bonus objects with cannons for no reason. I thought I had fixed this multiple times, but it always kept coming back. The final (hopefully) fix required a bigger refactoring to the AI architecture.
My AI code is divided into three parts that can be executed simultaneously: movement, cannons and special functions. The division is clear and works well, but better cooperation between the components is needed. For instance, the bonus object issue was because the AI first aimed cannons, but then tried to attract the bonus with a tractor beam. The latter behavior re-positioned the crosshair, which made cannons shoot in the wrong place. Luckily, shooting only takes one frame, so it was enough to tell secondary modules to hold on until the cannons are done. Once again, I consider this fixed. Expect to hear more about similar issues in the future.
I found it hard to visualize this subject, so here’s an unrelated picture of a drunken spectator about to fall down the stairs: