It may seem like Artificial Intelligence is a fairly new innovation in video games, however, it has been a developing resource for decades now. During the 1940s and 50s, scientists from different fields, ranging from mathematics, engineering, economics, political science and psychology, began researching the possibility of creating an artificial brain.
It was in 1951 that two of the first computer programs in history were written by Christopher Strachey (a program for the game checkers) and Dietrich Prinz (a program for chess) utilizing the Ferranti Mark 1 machine from the University of Manchester. However, it was a program for checkers developed by an American pioneer in the field of computer gaming and AI, Arthur Samuel, in the middle of 50s and early 60s that eventually was able to challenge a respectable amateur player. Since those early days, AI in gaming has risen to an incredible level of success.
AI IN Game Development
Artificial Intelligence (AI) in games is the “intelligence” displayed by the non-playable characters (NPCs). In a game, the various characters you see, other than the player-controlled character, are all driven by some form of artificial intelligence.
These characters you encounter can be good, bad, or neutral, be it enemies who shoot on sight, a crowd of people on the roads, or a friend who fights beside you, AI dictates how all these characters will behave.
The most important aspect of AI for these non-playable characters is that their behaviour must be realistic. If the characters are modelled in the real world, then the need for them to be believable increases even more. For example, in the game Crackdown 3, developed by Sumo Digital, enemy NPCs are present all over the city. The city also has civilians wandering around the streets and doing various activities and talking with each other. If the player starts a gunfight near these civilians, it would look odd if the NPCs continued talking to each other casually in the middle of a crossfire. The AI needs to react predictably to various events and situations in the game.
The core of any AI is decision making. In mainstream games, these decisions can be – when to continue idle behaviour and when to flee, when to attack a player and when to take cover… AI makes these decisions based on parameters such as threat level in the environment, ammo available and distance to a target etc. Techniques such as state machines and decision and behaviour trees are popular to drive AI decision making.
Animation for the actions AI performs also play an important role to make the AI character look real and interesting. For enemy AI, variety in behaviour and types makes the game more interesting, and a player needs to use a different strategy to defeat them. In Crackdown 3 there are various factions and types of AI on the ground, flying drones who can attack the player, and bosses who are special enemies tied to the narrative of the game.
Navigation is an integral part of AI. To reach a target location, various algorithms to find the optimal path and avoid obstacles etc. are used. A player can easily do these things as they can see the game environment, but the AI cannot see in the same sense. The representation of the environment is therefore provided internally to the AI as input and calculations are performed to find out the path to take to reach a target.
Opponent AI needs to be designed so that it is beatable. When faced with a difficult opponent, the player may get frustrated and find it no fun to play the game, additionally, if the AI is perfect and precise, it can appear robotic. So, the AI is deliberately made to make mistakes as a human player would, for example, in a shooting game AI knows the exact location of the opponent but will sometimes take the wrong aim. In racing games, the car AI knows all the optimal routes, but they might be made to go off-route to allow the player to win.
Game designers are responsible for writing documents outlining how the AI will behave and, once the AI is coded, they have many parameters to tune to make it balanced. The design makes sure that the AI is not too hard or not too easy for various difficulty levels and that various parameter are adjusted, for example how fast AI characters move and how much time they take to recover from a blow etc. Once this tuning is done and a major part of the game is complete, user tests are arranged for groups of people who haven’t played the game before and who are preferably in the target audience of the game. These user tests show how well the players perform, how hard or easy they find the game, what areas are confusing or difficult for them and if they enjoy playing the game etc. are noted. Based on the data and feedback, any required modifications are made.
AI is something that must undergo a lot of iteration to get right. It has a lot of parts to it and needs to handle a combination of many different use cases and scenarios. Many different people are behind creating the AI in games, including character artists, animators, programmers, designers, production, QA and even end-users.
Machine learning has been identified as a tool that can result in AI characters having emergent and human-like behaviour, for example, an AI learning from its mistakes and adapting to dynamic scenarios. However, this might not always be what is right for a game because this can cause unpredictability and make it difficult to debug and make the AI behave in a required way. Machine learning can also be used to make developing games easier. It can reduce the manpower required in large and complex games by automating pipelines such as parts of game testing and it can be used in the procedural world and content creation. Machine learning in games is not widespread, but with future advances in technology and new research, it has the potential to become a mainstream tool in game development.
Whatever tools and methods are used, the ultimate aim is to bring the non-playable characters in the game to life through AI and give the player an opponent, companion, or adversary to remember.
By Ganesh Chaudhari, Technical Manager at Sumo Digital