42
Scaling Up To More Scaling Up To More Sophisticated AI Without Sophisticated AI Without Overburdening Developers - Overburdening Developers - Lessons Learned Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Embed Size (px)

Citation preview

Page 1: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Scaling Up To More Sophisticated AI Scaling Up To More Sophisticated AI Without Overburdening Developers - Without Overburdening Developers - Lessons LearnedLessons Learned

Scaling Up To More Sophisticated AI Scaling Up To More Sophisticated AI Without Overburdening Developers - Without Overburdening Developers - Lessons LearnedLessons Learned

Marc Atkin

Irrational Games

AGDC 4-Dec-2004

Page 2: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

MotivationMotivationMotivationMotivation

Page 3: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Why Do We Want Better AI?Why Do We Want Better AI?Why Do We Want Better AI?Why Do We Want Better AI?

• Bad AI is always noticed

• AI often inconsistent between games – why can’t we build on previous work?

• The AI is a big part of what makes a game world immersive and fun

Page 4: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

What’s Stopping Us?What’s Stopping Us?What’s Stopping Us?What’s Stopping Us?

• What makes AI complex?– AI has many possible reactions to

many situations– Many behaviours are operating on

the AI at any given time– Hard to account for all the possible

interactions

• Impression that academic AI research isn’t applicable (too slow, too complex, too flaky)

Page 5: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

The Basic Idea: Use ModularityThe Basic Idea: Use ModularityThe Basic Idea: Use ModularityThe Basic Idea: Use Modularity

• It’s not just for coding anymore!

• Produces AI that is easier to understand and debug

• Produces AI that it reusable within and between projects

• The key point: Design the AI architecture so that it facilitates modularity

Page 6: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Tribes: VengeanceTribes: VengeanceTribes: VengeanceTribes: Vengeance

• First-person shooter

• Emphasises speed and freedom of movement (jetpacks!)

• 3rd in the series

Page 7: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

AI ChallengesAI ChallengesAI ChallengesAI Challenges

• AI works in service of the game:– AI characters shouldn’t act stupidly– yet still be fun to fight

• AI’s should exhibit diversebehaviour

• AI’s should jetpack and ski• AI’s should react to their environment• AI’s should have recognizable roles

– Sniper, duelist, mortar user, etc.

Page 8: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

System OverviewSystem OverviewSystem OverviewSystem Overview

NavigationSystem

NavigationSystem

PhysicsSystem

PhysicsSystemAIAI Game

World

GameWorld

PathfinderPathfinder

AnimationSystem

AnimationSystem

Page 9: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

What makes our game What makes our game characters “intelligent”?characters “intelligent”?What makes our game What makes our game characters “intelligent”?characters “intelligent”?

• A large set of sophisticated, hand-designed behaviors

• Common sense reactions

• The ability to exploit opportunities

• A consistent long term viewof tasks to be accomplished

Page 10: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

What makes our game What makes our game characters “intelligent”?characters “intelligent”?What makes our game What makes our game characters “intelligent”?characters “intelligent”?

• A large set of sophisticated, hand-designed behaviors

• Common sense reactions

• The ability to exploit opportunities

• A consistent long term viewof tasks to be accomplished

Tyrion: An architecture forspecifying and executingAI behaviour

Page 11: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

How Tyrion WorksHow Tyrion WorksHow Tyrion WorksHow Tyrion Works

Page 12: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Resources, Goals, and ActionsResources, Goals, and ActionsResources, Goals, and ActionsResources, Goals, and Actions

• Goal: A description of adesired world state

• Action (or behaviour):A method for achieving a goal

• Resource:An entity required toperform an action

Page 13: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Resource HierarchyResource HierarchyResource HierarchyResource Hierarchy

Team

Squads

Vehicles

Characters

Driver/Gunners

Legs/Arms/Head

Page 14: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Resource HierarchyResource HierarchyResource HierarchyResource Hierarchy

Team Strategic level

Tactical levelSquads

Vehicles

Characters

Driver/Gunners

Legs/Arms/Head

IndividualUnits

Motor Control

Page 15: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Action/Goal HierarchyAction/Goal HierarchyAction/Goal HierarchyAction/Goal Hierarchy

Attack From All Sides

NormalAttackDuelistAttack

MoveTo

Squad

Character

Legs /Arms

Attack Goals

Fire Weapon

MoveTo GoalFireAt Goal

Grunt

Duelist

Page 16: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Action StructureAction StructureAction StructureAction Structure

• Goal satisfied by action

• Selection heuristic– Evaluates appropriateness of action

in a given situation

• Message callback functions for child actions

• Message callback functions for sensors

• Body (Unreal script latent code)– Typically executes over a number of game ticks

Page 17: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Example Action: SearchExample Action: SearchExample Action: SearchExample Action: Search

• Satisfies:SearchGoal( target, searchDistance )– Only action that satisfies this goal

• Child action callbacks:– Set errorCode

• Sensor callback:– Terminate action if target spotted

Page 18: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Example Action: Search (cont)Example Action: Search (cont)Example Action: Search (cont)Example Action: Search (cont)

• Body:– Store location and rotation– ActivateSensor( TargetSensor, target )– Loop over searchPositions:

• WaitForGoal( MoveToGoal, searchPosition)• Fail() if MoveToGoal was not achieved• Play LookingAround animation• Pause AnimationTime seconds

– WaitForGoal( TurnGoal, originalRotation )– Succeed()

Page 19: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Sensor HierarchySensor HierarchySensor HierarchySensor Hierarchy

• Sensors can build upon one another, too

DodgeSensor: Warns a character about incoming projectiles

EnemySensor: Maintains a list of visible hostiles

TargetSensor: Triggers when a particular unit is visible

Vision SystemVision System

Page 20: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

AI and ScriptingAI and ScriptingAI and ScriptingAI and Scripting

• High level behaviours look a lot like scripts

• A script is essentially a one-time use behaviour

• Tyrion could be used to drive the scripting system

Page 21: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Example ScriptExample ScriptExample ScriptExample Script

• Executes when player enters trigger

• Spawns AI’s

• Moves AI’s into position and has them attack player

Page 22: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Example ScriptExample ScriptExample ScriptExample Script

• Executes when player enters trigger

• Spawns AI’s

• Moves AI’s into position and has them attack player

Sensor activation

Posting sub-goals

Page 23: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Execution ModelExecution ModelExecution ModelExecution Model

• 10 times a second:– Iterate over every resource:

• Order unmatched goals by priority• Find actions that achieve them• Tick every running action• Tick every active periodic sensor;

send messages• If an action completes, mark its goal as

achieved/failed; send messages

Page 24: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

A Day in the Life of a GruntA Day in the Life of a GruntA Day in the Life of a GruntA Day in the Life of a Grunt

• A Grunt AI with three goals:– PatrolGoal (priority 40)– AttackGoal (priority 50, dormant)– DodgeGoal (priority 90, dormant)

• AttackGoal will activate when an enemy is sighted

• DodgeGoal will activate when a visible projectile will hit the AI

Page 25: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

A Day in the Life (cont)A Day in the Life (cont)A Day in the Life (cont)A Day in the Life (cont)

Patrol is executing 4040

PatrolGoal AttackGoal DodgeGoal

legslegs

armsarms

Page 26: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

A Day in the Life (cont)A Day in the Life (cont)A Day in the Life (cont)A Day in the Life (cont)

Patrol is executing 4040

PatrolGoal

Enemy spotted! Sensor wakes up AttackGoal

Attack executes; posts subgoalsfor legs & arms

4040 5050

AttackGoal DodgeGoal

legslegs

legslegs

armsarms

armsarms

5050X

Page 27: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

A Day in the Life (cont)A Day in the Life (cont)A Day in the Life (cont)A Day in the Life (cont)

Patrol is executing 4040

PatrolGoal

Enemy spotted! Sensor wakes up AttackGoal

Attack executes; posts subgoalsfor legs & arms

4040 5050

AttackGoal DodgeGoal

legslegs

legslegs

armsarms

Projectile spotted! Sensor wakes up DodgeGoal

Dodge executes; needs legs arms continue executing Attack!

90904040

5050

armsarms

5050

legslegs

armsarms

X

X 5050X

Page 28: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

A Day in the Life (cont)A Day in the Life (cont)A Day in the Life (cont)A Day in the Life (cont)

Patrol is executing 4040

PatrolGoal

Enemy spotted! Sensor wakes up AttackGoal

Attack executes; posts subgoalsfor legs & arms

4040 5050

AttackGoal DodgeGoal

legslegs

legslegs

armsarms

Projectile spotted! Sensor wakes up DodgeGoal

Dodge executes; needs legs arms continue executing Attack!

90904040

5050

Dodge finishes: legs resumeAttack subgoal

4040 5050

armsarms

5050

legslegs

armsarms

legslegs

armsarms 5050

X

X

X

5050X

Page 29: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Lessons LearnedLessons LearnedLessons LearnedLessons Learned

Page 30: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Sophisticated AI != Expensive AISophisticated AI != Expensive AISophisticated AI != Expensive AISophisticated AI != Expensive AI

• This is not an expensive system– No search due to scoring function on actions– Action to goal matching only occurs when goal

list changes for the resource– Although there are many actions running

simultaneously, at any given time a lot are sleeping

– Most of high-level AI was written in Unreal Script (20x slower than C++) yet it still wasn’t a bottleneck.

Page 31: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Some AI Some AI isis expensive expensiveSome AI Some AI isis expensive expensive

• Superficially simple systems that require large amounts of debugging and tweaking (e.g. emergent AI)

• Search (e.g. planning, pathfinding)

• Line checks (e.g. vision)

Page 32: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Analysis (pluses)Analysis (pluses)Analysis (pluses)Analysis (pluses)

• Character actions were very useful in coordinating squads and chaining sub-actions

• Useful to think of legs and arms as separate resources

• Architecture no harder to use than others, but quite easily reusable for other projects

• Using squad goals worked well: helped reduce the amount of level design work

Page 33: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Analysis (minuses)Analysis (minuses)Analysis (minuses)Analysis (minuses)

• Full potential of architecture not exploited: FPS opponents are only human-like to a degree; their required spectrum of behaviours is fairly limited

• Exposed too much detail to designers; editor could have been streamlined

• We didn’t use the AI architecture to drive the scripting system: duplication of effort

Page 34: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

General Lessons LearnedGeneral Lessons LearnedGeneral Lessons LearnedGeneral Lessons Learned

• Create AI that’s required by the game

• Create debugging tools early

• Leave time for tweaking

• Make sure the player knows when the AI does something cool

• Does good AI make a game fun (or is it just that bad AI makes a game not fun)?; do games need scripted set-pieces?

Page 35: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Take-home MessageTake-home MessageTake-home MessageTake-home Message

• powerful AI != expensive AI

• One AI description language can control control teams, squads, characters, and scripting

• A modular AI is a reusable AI – let the AI engine handle the interaction complexities

Page 36: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

The EndThe EndThe EndThe End

Page 37: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004
Page 38: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Unused Slides Follow….Unused Slides Follow….Unused Slides Follow….Unused Slides Follow….

Page 39: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Oh No, Not Another Hierarchy!Oh No, Not Another Hierarchy!Oh No, Not Another Hierarchy!Oh No, Not Another Hierarchy!

• Control hierarchies are a dime adozen in the AI/robotics literature

• Tyrion’s more interesting features:– No set number of levels– Uniform description language and execution

model used across levels– Separate sensing system– Dormant goals– Supervenience: information is sent up, goals

are sent down

Page 40: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Relationship to AI PlanningRelationship to AI PlanningRelationship to AI PlanningRelationship to AI Planning

• Tyrion can be viewed as a Task Network (or Partial Hierarchical) Planner

Goal A

Possible Actions

Page 41: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Relationship to AI PlanningRelationship to AI PlanningRelationship to AI PlanningRelationship to AI Planning

• Tyrion can be viewed as a Task Network (or Partial Hierarchical) Planner

Goal A

Possible Actions

Sub-goals

Possible Sub-Actions

Page 42: Scaling Up To More Sophisticated AI Without Overburdening Developers - Lessons Learned Marc Atkin Irrational Games AGDC 4-Dec-2004

Relationship to AI PlanningRelationship to AI PlanningRelationship to AI PlanningRelationship to AI Planning

• Tyrion can be viewed as a Task Network (or Partial Hierarchical) Planner

Goal A

Possible Actions

Sub-goals

Possible Sub-Actions

x Outcome for goal A