Game AI — basics
Published in
3 min readApr 23, 2022
Pac- Man
- Pac- Man is the first game many people remember playing with fledging AI.
- It has definite enemy characters which seem to conspire against you.
- Pac man relies on simple AI technique — state machine. Each of the 4 monsters either chase you or run away.
- For each state, they take a semi random route at junction. In chase mode, each had a different chance of chasing player or choosing a random direction.
Golden-Axe
- Enemy characters stood still until the player got close to them, whereupon they homed in on the player.
- It had neat innovation with enemies that would rush past the player and then switch to the homing mode, attacking player from behind.
Goldeneye 007
- Relied on characters with small number of well defined states, it added a simulation system: players could see their colleagues & notice if they get killed.
- Other games to use sense simulation — Metal Gear Solid.
Warcraft
- RTS game where first time pathfinding was noticed in action.
The Sims
- Neural network based brain for each creature .
AI in modern games addresses 3 basic needs -
- ability to move characters
- ability to make decisions about where to move
- ability to think strategically
Movement
- Algorithms which turn decisions into some kind of motion.
- When an enemy character without a gun needs to attack the player in Super Mario, it first heads directly towards the player.
- The decision to attack is carried out by set of movement algorithms that home in on player’s location — only then attack animation can be played & player’s health can be depleted.
- Movement algorithms can be much more complex than just homing in. A guard in some levels of Splinter Cell may need to raise an alarm when seeing the player.
- This would require navigating to the nearest wall mounted alarm point which may involve complex navigation around obstacles or through corridors.
- Lots of actions can be carried out by simply displaying animation — If a Sim in The Sims game is sitting infront of a table with food in front of him, we can simply play eating animation to carry out eating action.
- If same character is located by the door, same algorithm needs to guide him to the chair to eat.
Decision Making
- Involves a character working out what to do next.
- Each characters have different behaviours to choose from — attacking, standing still, hiding, exploring, patroling.
- Decision making algorithm needs to figure out which behaviour is most appropriate at each moment of game. Chosen behaviour can be carried out using movement AI + animation.
- Farm animals at various levels in Zelda games will stand still until the player comes close to them — they will move away a small distance.
- Enemies in Half-life2 display complex decision making where they’ll try different strategies to reach player — chaining together intermediate actions such as throwing grenades & laying down suppression fire to achieve their goals.
- Some decisions will require movement AI to carry them out — hand to hand attack requires character to get close to victim. Others can be handled by pure animation.
Strategy
- Required to coordinate the whole team.
- AI algorithms don’t control just one character, but influences behaviour of other characters.
- Each character will have their own movement & decision making algorithm but overall their decision making will be influenced by a group strategy.
- In Half-life, enemies worked together as team to surround & eliminate the player. One would often rush past the player to take up a flanking position.