Introduction to Game AI
Ever since I was a kid, I have loved working on video games. Now, a game has many many parts to it, like:
- Story
- Graphics
- Music
- Game Mechanics (including physics)
- Game AI (both Friendly and Hostile)
I am going to take some time and introduce you to one of my favorite parts: Game AI.
A single intelligent piece of the game (such as an enemy unit), can be considered an “AI Agent”. There really is no on definition of AI Agents, but here’s one that I like:
An intelligent agent is an entity that observes the environment and acts accordingly.
So what an Agent does, can be broken down to three fundamental steps:
- Observe Environment (Input)
- Come up with a response (process)
- Act upon it (output)
For example, an AI Tic-Tac-Toe player would observe the board, select a move, and then make its mark in the selected spot.
Now most of you might think that one only has to care about the process part when designing an agent, but that is actually not true. It is very important to know what an agent can observe from the environment and exactly what type of response an agent can give. So before you can start designing an agent you must take the following 4 things into consideration:
- Sensors -Actuators
- Environment
- Performance
Sensors #
Before you can design an agent that responds to situations, you need to know how exactly can it perceive the situation? What things can it observe? Which variables can it know at any given time?
In some cases, you will have all the information available at any given time, for example a tic-tac-toe game. Sometimes you may only have partial information of the game state, like in a poker game. Obviously this will affect your agent’s design.
Actuators #
You also need to know what kind of output is expected of your agent. Not only does this give you a direction to work towards, but it may also show your agent’s limitations. For example, in a tic tac toe game, you just need to output the location of your next mark, but in a top down tank game, you might not be allowed to simply tell where you want to go. You might have to output how many degrees you want to turn, whether you want to move forwards or backwards, do you want to shoot, etc.
Environment #
A huge deciding factor for any Intelligent Agent is the Environment it will be operating in. This is basically the game you want to build the AI for. The AI will be design based on what kind of the game it is expected to play.
The environment can be of many types. Some factors that describe an environment are:
- Turn-based (Discrete) or Real-Time (Continuous)?
- Fully observable (eg: tic tac toe) or Partially Observable (eg: poker) ?
- Competitive or Co-operative w.r.t to other Agents (including the Player)
Performance #
This is perhaps the most important factor when designing an AI Agent. How will the agent’s performance be measured? Not only does this help you judge if it is working properly, but it also allows you to give feedback to Agent. Most AI techniques use Performance Measures to help the AI learn from its actions. For example if an agent performs an action and observes an increase in the performance score, it’ll learn to do that action more often. Similarly, if an action results in a decrease in the performance score, the Agent will seek to avoid this action in the future.
So these are all the things you need to consider before even STARTING to create your own intelligent agent. As to how we’re actually gonna do that, I’ll cover some other time!