Programming Singularity’s artificial intelligence was all about variety and usability. Providing compelling tactical AI was just one small part. We also needed melee and creature AI, and the AI had to interact with super-powered sci-fi attacks. Additionally, a large part of my job as an AI programmer was providing designers with flexible, powerful tools created to ease the set up of multi-stage, varied combat.
In order to accommodate as many different types of AI as possible and still share code between them, we developed a data-driven hierarchical finite state machine, or HFSM. We also created a visual editor for these HFSMs so AI programmers and technically-minded designers could rapidly prototype and fine-tune AI. Using the editor, it is easy to pick the states an AI should use, like “Cover” or “Melee Attack.” Then you can arrange those states by priority and configure parameters governing their behavior. For example, you can change the preferred distance between cover and the AI’s current enemy. This allowed a minimal amount of code to manage different AI, and made behavior iteration really efficient – you could even change AI behavior as the game was running!

For tactical combat, it’s a fact that a game’s AI is only as good as its scripting, so it was essential that we provide tools to designers to make it easy to set up compelling combat. We took several steps to make it easier to spawn in AI, and to instruct them how to advance towards the player, fall back, or bring in reinforcements.
Here’s an image of a combat space without any AI information:
Now here’s an image where you can see several different things we’ve done to help our designers and scripters guide the AI.
In the image, you can see the cover nodes placed behind the barricades, with both the actual cover spot in red, and some nearby spots in blue, which the AI falls back to if it can’t get a good shot at the player. We added this to help the AI be effective without breaking them out from the “cover” state.
The pink cylinders represent regions or “tethers” to which the AI can be restricted by our designers. Then, when certain conditions are met, the script can tell the AI to move forward or fall back.
Finally, the soldiers you see represent special nodes where the AI knows to play a custom “jump down” animation when they want to move to the ground below. This gets automatically cooked into the path-finding information.
Here’s the final result, where you can see AI using some of the cover nodes in this area:
This is just a taste of some of the things the AI team worked on to make Singularity. It has been a very rewarding challenge to develop the AI for the game. I hope you enjoy the end result as much as we enjoyed making it!
Willie Ryan
Senior Software Engineer
Raven Software
