Video game AI – is it even really artificial intelligence?

main

Video game AI – is it even really artificial intelligence?

Gaming has come a long way since its humble 8-bit origins. While some changes, *cough*graphics*cough* are easily visible; the changes under the surface usually go by unnoticed – even though those changes are probably far more important than what we see on the surface. Game creators were coming to the realisation that just good looks and fancy animation wasn’t going to be enough to impress gamers. While graphics were the main indicator of a game’s quality for the longest time, it was now time to focus on video game AI as well.

No, the AI we’re talking about are nothing like System Shock’s SHODAN

In addition to graphics, we’ve also seen a lot of growth in online gaming. Playing online with other people is nice and all, but it would be foolish to forget what keeps us company on our single player adventures. Again, we’re talking about video game AI here. Because if you think about it, they’ve been with us since pretty much forever. Almost every game you’ve ever played has some kind of AI in it, be it the villain, the mobs, your companion, the opposing team, it’s all AI.

So first things first, let’s get the basics out of the way.

What exactly is video game AI?

A simple example of having multiple conditions i.e. IFTTT scripts

Artificial Intelligence can be thought of as the brain of the game. This is what governs how everything happens in the game while you’re playing it. This includes adapting to the user’s actions as well. Everything from the NPCs and how they walk around, to the enemies and their attack patterns, is handled by this pretend brain.

But here’s the kicker, if you look up the definition of intelligence online, you’ll find that it’s defined as “the ability to acquire and apply knowledge and skills.” Video game AI doesn’t do this, not by default at least. If anything, the AI in video games is more of an ‘if this then that’ (IFTTT) script. A LOT of IFTTT scripts, running side by side. Depending on the scale and complication of the game these scripts can be ridiculously lengthy. The more freedom you have to approach a situation, the more ifs are added to that script.

So how is video game AI different from actual AI?

Simply put, video game AI doesn’t react, even though it looks like it does. The computer simply understands the ‘if’ condition and performs the ‘that’ action accordingly. You do this well enough, and it’ll look like you’re actually reacting realistically. Video game AI today use multiple conditions to simulate a realistic reaction. In addition to multiple IFTTT scripts, developers could make them even more complex, by making ‘if this and this but not this then that and that’… and so on; you get where we’re going with this. The more complex it becomes, the more intelligent the video game AI seems. And since it’s all running on a computer, the ‘that’ action takes place fast, so it definitely seems like an instant reaction which simulates intelligence.

For example, have you ever noticed that sometimes, when fighting an enemy in a certain way, or if a certain method is working out for you against them, they change tactics to avoid that method. Definitely seems like the enemy is intelligent and adapted to your playstyle, doesn’t it? While it looks like the AI learned and adapted from you, it’s not actually the case. Developers often make it so that the game keeps track of what you’re doing, and if you’ve done a certain action a certain number of times, then the AI will change behaviour accordingly.

Rubber band AI

Simply put, it’s AI that matches your skill level. Level scaling and all that good stuff. Basically, the game keeps track of your skill, how well you handle levels, enemies, etc. This of course applies to every genre of gaming; your opponents in racing games, sports games etc. Rubber band AI is a part of Dynamic Game Difficulty Balancing, or Dynamic Difficulty Adjustment (or DDA for short) which scales the AI in real-time to match your skills and give you a better challenge.

The AI in Mario Kart are a good example of scaling Rubber band AI

So now that we’ve established that video game AI isn’t actually intelligent and doesn’t think for itself – let’s find out how it actually works.

How does video game AI work?

AI began as shorthand for a bunch of rules. In more technical terms, it’s a bunch of rules written directly into the game’s code. The computer interpreted these rules and ran the Appropriate behaviour scripts depending on which rules had and had not been met with. This was pretty much all there was to it, at least back in the 1970s.

Metal Gear Solid was among the first to do stealth games right

Games were pretty simple back in the 70s. We’re talking games like Donkey-Kong and Boulder-Dash. However, as player demands grew over time, so did game complexity. With more complexity came the use of more and more advanced algorithms. Modern game engines are some of the most complex applications written. While game scripts used to be written as single entities before, they were now split into various modules which focused on aspects like rendering, artwork, level design and of course, artificial intelligence. We’ve moved past simple algorithms and use complex and advanced methods to govern AI nowadays; from neural networks, to genetic algorithms, and fuzzy logic.

Metal Gear Solid 5 on the other hand… maybe takes that too far

There’s different scripts and algorithms for different genres. For obvious reasons, a script written for an FPS game obviously won’t work with an RTS game. We’ll try to cover the basic structure of the AI in some of the more common gaming genres.

AI in First-Person Shooter (FPS) games

All games make use of a layered AI structure which functions based on a hierarchy. In the case of FPS games, how this works is, the lowest layer in the hierarchy handles the more simpler tasks. This includes tasks like finding the best way to the target (i.e., you). As you go higher in the hierarchy, the tasks get more complex, such as tasks involving tactical reasoning (take cover, shoot, alert nearby AI etc).

F.E.A.R. has some of the best AI ever seen in video games

AI in Real-Time Strategy (RTS) games

In RTS games, there are several different AI modules within the structure of a level. Each module handles different tasks. One module would focus on pathfinding, i.e, finding the quickest way from A to B. Another would detect collisions; making sure units didn’t collide with the environment or each other. This is especially tricky in RTS games, because a large number of units have to be taken into account.

The first Warcraft did unit pathing far better than any other RTS of its time

AI in Racing games

Racing games use a slightly more complicated version of the ‘getting from A to B’ algorithm. The map or world of any game – in this case the racing course – can be represented as a graph. The AI makes use of this data and calculates the fastest way (depending on the difficulty of course) to reach the destination. The higher up the hierarchy you go, the more things it accounts for, i.e, slowing down when approaching curves, bends, avoiding objects on the road, other cars, etc. What may look like an improvement in AI skill is actually just the AI making use of better pathing to get to the destination faster.

Forza’s Drivatar attempted to learn from players. Didn’t work out too well

AI Libraries

Wheatley is another iconic AI from the world of video games

As you can imagine, the above descriptions are simplified explanations of the AI modules these games actually use. The code these games use now are insanely huge! Developing an AI module from scratch – for games as advanced as the ones we have today – would take forever. Only AAA companies can actually allocate the manpower needed to do that; we can’t imagine every developer has that luxury. However, for this purpose, there are existing AI libraries which developers can purchase. These libraries make use of more commonly used algorithms, which you see in almost every other game. For example, the ‘getting from A to B’ algorithm that came up in all three of the previously mentioned genres is popularly known as the A* (A star) Algorithm. The A* Algorithm in simple terms, is a pathfinding AI module.

AI.implant

One such software module is AI.implant, which features advanced algorithms for path finding and planning, and decision making based on binary decision trees (basically, a more complicated IFTTT). It’s got an especially sophisticated group behaviour module. You know, for when you need to populate your cities with NPCs. AI.implant has the added advantage of being able to work in close integration with programs such as Autodesk 3ds Max and Maya. AI.implant works across multiple platforms, with support for Windows, Linux, Xbox 360, and Playstation 3 applications.

xaitment

Two other good examples of AI modules are German based company xaitment’s xaitMap and xaitControl modules. xaitMap provides runtime libraries and tools for navigation mesh (or NavMesh) generation, pathfinding, avoiding collisions, and individual and crowd movement. Meanwhile, xaitControl is a finite-state machine (one of the least complicated and most frequently used AI algorithms) for logic based behaviour modeling. xaitment also works across multiple platforms, with versions for Windows, Linux, PlayStation 3, Xbox 360 and Wii. It’s also currently integrated in the Unity game engine, Havok’s Vision Engine, and GameBase’s Gamebryo engine. And that’s about all we can tell you without getting too technical.

Anyway, that was a very basic idea of how AI functions. We know that there’s a lot of other genres and modules out there but it would take a lot more space (that we don’t have) to cover all of them.

How does video game AI impact your game? Where do we go from here?

The primary thing we should pick up from this article should be the fact that video game AI isn’t really AI. Not the kind based on cognitive functioning anyway. It’s just algorithms. However, that doesn’t mean that you can’t get it to do what you want it to. If a programmer does a good job of it, then it may as well look and feel like real intelligence. Even if it actually really isn’t. As one of the Hosts in Westworld famously said “Well, if you can’t tell, does it matter?”

Doom 3’s AI was so bad, you could fool them with a table and watch them endlessly bump into each other in a corridor.

We all know how much of an impact good AI can have on a game, take F.E.A.R. for example. The AI in F.E.A.R. was ahead of its time and is still praised to this day. On the other end of the spectrum, bad AI can ruin an otherwise potentially great game, Doom 3 immediately comes to mind here…

But where do we go from here? Even more complicated engines and modules? Even more IFTTT conditions? Will we finally have modules that account for every single possible condition that may occur? Or perhaps the next step in video game AI, is actual AI.

SKOAR! is India's Premier Gaming Website. SKOAR! began its journey as a bi-monthly publication in 2003 and has since kept growing. Through this journey, it has evolved from a purely print magazine to an interactive magazine and now, has made its foray into the digital space. BTW, why on earth are you reading this part? Ran out of articles to read? Weren't we entertaining enough? Maybe you're just bored, so you might as well go pester the editor or troll someone in the comments ;-)