AI has changed the way video games work, and it’s slated to change that even more. NPCs beware.

Let’s get this out of the way:

  • When you think of the words artificial intelligence, you may think “future of technology” or maybe “robot overlords using us for our carbon.”
  • When AI developers think of AI, they think about their grand yet unrealized plans: One day, machines will learn a skill and transfer that skill to another task, just as humans do. They will make decisions without human input. And as a stretch goal, they may dream of electric sheep.
  • When game developers think of AI, they think of something altogether different: the algorithms that drive the decision-making processes behind the non-player characters (NPCs) in games like Grand Theft Auto, Skyrim, or Red Dead Redemption.

At its simplest, gaming AI is just a set of rules that computational agents follow to respond to external stimuli. Modern games feature sophisticated sets of rules, so NPCs follow their own daily routines that can be perturbed by the game player’s actions.

AI purists don’t consider the AI that works under the hood of video games to be “true AI,” which is trained from real-world data to make decisions about the world around it. (Training AI to identify something new based on previous examples is a major field of modern computer science and often called machine learning.) Gaming AI tends to focus on one aspect: the development of algorithms that mimic human behavior. But for the purpose of this article, we embrace the definition given by Theresa Duringer, CEO of Temple Gate Games: “AI is any computer process that’s driving decision-making by an agent.”

AI does what you tell it to do. It may not be telling [the game] to do what you think you’re telling it to do.

Video gamers have used AI since as far back as 1951, when developers created programs for chess, checkers, and Nim. But AI proclaimed its might to the world in a 1997 chess match, when IBM’s Deep Blue turned Garry Kasparov from a winner into only slightly less of a winner. At that point, AI proved that, when it comes to performing multiple calculations in short periods of time, machinery can outthink puny human brains.

By now, machine learning has become accessible to amateur enthusiasts. For example, you can now try it yourself at home, with cerebral thought experiments such as AI Experiments with Google or a fun generative text tool like Tracery. Some developers are training AI to play video games, with the potential to transfer those skills to the real world, which means we’re using video game AI to train more AI.

If you’re now feeling the appropriate mixture of intrigue and terror (Do you want GLaDOS? Cuz that’s how you get GLaDOS), let’s explore.

“More human than human”: AI makes gameplay more realistic

AI creates behavior, whether that’s for NPCs or agents in a game, driving what the characters on the screen are going to do, explains Gillian Smith, assistant professor in computer science and interactive media and game development at Worcester Polytechnic Institute. “It’s what puts life into a game.”

You can see AI at work when you pick off one NPC and its fellow henchpeople become alert and twitchy. They might even determine your location and come looking for you. You also see AI at work when an NPC crouches for cover when you enter a room. Or, if you have a companion, the companion follows you at your pace. Good AI makes your game a place you can inhabit and enjoy.

Poor AI, on the other hand, results in NPCs who do not follow you but endlessly collide into doors. Or NPCs who don’t react when you kill the henchbuddy standing. right. next. to. them. This nonsensical behavior leads to immersion-breaking experiences.

AI is only as intelligent as the programmers behind it, which makes for some amusing problems, particularly when the developers take any simple action for granted. Kate Compton, a doctor of computer science, independent researcher, and creator of the language Tracery, describes this as “emergence,” or “where behavior you didn’t expect starts happening.”

One example of emergence happened when Sims traveled between work and home (locations that are considered a “node”). Instead of using the sidewalk (considered an “edge”), they traveled via the city’s power lines (also an edge). Yes, the characters went where they were supposed to go—just in the least realistic way possible.

“AI does what you tell it to do. It may not be telling [the game] to do what you think you’re telling it to do,” says Compton, who worked as a technical artist on Sim City.

“There is no fate but what we make”: AI can change its play style on the fly

Some video games react to player skill level. Depending on how well you do, adaptive AI ratchets the game’s difficulty level up and down to give you a greater challenge when you need it or to prevent you from rage-quitting in frustration. “An adaptive AI system can adapt to the experience of the players,” says Smith.

AI can also adapt to your play style by making the game more exciting. AI researcher and game developer Tommy Thompson spoke in a video about the AI of Valve’s co-op zombie first-person shooter Left 4 Dead, known as the Director. In his video, Thomspon explains how the game’s virtual George Romero knows when you aren’t under enough stress. (If the enemy is at a distance, you’re not stressed; if the enemy is sinking its teeth into your neck, you’re stressed.) “The Director will focus on players if their stress levels are lower than others,” Thompson says.

“We can rebuild you”: AI can improve the look of old games

Old video games suffer when played on modern monitors, what with bad scaling algorithms and jagged textures. The traditional solution to this problem is anti-aliasing (AA). All modern graphics cards support multiple algorithms, such as FXAA and MSAA for upscaling low-resolution images into images with more pixels. They work by sampling the surrounding pixels to infer the color of new ones, with varying levels of effectiveness.

But AA can take you only so far.

Game modders (both professionals and fan) can now improve the quality of old games, thanks to AI upscaling through machine learning. By training an AI (from game imagery or from images related to the game’s content and art style), programmers can generate new high-resolution art that adds more detail.

Machine learning is increasingly accessible, too. There is a burgeoning DIY enhancement community for improving old video games. Game modders use tools such as NVIDIA’s GameWorks and ESRGAN to refurbish their favorite games—and die valiantly within them—in months instead of years.

“Let there be light”: AI can create game levels on the fly

How do you make a game replayable after you’ve played it before? You procedurally generate its levels. That is, you semi-randomize the game based on parameters given by the developers.

Minecraft generates an entire world based on a single input seed. Space simulator Elite: Dangerous mimics the formation of star systems to create a realistic model of the 400-billion-star Milky Way. With procedural generation, your old game is still familiar yet new—and infinitely replayable.

Because procedural generation doesn’t involve responses to player actions, it’s not technically AI. But it will be, according to Julian Togelius, associate professor in the Department of Computer Science and Engineering at the New York University Tandon School of Engineering.

In games like Red Dead Redemption 2, Togelius says, “you use procedural generation methods for producing the background content, like vegetation and aspects of the geology. But you don’t procedurally generate the quests, the characters, the cities, and important content interaction.”

After AI models the player’s preferences and behaviors, Togelius says, procedurally generated content will create in-game experiences based on what you personally enjoy. “You will come to another town that didn’t exist before you saw it, and it was created based on a model of what you like to do. Maybe you’re in it for the romantic content. Maybe you like horseback racing. Maybe you like shooting, but you’re not good at this, so it doesn’t give you hard challenges.”

Although AI programmers have made big advances in machine learning optimization that generates game content, don’t expect to see AI-based procedurally generated content anytime soon. “Developers are risk-averse,” Togelius says. “They’re hit driven, so they play it safe.”

“My instructor was Dr. Chandra, and he taught me to sing a song. If you’d like to hear it, I could sing it for you”: We can learn from AI

While AI in video games is as flawed as its creators, video games will cause the discipline of AI to improve.

According to David Churchill, assistant professor of computer science at Memorial University in Newfoundland, video games are helping the next generation engage with AI. “For me, as an educator, AI in games are by far the best motivational tool for students that I’ve ever seen,” he says. “If I walk into a class and say, ‘Today we’re going to talk about Starcraft AI,’ the cell phones actually get turned off. It’s an excellent motivator for students.”

We humans are also learning gameplay from AI. Temple Gate’s Duringer says, “AI can come up with novel strategies that we didn’t realize were good strategies because we have human bias. I can turn on debug mode in our game, and I can see the AI is scoring moves I would never make myself as pretty high, which is showing me I’m overlooking strategies I could be paying attention to.”

Because AI doesn’t “think” as humans do, its moves surprise and sometimes confuse flesh-based players, as Deep Blue befuddled Kasparov by sacrificing a pawn.

Duringer and her team keep this in mind when designing their AI. “We don’t take the moves that are most likely to win the game,” she says. “We synthesize our own idea of what a human would expect an AI to do. People seem to like it.”

“Shall we play a game”: AI will improve life outside of the game

Grand Theft Auto IV and V are realistic simulations of real-world New York and Los Angeles. Its AI routines are convincing enough that you can practically smell the smog. That makes them a perfect test environment for training AI with machine learning.

According to Bloomberg, “[In 2016], scientists from Darmstadt University of Technology in Germany and Intel Labs developed a way to pull visual information from Grand Theft Auto V. Now, some researchers are deriving algorithms from GTAV software that’s been tweaked for use in the burgeoning self-driving sector.”

Putting a real AI-controlled vehicle on the road is expensive, legally fraught, and limited in scope, because causing accidents to train your AI to avoid collisions is a terrible idea. But in a video game, you can provide the AI with a real enough simulation of city life to substitute for reality, then create situations for the AI to experience and learn from. This way, you can train your AI that hitting pedestrians is a bad idea—without actually hitting pedestrians.

Now if we could just get those pesky humans to behave more predictably.

This article/content was written by the individual writer identified and does not necessarily reflect the view of Hewlett Packard Enterprise Company.