An Introduction to Artificial Intelligence in Video Games

I first became interested in the subject of AI back in March of 2017, when I was on spring break in my senior year of high school. I was reading a book on beginning C++ programming, and I remember the author began discussing how to program a Tic-Tac-Toe game with an Artificially Intelligent opponent. As I observed the C++ code and typed the source code onto my computer, the more I realized how the games I play use artificial intelligence.

For example, one of the most interesting games that uses AI is Animal Crossing for the GameCube. For people who haven't played that game, essentially you are a kid that moves into a new town and you buy a house, and the whole goal of the game is to interact and socialize with other animals, pay off your debt, and purchase new daily items at Tom Nook's shop! Not to mention, that game even mimics the current weather outside in real life in the video game (i.e. if it is raining in real life, it is either rainy or cloudy in the game). One day in the game represents one day in real life; it matches your calendar on your GameCube. But the AI still fascinates me, because every animal in that game has its own personality and almost every time you talk to that same animal, they say something different. There must be hundreds of sayings! The animals even know the time you last talked to them (i.e. the number of days in real life that have gone by). The animals make a lot of decisions for themselves too, like fishing or running around, or even testing you with questions! It is really a brilliant, yet simple game. All you have to do is talk to animals and upgrade your house by finding money or selling items. 

Anyway, as I mentioned before, Ben Sawyer in his book The Ultimate Game Developer's Sourcebook discusses Artificial Intelligence, and I wanted to highlight some key concepts related to AI that I've learned. I don't want to describe anything super technical here because it would probably be extremely confusing to people who haven't seen algorithms before. I am also still learning some of these algorithms myself!

Nevertheless, here are a few important ideas he discusses about AI, but in my own words:

*Note: an 'agent' usually refers to any interactive object or entity, such as an AI, within a game.

  • An Artificially Intelligent agent in a game represents a non-player controlled object that appears to make decisions similar to that of a person in real life using a decision-making algorithm. This algorithm processes information provided by the program, where the rules of what kinds of decisions to make (and possibly when to make them) have been formulated by the game designer or programmer himself.

 

  • An Artificially Intelligent agent makes decisions depending on certain factors or conditions, not randomly. For example, these decisions may revolve around the external environment, such as the numbers of threats near the AI's base, or the time of day and a human's hunger level. For example, if the player has an army surrounding the AI's base, then the AI may decide to send all its troops to that location to protect its base after taking 1/2 damage. Or If it is around noon to 2 P.M. sometime, usually a human is hungry for lunch. Thus an artificially intelligent agent at this time in the game may say "Man, I need to eat lunch."

 

  • The hardest part of Artificial Intelligence in video games is the fact that few decisions are "cut and dry", meaning that most decisions either aren't simple to make or sometimes overlap. For example, in real life, you may schedule to hang out with a friend and go to the movies, but you also have to consider "how do I get to the movie theater? Do I drive or is my friend picking me up? Will I need money for food? What time do I leave? Do I need to reserve seats online?", etc. This is why AI depends a lot on Game Theory, and requires a set of actions (or decisions) to be made with certain rules defined in an algorithm. The more factors your algorithm considers, the more realistic your characters may react. This is especially important in games like the Sims or even in sports games like Madden

 

  • As long as the AI appears intelligent to the player without seeming TOO smart, then the game will seem realistic and thus more entertaining. If your AI appears to be too powerful or "cheating" in the eyes of the player (say, by seeing everything you have and knowing your strategy) , then the AI will actually seem literally "artificial." Just like humans, Artificially Intelligent agents must appear to make mistakes at times! This makes them vulnerable and more realistic! Otherwise, the game becomes frustrating and unfulfilling.

Hope that was all interesting! See you guys tomorrow!

AI.png