Title: Artificial Intelligence in Game Design
1Artificial Intelligence in Game Design
- Hierarchical Finite State Machines
2Actions Chosen by AI
- AI chooses actions game engine performs
- Internal state
- Example Which city boss NPC chooses to attack
- Visible actions
- Example Whether orc attacks or defends
- Must be at level of detail that game engine
expects
3Scripted Actions
- Visible actions usually limited to set of
animations created in advance - Can often be sequence of actionsscripting
Self destruct sequence
Game AI
Game Engine
Poll again when script finished
4Level of Detail in Graphics
- Only render graphics at detail necessary for what
player can see - Close up full detail
- Facial expression
- Detailed motion
- Far away little detail
- Basic body shape
- Simple motion
- Minimize load on graphics engine
- Few NPCs need to be rendered in full detail
(usually one at a time)
5Level of Detail in AI
- Only use full AI when necessary
- Fast approximations in other situations
- Often when NPCs off screen
Use full passing AI for cars visible to player
Simple rule for cars not visible to
playerFaster car has 75 chance of successful
pass
6Guardbot Example
Chase Move towards player Energy Energy - 1
Player visible
PatrolMove back and forth in front of
door Energy at 100
Player within 2 units
Player not visible
Player visible
Escaped Move towards door Energy Energy - 1
Fire
At door
Energy below 50
ReturnMove towards door Energy Energy - 1
7Guardbot Example
Player in front
Turning
Forward
Player visible
Player to side
Obstacle in front
Dodge
PatrolMove back and forth in front of
door Energy at 100
Player visible
Player not visible
Player within 2 units
Escaped Move towards door Energy Energy - 1
Fire
At door
Energy below 50
ReturnMove towards door Energy Energy - 1
8Hierarchical State Machines
- Problems with Finite State Machines
- Too complex
- Potentially hundreds of states
- Design difficult
- Debugging impossible
- Much duplication
- Many blocks of states similar
- Example Return state also needs Turn, Move,
and Dodge - Many transitions similar
- Example Need low energy transition from all
states in Chase
9Hierarchical State Machines
- Single high-level state contains entire low-level
FSM - Need initial state that high-level passes control
to - Need final states that correspond to transitions
from high-level state
Chase
Escaped
Turning
Player not within 10 units
Player to side
Obstacle not in front
Dodge
Start
Player to side
Player in front
Obstacle in front
Forward
Fire
Player within 2 units
10Hierarchical State Machines
- Usually implemented as stack
- Push low-level state on stack when enter
- Pop and move to next state when finished
Start
Turning
Escaped
Chasing
Chasing
Chasing
Chasing
Escaped
Guarding Door
Guarding Door
Guarding Door
Guarding Door
Guarding Door
11Exiting Low-level States
- Interrupts may cause exit before task is
completed - Example Caution flag interrupts passing
- All states on stack may have interrupt conditions
- Check all at each frame
- Better than having same transition for all states
Player in front
Forward
Turning
Energy lt 50
Chasing
Return
Guarding Door
Emergency recall
Go to HQ
12Exiting Low-level States
- Can store current low level state and return if
necessary once exception handled
Build Farm
Clear land
Build barn
Plant crops
Return to appropriate state when dam fixed
Dam break
Fix Dam
13Designing Hierarchies
- Task based
- Major tasks NPC performs
- Guard
- Patrol
- Defend
- Steps in tasks
- Wait
- Chase
-
-
- Motion
- Turn
- Move
-
High level character design team (works with
game designers)
Task subteam
Character motion team(works with animation team)
14Designing Hierarchies
- Strategy Level
- What goal does character attempt to meet?
- Build, attack, negotiate
- Tactical Level
- How does character meet current goal?
- Which city to attack
- Which resources to use
- Motion Level
- What action does character take this turn?
- Move forward, left, right
- Corresponds to animation