One of the most common user complaints about gaming is the AI. It’s been this way for decades, which doesn’t seem to make sense — computers today are vastly more powerful than systems built 30 years ago. We recently sat down with Brad Wardell, CEO of Stardock and the author of the AI in Galactic Civilizations II about this problem — and how DirectX 12 and improved multi-threading support offer hope of improvement.

The underpinnings of RPG AI emerged relatively quickly. Games like Ultima IV (1985) offered comprehensive conversation trees that allowed players to query NPCs (non-player characters) on specific topics. A major part of Ultima IV’s gameplay involve traveling the world and learning from its various denizens. The approach feels deep, even today, despite the fact that U4 shipped on two double-sided floppy disks.

Ultima V (1988) added a day / night cycle, which means that two of the fundamental building blocks of RPG gaming — robust NPC conversations and realistic life cycles — were shipping nearly 30 years ago, in games of less than 1MB. That doesn’t mean we’ve made no improvements since, but according to Wardell, AI has actually become worse in some respects. There are several interlocking reasons why this is the case.

Scale, cost, and complexity

The first problem, Wardell explained, is that good AI doesn’t really sell games. Gamers may value good AI, but it’s not the determining factor in whether people buy a title. At the same time, AI is now tightly coupled to graphics and must be communicated visually. It’s no longer enough to tell the player, “The shopkeeper looks frightened,” as players want to see that the shopkeeper is frightened.

Virtually all of what we call AI in games relies on scripted sequences, either hand-written or procedurally generated. Bethesda’s Radiant AI, for example, uses procedurally generated scripts to create goals and tasks for NPCs, then allows them to determine how best to fulfill their needs. The company famously had to tone down how the system functioned in The Elder Scrolls: Oblivion after it became clear its original approach produced unintended consequences. In one case, NPCs addicted to a drug called skooma would buy the drug until they ran out of money, then kill the dealer and steal his supply. Players would arrive to talk to the dealer as part of a quest chain, and find he was already dead.

Multithreading and the AI-vs-graphics tug of war

Unlike graphics workloads, which can be easily parallelized and scale well, artificial intelligence processing is difficult to multithread. The job-based systems that many games use for multithreading don’t tend to work well for AI processing, Wardell explained, because the AI is constantly asking questions and must receive immediate answers. Job-based systems are designed to launch and process workloads, not facilitate constant communication between the job and the host CPU.

To understand this better, consider interactions between the player and an NPC shop owner. Bethesda games typically offer you the option to steal goods without penalty, provided no one else sees you doing it. This means the game is constantly calculating the shopkeeper’s line of sight. If you’re trying to sneak around a camp full of bandits, the AI is checking to see how much noise you made and whether the bandits heard it. In both cases, the AI is asking a question and receiving an answer many times a second.

A critical part of the reason why AI doesn’t seem to have advanced much, even though computers today are orders of magnitude more powerful than their predecessors, is because the overwhelming majority of that compute capability has been devoted to making games prettier, not smarter.

Because AI actions and reactions are synched to graphics, AI workloads need to be completed in time for an NPC to react to what’s going on in the world around them. That means AI processing needs to happen within a 10-20ms timeframe — and since AI workloads don’t thread well, the AI is probably running on a CPU core that’s also handling other tasks. Most games display more than one NPC at a time, so all of their collective AI calculations must be handled simultaneously.