AI is already used in video games today, but it is still nowhere near the self-learning algorithms that drive cars or detect cancer in its early stages. Eventually, they will enter the gaming world as well, as they can make games much more variable and also cheaper to develop. But is it just for the good, or are there bad sides?
Since all characters other than the player are controlled by the computer, they need some governing mechanics to act and react to their surroundings. They must become worried if you pull a sword out on a crowded street, fight or run if you attack them, and search for you if you've entered a restricted area. Also, they need to pose a threat in a fight and act with a bit of unpredictability to make the game challenging. The better job they do at reacting to all possible actions of the player, the more immersive the game will be. So, AI aims to make the player forget that they are playing against a computer and make them believe that the world they are in is filled with living, thinking beings.
Gaming AI uses pathfinding algorithms and finite-state machines to simulate the behavior of real creatures. The first method is aimed at telling an NPC where it should and shouldn't go. The algorithms prevent the characters from going through walls and obstacles and help them find the shortest path to the needed location. In modern open-world RPGs like RDR2, NPCs follow a programmed routine to make the place look alive — go to work, visit shops, chat with each other, and go home to sleep.
A finite-state machine is a program covering different rules under which NPCs switch from one state to another. For example, when a police car drives on the street in GTA, they are in an idle state. If the player commits a crime, they shift to a pursuing state and try to close in on him.
The combination of these algorithms dictates NPCs where they should go and what they must do. The flexibility of their actions depends on the number of states they have and the inputs they can respond to.
When self-learning AI is introduced instead of following a limited number of instructions, NPCs will learn how to act in different situations much like a real brain does. Here are the pros and cons it may bring to gaming: