Download presentation
Presentation is loading. Please wait.
Published byKristian Hamilton Modified over 9 years ago
1
Artificial Intelligence in Game Design Hierarchical Finite State Machines
2
Actions 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
3
Scripted Actions Visible actions usually limited to set of animations created in advance Can often be sequence of actions: “scripting” Game AI Self destruct sequence Game Engine Poll again when script finished
4
Level 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)
5
Level 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 player “ Faster car has 75% chance of successful pass ”
6
“Guardbot” Example Patrol Move back and forth in front of door Energy at 100% Chase Move towards player Energy = Energy - 1 Player visible Escaped Move towards door Energy = Energy - 1 At door Player not visible Energy below 50% Return Move towards door Energy = Energy - 1 Player visible Fire Player within 2 units
7
“Guardbot” Example Patrol Move back and forth in front of door Energy at 100% Player visible Escaped Move towards door Energy = Energy - 1 At door Player not visible Energy below 50% Return Move towards door Energy = Energy - 1 Player visible Fire Player within 2 units Turning Player in front Forward Player to side Dodge Obstacle in front
8
Hierarchical 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”
9
Hierarchical 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 Turning Forward Player to side Dodge Obstacle in front Start Player to side Player in front Obstacle not in front Escaped Player not within 10 units Fire Player within 2 units
10
Hierarchical State Machines Usually implemented as stack –Push low-level state on stack when enter –Pop and move to next state when finished Start Chasing Guarding Door Chasing Guarding Door Turning Chasing Guarding Door … Escaped Chasing Guarding Door Escaped Guarding Door
11
Exiting 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 Turning Chasing Guarding Door Forward Player in front Return Go to HQ Energy < 50% Emergency recall
12
Exiting Low-level States Can store current low level state and return if necessary once exception handled Build Farm Clear landBuild barnPlant crops Dam break Fix Dam Return to appropriate state when dam fixed
13
Designing 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)
14
Designing 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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.