AI in Gaming: How the NPC Becomes Human

SO, WHAT ARE NPCs?

If you are into gaming, you definitely know what an NPC is. If you are tech-savvy and not into gaming, you can stumble upon NPC and its related content with a desultory web browsing. An NPC, short for non-Player Character, is a character in a game that is not controlled by humans. Though the NPCs are programmed by humans, they add life to the game and even pose as opposing characters to us in the game. This article will explore the basics of how AI is used and where it is used. Stay tuned for upcoming articles detailing on the jargons and particularities of this system!


If you know the Red Dead Redemption series (a game series consisting of two parts and one online edition), the characters that you pass in the game while you ride your horse or do anything else are NPCs. The ones shooting at you are NPCs. The ones riding with you are NPCs. So, every other character, except yours, is an NPC.

Some games have bad NPCs, while some have excellent ones. It all boils down to which game has the better algorithm and engine (we will discuss engines shortly) for the NPCs. Now if you imagine Pacman, the game has ghosts as NPCs, and GTA 5 (an instalment of the Grand Theft Auto series, a game series with multiple instalments), too, has tons of cops as NPCs. You may ask, what's the difference between the NPCs of both games? It's how the AI is used.

The ghosts in Pacman have a pattern. Blinky (the red one) always chases Pacman, while Pinky (the pink ghost) is always ahead of Pacman. Inky's (the cyan ghost) behaviour is a bit more complex. It tries positioning itself based on Pac-Man's and Blinky's positions. Inky moves towards a point calculated by drawing a vector from Blinky to two grid spaces in front of Pac-Man, then doubling that distance (some math bull). Clyde (the orange one) would randomly move towards Pacman and occasionally veer off in other directions. So, as we can see, the ghosts' movements are based on mathematical algorithms and calculations. There is no intelligence in the ghosts here.

Pacman, the game


ENTER, AI

Modern games such as GTA5 have very advanced AI algorithms dedicated to NPCs. Try getting chased by cops, and you'll find that they'll always catch up with you, make manoeuvres like humans, and try to bump into you in a way that your car will turn over. How did the computer know how to turn your car over in the best way possible? The computer takes the help of AI.

Nowadays, games have become an integral part of our lives. We do stuff in games we cannot do in the real world, like shooting aliens and racing in super-expensive hyper-cars – a vicarious pleasure we revel in. Imagine venting out your work or college frustration in the real world. Now that would not be good, would that be? But how do you pursue an intense, high-octane, adrenaline-rushing adventure? In Pacman? No way. You can best do it with AI in games. AI makes games much more competitive, so life-like and realistic that we can relate to our life. At the end of movies, you feel like doing the stuff that the protagonist has done. But in a game, you do it. That's where it makes gaming more interesting than other forms of entertainment.

Forza Horizon 4, the game

Now enough about how AI enriches the games. How does it work? How do the game developers make it work? Heck, what is AI? I have heard about it only in movies and now in ChatGPT! Fret not; here we go:

WHAT IS AI?

AI, short for Artificial Intelligence, is a broad term for technologies that adapt, predict, and pursue problems while making informed decisions using past knowledge to solve them. In simple words, they work the way we do. We see something, we learn it, and we use it. We all know guns are used to shoot, right? But only people who have undergone gun training will ever pull a trigger with the best accuracy.

WHERE IS IT USED IN GAMES?

Similarly, AI systems learn the patterns, adapt to them, and then use this knowledge to make decisions. In games, they understand how you play, handle difficulties, and create a table or a model. This table or model is now a concise version of the elaborate moves that you pull in the game. The AI model learns these moves and makes decisions based on them. So, if a cop is chasing you in GTA5, the game is learning your moves and then calculating appropriate countermeasures to apprehend you.

  • The police set up roadblocks, and the police cars find the shortest route to your location (using the A-Star algorithm, the most widely used technique to calculate the shortest paths) or,
  • Based on many observations, even predict where you are off to.
  • Even the random events around you in these games, such as petty crimes, murders, and squabbles, are all AI-generated. 
This is akin to other games like Watch Dogs and Battlefield, where the enemy NPCs not only attack you but also utilise impressive techniques such as crouching behind building walls or shooting in periodic intervals for cover fire, all with the help of AI. Even NPCs on your team try to help you in heated situations. In this way, the developers make the game more competitive, human and entertaining.

An example of the advanced AI in GTA 5

Thus, games can actually do a lot of stuff using AI such as:

  • Enemy AI: Controlling the movements and decision made by the character opposing yours.
  • Mission AI: Controlling the outcome of a mission based on the approach you take and also the minute decisions you make like killing an enemy, or making an arrest instead in games like BF Hardline.
  • Environment AI: Some games even make your environment NPCs behave in a particular way according to your decisions, like in Fallout 4 where NPCs have a like meter that is affected by your decisions. This like meter shows how much an NPC trusts you and if they will help you in future or not.
  • Battle AI: The game will send enemy reinforcements to the fight if you perform well. If your kill count increases, the game will increase difficulty dynamically. Games like Legend of Zelda: Breath of Wild and Metal Ger Solid 5: Phantom Pain utilise this. PvP games like Valorant use this kind of AI differently by matching you with an equally skilled player.

Valorant, the game


GAME ENGINES AND AI

Companies have proprietary game engines. These engines are those systems used to develop games. Consider these engines as just a regular IDE, but only for games, as they include a host of libraries and visual development modules suited to developing games. They are special software to build games. Modern engines can even perform sophisticated AI computations, making the game even better. These engines are particular to the type of games they produce. For example, Rockstar Games, the game that develops the Red Dead Redemption and GTA series, uses the RAGE (Rockstar Advanced Game Engine), and CD Projekt Red (pronounced C D Proyekt Redt), the company that developed The Witcher series uses the REDengine for their sophisticated games. The algorithms they use for the advanced AI mechanism are proprietary. Hence, these algorithms are not publicly disclosed.

RAGE Engine by Rockstar Games



Some even use open-source engines such as Unreal Engine and Unity Engine. Lately, Unreal Engine has been the centre of attention due to its breakthroughs in graphics development. The graphics that the Unreal Engine 5 renders are breathtaking and very realistic. The line between reality and graphics keeps getting thinner because of these developments. Unsurprisingly, these graphics are powered by AI as well, but that's a topic for another day to discuss.

As always, stay techy!


Comments

  1. That is a good article. The emphasis on AI has been a strong topic these days in the world of electronic games. But I suggest you add more technical details to the article. The content that you have posted is useful and informational, but a detailed insight into the technologies being used could prove even more useful to people who might actually want a career in game development.

    ReplyDelete
    Replies
    1. Thank you for the feedback. I will keep that in mind in my future posts and give a little more detail about the game dev world as much as I can.

      Delete

Post a Comment

Popular posts from this blog

The Art of Game Matchmaking ft. AI: The Usage of AI in Online PvP Matchmaking

The Ethical Odyssey: AI's Struggle for Moral Enlightenment