beyond finite state machines managing complex, intermixing behavior hierarchies

28
Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies Michael Mateas Michael Mateas Georgia Institute of Technology Georgia Institute of Technology College of Computing & LCC College of Computing & LCC www.lcc.gatech.edu/~mateas www.lcc.gatech.edu/~mateas Andrew Stern Andrew Stern Interactivestory.net, Interactivestory.net, Zoesis Studios Zoesis Studios www.interactivestory.net www.interactivestory.net www.grandtextauto.org www.grandtextauto.org

Upload: phyllis-weeks

Post on 03-Jan-2016

26 views

Category:

Documents


4 download

DESCRIPTION

Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies. Michael Mateas Georgia Institute of Technology College of Computing & LCC www.lcc.gatech.edu/~mateas. Andrew Stern Interactivestory.net, Zoesis Studios. www.interactivestory.net www.grandtextauto.org. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

Beyond Finite State MachinesManaging Complex, Intermixing Behavior Hierarchies

Beyond Finite State MachinesManaging Complex, Intermixing Behavior Hierarchies

Michael MateasMichael MateasGeorgia Institute of TechnologyGeorgia Institute of Technology

College of Computing & LCCCollege of Computing & LCC

www.lcc.gatech.edu/~mateaswww.lcc.gatech.edu/~mateas

Andrew SternAndrew SternInteractivestory.net,Interactivestory.net,

Zoesis StudiosZoesis Studios

www.interactivestory.netwww.interactivestory.net

www.grandtextauto.orgwww.grandtextauto.org

Page 2: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

New programming constructs for believable charactersNew programming constructs for believable characters

• In creating Façade, we developed programming constructs In creating Façade, we developed programming constructs for believable charactersfor believable characters

• We created a new language to support these constructs We created a new language to support these constructs AA BBehavior ehavior LLanguage– ABLanguage– ABL• Based on the CMU Oz-project language Hap

• Reactive-planning: characters organized as goals and behaviors

• Lessons from these constructs can be generalized beyond ABL

A different way of thinking than imperative languages A different way of thinking than imperative languages (e.g. C++, Java) (e.g. C++, Java)

Page 3: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

FaçadeFaçade

• Dramatic world inhabited by computer controlled characters (believable agents)

• The user (player) plays a protagonist within the story, first-person point of view

• The player experiences a story with a dramatic arc

Page 4: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

Façade character requirements Façade character requirements

• Moment-by-moment believabilityMoment-by-moment believabilityBody movements, facial expression, behavior mixing

• Tightly coordinated actionTightly coordinated actionCharacters work closely together to perform story

• Conversational behavior Conversational behavior Longer-term, non-linear dialog flow that preserves reactivity

Page 5: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

Code support for character requirementsCode support for character requirements

• Goals and behaviorsGoals and behaviorsSequencing + reactivity, behavior mixing, hierarchy

• Joint goals and behaviorsJoint goals and behaviorsProtocol supporting multi-character teamwork

• Meta-behaviors Meta-behaviors Canonical behavior sequences are modified by player interaction

Page 6: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

Façade architectureFaçade architecture

Drama Manager(sequences

beats)Bag of beats

beatbeat

beat

beat

beatbeat

Desired valuearc(s)

Selected beat

History

timePrevious action

beat beat beat beat

Activity not part of a beat

Currentstory

values

Player

Story World

TripGrace

Recognizers

Natural Language Processing

surface text

discourse acts

discourse acts

reactions

Behavior-basedagents used here

Page 7: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

A behavior-based agentA behavior-based agent

Active Behavior TreeRoot

behavior

Goal1 Goal2

Seq.Behavior1

Par.Behavior2

Mental Act Goal3

Available for execution

Behavior libraryBehavior1

Behavior2

Behaviorn

Working memoryWME1 WME2

WMEn

SensorsSensor1

World

Page 8: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

Features of our behavior-based agentsFeatures of our behavior-based agents

• Characters organized as goals and sequential & parallel behaviorsCharacters organized as goals and sequential & parallel behaviors

• Joint (synchronized) goals and behaivorsJoint (synchronized) goals and behaivors

• Reflection (meta-behaviors)Reflection (meta-behaviors)

• Generalization of sensory-motor connectionsGeneralization of sensory-motor connections

• Multiple named working memoriesMultiple named working memories

• Atomic behaviors (useful for atomic WM updates)Atomic behaviors (useful for atomic WM updates)

Page 9: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

BehaviorsBehaviors

Behaviors consist of stepsBehaviors consist of steps

• Similar to the scripts or functions associated with FSM states, but

• Can be parallel as well as sequential

• Mix together as multiple behaviors are pursued

Behaviors are chosen to accomplish a goalsBehaviors are chosen to accomplish a goals

• Similar to function calls but

• Are dynamically chosen given current game conditions

• Can be re-chosen if the first choice doesn’t work out

Page 10: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

Example behaviorsExample behaviors

sequential behavior AnswerTheDoor() { WME w; with success_test { w = (KnockWME) } wait; act sigh(); subgoal OpenDoor(); subgoal GreetGuest(); mental_act { deleteWME(w); }}

To answer the door:1. Wait for knock2. Sigh3. Open the door4. Greet the guest

sequential behavior OpenDoor() { precondition {

(KnockWME doorID :: door) (PosWME spriteID == door pos :: doorPos) (PosWME spriteID == me pos :: myPos) (Util.computeDistance(doorPos, myPos) > 100) }

subgoal YellAndWaitForGuestToEnter(doorID);}

If there is knock and the door is too far away,yell for guest to come in.

Page 11: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

StepsSteps

• Subgoal – chooses behaviorsSubgoal – chooses behaviors

• Act – does a physical act in the worldAct – does a physical act in the world

• Mental act – a bit of computation (e.g. change memory)Mental act – a bit of computation (e.g. change memory)

• Wait – used with conditions to accomplish demonsWait – used with conditions to accomplish demons

All steps succeed or failAll steps succeed or failBehavior finished when all steps succeed or one step failsBehavior finished when all steps succeed or one step fails

Behavior success and failure propagates up ABTBehavior success and failure propagates up ABT

Page 12: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

Continuously monitored conditionsContinuously monitored conditions

• Success tests – spontaneously make a Success tests – spontaneously make a step succeed if test is satisfiedstep succeed if test is satisfied

• Context conditions – spontaneously make Context conditions – spontaneously make a behavior fail if test is satisfieda behavior fail if test is satisfied

• Makes behaviors immediately reactive to Makes behaviors immediately reactive to changes in the worldchanges in the world

Page 13: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

Success and failure propagationSuccess and failure propagation

ABTRoot

behavior

Par.behavior2

Goal2Goal2

Goal3

Act2

Seq.behavior1

Mental Act1

Act2 Fail

Seq.behavior3

Seq.behavior3

Fail

Goal3

Goal2

Success TestSucceeds

MentalRemove

RemoveSeq.

behavior1

Page 14: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

Example: Making a drinkExample: Making a drink

Code example showing basic sequential Code example showing basic sequential behavior plus hierarchical subgoaling.behavior plus hierarchical subgoaling.

Page 15: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

Example: Interrupting Example: Interrupting

Code example using a continuous condition Code example using a continuous condition to interrupt activity.to interrupt activity.

Page 16: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

Example: Low-level parallelismExample: Low-level parallelism

Performance behavior example.Performance behavior example.

Page 17: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

Example: High-level behavior mixingExample: High-level behavior mixing

Example showing two high level behaviors Example showing two high level behaviors blending together (making a drink + dialog blending together (making a drink + dialog performance). Demonstrates conflicts and performance). Demonstrates conflicts and priorities.priorities.

Page 18: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

Joint goals and behaviorsJoint goals and behaviors

Characters sometimes need to coordinate actionCharacters sometimes need to coordinate action

Some approachesSome approaches• Coordinate through sensing (but plan recog. hard)Coordinate through sensing (but plan recog. hard)• Explicitly communicate (but ad hoc)Explicitly communicate (but ad hoc)• Build it into architecture (but not flexible)Build it into architecture (but not flexible)

Architecture coordinates author-specified joint actionArchitecture coordinates author-specified joint action

Page 19: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

NegotiationNegotiation

Agent1’s ABTRoot

behavior

Goal1

Joint Goal2

Seq.Behavior1

JointBehavior2

Mental

Agent2’s ABTRoot

behavior

Goal5

Seq.Behavior5

Act

Joint Goal2

JointBehavior6

Intention to enter G2

Intention to enter G2

Page 20: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

Conflicting intentionsConflicting intentions

Agent1’s ABT Agent2’s ABT Agent3’s ABTRoot

behavior

Goal1

Joint Goal2

Succeeds

Rootbehavior

Goal3

Seq.Behavior1

Joint Goal2

JointBehavior2

ActFails

Rootbehavior

Goal4

Seq.Behavior3

Joint Goal2

JointBehavior4

Act

Suspends

Resolution: intentions are precedence orderedResolution: intentions are precedence ordered

Mental Goal5

Problem: Problem: asynchronousasynchronous agents enter conflicting states agents enter conflicting states

Page 21: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

Inconsistent subtree executionInconsistent subtree execution

ABTRoot

behavior

JointGoal1

G2

Seq.Behavior1

JointBehavior2

Joint Goal2

Act

Succeeds

Resolution: freeze subtreeResolution: freeze subtree• Initiate exit intention at the subtree root• Remove all leaf steps• Deactivate all monitored conditions• Negotiate removal of all joint goals• Commit to exit intention at subtree root

Problem: Problem: continuingcontinuing execution execution leads to ABT inconsistenciesleads to ABT inconsistencies

Page 22: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

Variably coupled agentsVariably coupled agents

Agent1’s ABT

Seq.Behavior1

Rootbehavior

Goal1

Joint Goal2

JointBehavior2

Act

Agent2’s ABTRoot

behavior

Goal3

Joint Goal2

JointBehavior4

Mental

Seq.Behavior3

Effects propagate across ABTs

Mental Goal4

Effects propagate within ABTs

A tunable spectrum between one-mind and many-mindsA tunable spectrum between one-mind and many-minds

Page 23: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

Example: Coordinating dialogExample: Coordinating dialog

Beat goal showing dialog-line level agent Beat goal showing dialog-line level agent coordination. Difficult to get this level of coordination. Difficult to get this level of coordination without negotiation support.coordination without negotiation support.

Page 24: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

Meta-behaviorsMeta-behaviors

• Meta-behaviors manipulate the runtime state of Meta-behaviors manipulate the runtime state of other behaviors (e.g. succeed or fail steps).other behaviors (e.g. succeed or fail steps).

• Ability to match on this runtime state just like it Ability to match on this runtime state just like it was part of the world (preconditions, context was part of the world (preconditions, context conditions, success tests)conditions, success tests)

Page 25: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

Example: Conversation = joint behaviors + handlersExample: Conversation = joint behaviors + handlers

Behaviors for a dramatic beat with default Behaviors for a dramatic beat with default order of activity and handlers to respond to order of activity and handlers to respond to interaction.interaction.

Page 26: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

Interaction = (Joint) behaviors + handlersInteraction = (Joint) behaviors + handlers

• Difficult to specify responsive sequential activityDifficult to specify responsive sequential activity

• Implicitly encode in ABT – conditions get complicated fast!

• Flat behaviors with declarative state – redundant and error prone

• Instead: Joint behaviors + handlers (meta-behaviors)Instead: Joint behaviors + handlers (meta-behaviors)

• Explicitly encode sequential activity in ABT

• Modify future activity through dynamic ABT modification

Page 27: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

ConclusionsConclusions

Behavioral coding vs. FSMsBehavioral coding vs. FSMs• Behaviors support mixing (can be in more than one “state” at

once)

• Behavior hierarchy more expressive than flat FSMs

• Dynamic coupling between goals and behaviors

Behavioral coding vs. rulesBehavioral coding vs. rules• Behaviors support sequential activity

• Behaviors support hierarchy

Page 28: Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies

For more info For more info

www.interactivestory.netwww.interactivestory.netFaçade project site (includes latest slides)

www.grandtextauto.orgwww.grandtextauto.orgGroup blog on games and new media

egl.gatech.eduegl.gatech.eduExperimental Game Lab (includes projects using ABL)