Making games is an art. This is a very complex, time-consuming and painstaking process, which is being worked on by a whole team of specialists of different profiles: programmers write code, designers draw the world and characters, scriptwriters work on writing an interesting story. Artificial intelligence in games is represented by numerous NPCs, or NPCs (not playable characters).
Without a well-written AI, the game becomes boring, repetitive and uninteresting. It doesn't really feel alive. Now we will try to figure out how artificial intelligence works in video games, how AAA projects manage to show a truly living game world.
Simulation like an illusion of life
With multiplayer games, everything is simple, in which NPCs do not play a particularly important role and serve only as a means to achieve certain goals. The key moments of the game occur in interaction between the players themselves. But single-coil projects require excellent AI, because the NPCs here are the only ones the player contacts with throughout the game. And if they all do the same thing or just stand still, the gamer will become bored, and he will no longer play this game. The clearest example of real life simulation is the recently released Red Dead Redemption 2, where each NPC is busy with his own business, which creates the illusion of the real world for the player. Watching the life of virtual people is truly impressive. However, everything is just ordinary program code, and there is nothing supernatural in it.
Each NPC, both in RDR2 and in other games, does what is written in his code. He has one or more pre-recorded actions that he will take when the player approaches. As soon as you go around the corner, the NPCs and the entire game world out of your sight will simply freeze. Some of the NPCs can talk to the player with seemingly random phrases. Or, if you perform some specific action in the game, some NPCs may activate new phrases that will comment on this event. This is how the illusion of life in the game is created: by the program code, if's and while's.
Think Far Cry 4 or Assassin's Creed Odyssey, where even animals are constantly fighting with each other, which looks just incredible. The lion hunts smaller animals, the wolves kill the deer in flocks, the bears fight to the death among themselves. How does all this magic work?
It's very simple. Fights between various NPCs without player participation existed in games even before the clashes of Spartan and Athenian soldiers in Assassin's Creed Odyssey. In fact, we have two warring factions with each other, and when different NPCs from both factions meet, a clash occurs. They will fight among themselves as long as there are no representatives of the hostile faction left. The same thing happens between animals. They randomly roam the woodlands, and when they cross each other, they fight to the death.
Another possible option is two neutral factions in relation to each other, but hostile to the player. If they all attack the player at the same time, they can accidentally hit each other and continue the battle without him. The same rule applies to allied NPCs for the player. They, following the player, will attack all hostile creatures and will not go further until they have destroyed every enemy in sight. You must have always been pissed off by the fact that your escort was constantly getting involved in a fight and did not want to go further until you killed everyone. Don't blame the poor guy, he's just programmed for it.
The harder the more realistic
Many people think that if one hostile NPC is stronger than the rest, some elite boss, for example, then he is smarter. In fact, artificial intelligence has nothing to do with it. The developers simply overestimate the characteristics of individual NPCs to make it harder for the player to win, that's all. And it works. Trying to defeat the main boss for a long time, it really seems to us that the more difficult, the more realistic. After all, he is the main boss, and must be stronger than the rest.
There are usually no more or less smart NPCs in games. They all have the same artificial intelligence, but their actions and characteristics are different.
It may seem to you that the smarter are those NPCs who use various shelters and interact with the environment. But no, in theory all NPCs can do this, but not everyone has such actions.
How artificial intelligence is superior to the player
Yes, literally everyone. AI can perform absolutely any actions that are prescribed for it by developers. And these actions are often not entirely honest. For example, everyone knows what RTS strategies are: Warcraft, Starcraft and others. When playing against AI in such games, you may notice that the enemies not only build their buildings and earn resources faster than you, but also easily repel the attacks of your units. This is because NPCs, or bots, are not entirely fair.
Firstly, they do not collect resources, but simply get them literally out of thin air. That is, your resources are limited, while the NPC's are endless. So, of course, not in all games, but in the majority.
Secondly, they also "cheat". Bots see everything you do: what buildings you build, what units you create, and immediately apply countermeasures. For example, you have recruited an army of flying units, and your AI opponent already has an army of units that have increased damage against flying enemies. You will think that this is a coincidence, and the developers will laugh. And by the way, if you spend any amount of time creating certain units, then artificial intelligence does it instantly. This is the complexity of RTS. But after all, overcoming certain difficulties, it becomes much more interesting to play, isn't it?
Among other things, NPCs can automatically adjust to the level of the player or build strength over time. If at the beginning of the game you easily throw everyone to the right and to the left, then towards the end you will need to be more careful. It also adds
Problems of artificial intelligence in games
Artificial intelligence isn't perfect. It's okay, it's artificial. Yes, and intelligence does not shine like Skynet. Maybe it's for the best. So, let me introduce the most serious problems of artificial intelligence in games:
Unlimited view. Let's remember Assassin's Creed and similar stealth games again. Does it infuriate you, too, when you move at a great distance from a hostile NPC at night, and he notices you literally a kilometer away just because he is turned to face you? Naturally, the NPC's view range is usually limited, but no one is safe from bugs or irresponsible developers. And it also happens that you are sitting in some kind of shelter, hiding, everything is fine with you, and then an armada of enemies suddenly starts to run at you, because one of them had an error in the code and he saw you through the impenetrable thickets ...
Teamwork. Under normal implementation, this is more of a plus than a minus. After all, it's always nice to watch NPCs talk to each other and cooperate to defeat the player together. Then they seem even more alive. But everyone had a similar situation: a stealth mission, you are sneaking around the location, and then one NPC accidentally notices you. You successfully manage to kill him, but no, you do not have time. An entire army has already left for you. What how? He didn't even have time to shout, why suddenly everyone knew where I was? But because. Ask the creators of the Fort Conquests in Far Cry 3.
Unfairly strong. I already spoke about this a little higher. Even if you are an unrealistically tough player, and have captured all the points with resources on the map, playing against artificial intelligence, he will surely suddenly have resources that will definitely be enough to slap you with bream.
Limitation. Each NPC in the game is limited only by its own program code. And that's okay. But for some reason, there are so many limited characters among them that I would not call it intelligence, albeit artificial. For example, if an NPC is following you and you are walking too fast, he may simply stop as he loses sight of you. Even if you are walking on a straight road: ten meters ahead and that's it, a stupor. Or the NPC, who only in the cutscene tore enemies in half, in the game itself just stands and pokes at them with a sword, without even causing damage, so that you have to kill everyone around you yourself.
Scriptedness. Yes, each NPC has its own script of actions that are repeated in a circle. It is clear that they will not be able to come up with something new on their own, but when you play one game long enough, you begin to notice that the world around you is not really alive, but constantly doing the same thing. Each according to its own scenario. Phrases and actions someday end, but the game continues. And it’s not so much fun anymore. Although this is more of a game protractedness problem than artificial intelligence. Playing the same Assassin's Creed Odyssey for 90 hours, it starts to seem to you that everything around is the same, all NPCs are doing the same thing, although at first you were delighted that you can talk about something with each of them something different, each was engaged in different matters.