One of my favorite topics is Artificial Intelligence. I like it so much that I did my master’s thesis on Genetic Programming, a machine learning algorithm that lets a computer create programs.
When we think of Artificial Intelligence, we think of intelligent computer programs that think like, or better, than a human, or we think of a program that is intelligent at a specific task, like IBM’s Watson which competed on Jeopardy.
Creating these types of AI programs is time-consuming and requires vast amounts of computer processing power. Neither of these is practical for a computer or mobile game.
Computer games are limited to how much processing power a computer has and mobile games have even more limitations. Game developers are also limited on how much time and money they can spend on creating their game, a large portion of which is spent on making the game look good.
The good news is, we don’t actually need to create an artificial intelligence in our games; we only need to make it seem as if our characters and creatures look intelligent. The goal of a game is to create a fun experience for the players, not an actual intelligent AI.
Something to consider: what if we did create an AI that could compete against the player? It’s possible that this AI could be too challenging. Players like a challenge, but if they can never win, they will grow frustrated with the game and put it away and play something else.
So how do we make characters and creatures in our games look intelligent? First we need to define what intelligence looks like in a game. It’s difficult to people to point at a game and say “Those characters were intelligent!” However, the reverse is easy to spot, “Those characters were stupid!”
So goal #1, don’t let your AI agents in your game act stupid. Keep them from running into walls, acting completely random, or doing other things that appear to be dumb (like blowing themselves up!).
Keeping them from running into walls is fairly easy with pathfinding algorithms. There are several ways to go, such as A* or using a navigation mesh.
Randomness can be a good thing, but too much randomness does not create the appearance of intelligence. Humans opponents are often unpredictable, but not random. We can use randomness to help us choose between decisions, but we need to temper that with other algorithms to so that those decisions are not always random.
Doing that that appear dumb can be the most difficult. Determining if the AI is dumb usually comes about from a lot of playtesting, however, some things are pretty obvious: don’t use a rocket launcher on a target if the explosion will kill both of you.
There are many algorithms that software developers, mathematicians, and traditional AI researchers have created that game programmers can use to make game AIs that are fun, and more importantly, not stupid.
Algorithms such as:
- Finite State Machines
- Steering Behaviors
- Pathfinding
- Goal-Based Behaviors
- Decision Trees
- Game Theory
- Fuzzy Logic
- Machine Learning
These are all topics that I teach my students and I will be covering most, if not all, in future blog posts.
We are always open to comments and questions, so post a comment or visit our Facebook page at https://www.facebook.com/GameProgrammingAcademy.
Stay in touch, and happy game creation!
Regards,
Greg Miranda