Game Development Reference
In-Depth Information
5.2 Artificial Intelligence
In video games, Artificial Intelligence (AI) is used to simulate human-like intelligence and
intelligent behaviors primarily in non-player characters like NPCs and sprites.
In the project, the behavior of monsters has 2 generic modes: Alert and Non-Alert.
Alert - A monster seeks to attack hero. Alert mode is also referred to as Chase or Seek mode.
Non-Alert - Random movements on the maps, this helps prevent monsters from getting
locked into a pattern. Non-Alert mode is also referred to as Roam or Patrol mode.
An intelligent monster can evaluate its surroundings in real time and perform its actions such
as searching for directions, pathfinding at a crossway, and pathfinding at the end of a path.
By default a monster will be in non-alert mode, as it's not chasing anything. Once an enemy
is detected in the vicinity, it changes to alert mode and begins chasing.
In figure 5.3, the monster in point A is trying to seek the best way to reach the raccoon
in point B. Obviously, the line segment AB is the most effective and efficient path for the
monster to pick as it's the shortest one. However, it can only move towards 4 directions:
forward, backward, left and right, so the most possible path it may choose is a zigzag from
A to B, which consists of a series of chosen directions: forward, left, then forward, left, and
again……
Search WWH ::




Custom Search