Beyond Finite State Machines Beyond Finite State Machines Managing - - PDF document

beyond finite state machines beyond finite state machines
SMART_READER_LITE
LIVE PREVIEW

Beyond Finite State Machines Beyond Finite State Machines Managing - - PDF document

Beyond Finite State Machines Beyond Finite State Machines Managing Complex, Intermixing Behavior Hierarchies Managing Complex, Intermixing Behavior Hierarchies Michael Mateas Michael Mateas Andrew Stern Andrew Stern Georgia Institute of


slide-1
SLIDE 1

1

Beyond Finite State Machines

Managing Complex, Intermixing Behavior Hierarchies

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 Zoesis Studios Studios www.interactivestory.net www.interactivestory.net www.grandtextauto.org www.grandtextauto.org

New programming constructs for believable characters New programming constructs for believable characters

  • In creating Façade, we developed programming constructs

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

  • We created a new language to support these constructs

We created a new language to support these constructs A Behavior ehavior Language anguage– ABL 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)

slide-2
SLIDE 2

2

Façade Faç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

Façade character requirements Façade character requirements

  • Moment

Moment-by by-moment believability moment believability Body movements, facial expression, behavior mixing

  • Tightly coordinated action

Tightly coordinated action Characters work closely together to perform story

  • Conversational behavior

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

slide-3
SLIDE 3

3

Code support for character requirements Code support for character requirements

  • Goals and behaviors

Goals and behaviors Sequencing + reactivity, behavior mixing, hierarchy

  • Joint goals and behaviors

Joint goals and behaviors Protocol supporting multi-character teamwork

  • Meta

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

Façade architecture Façade architecture

Drama Manager (sequences beats)

Bag of beats beat beat beat beat beat beat Desired value arc(s) Selected beat

History

time Previous action beat beat beat beat Activity not part of a beat Current story values

Player

Story World

Trip Grace

Recognizers

Natural Language Processing

surface text discourse acts discourse acts reactions

Behavior-based agents used here

slide-4
SLIDE 4

4

A behavior-based agent A behavior-based agent

Active Behavior Tree

Root behavior Goal1 Goal2 Seq. Behavior1 Par. Behavior2 Mental Act Goal3

Available for execution

Behavior library

Behavior1 Behavior2 Behaviorn

Working memory

WME1 WME2 WMEn

Sensors

Sensor1

World

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

  • Characters organized as goals and sequential & parallel

Characters organized as goals and sequential & parallel behaviors behaviors

  • Joint (synchronized) goals and

Joint (synchronized) goals and behaivors behaivors

  • Reflection (meta

Reflection (meta-behaviors) behaviors)

  • Generalization of sensory

Generalization of sensory-motor connections motor connections

  • Multiple named working memories

Multiple named working memories

  • Atomic behaviors (useful for atomic WM updates)

Atomic behaviors (useful for atomic WM updates)

slide-5
SLIDE 5

5

Behaviors Behaviors

Behaviors consist of steps Behaviors 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 goals Behaviors 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

Example behaviors Example 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 knock 2. Sigh 3. Open the door 4. Greet the guest

sequential behavior O p e n D o o r() { 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.

slide-6
SLIDE 6

6

Steps Steps

  • Subgoal

Subgoal – chooses behaviors chooses behaviors

  • Act

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

  • Mental act

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

  • Wait

Wait – used with conditions to accomplish demons used with conditions to accomplish demons All steps succeed or fail All steps succeed or fail Behavior finished when all steps succeed or one step fails Behavior finished when all steps succeed or one step fails Behavior success and failure propagates up ABT Behavior success and failure propagates up ABT

Continuously monitored conditions Continuously monitored conditions

  • Success tests

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

  • Context conditions

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

  • Makes behaviors immediately reactive to

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

slide-7
SLIDE 7

7

Success and failure propagation Success and failure propagation

ABT

Root behavior Par. behavior2 Goal2 Goal2 Goal3 Act2 Seq. behavior1 Mental Act1 Act2 Fail Seq. behavior3 Seq. behavior3 Fail Goal3 Goal2 Success Test Succeeds Mental Remove Remove Seq. behavior1

Example: Making a drink Example: Making a drink

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

slide-8
SLIDE 8

8

Example: Interrupting Example: Interrupting

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

Example: Low-level parallelism Example: Low-level parallelism

Performance behavior example. Performance behavior example.

slide-9
SLIDE 9

9

Example: High-level behavior mixing Example: 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.

Joint goals and behaviors Joint goals and behaviors

Characters sometimes need to coordinate action Characters sometimes need to coordinate action Some approaches Some approaches

  • Coordinate through sensing (but plan

Coordinate through sensing (but plan recog

  • recog. hard)

. 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 Architecture coordinates author-specified joint action specified joint action

slide-10
SLIDE 10

10

Negotiation Negotiation

Agent1’s ABT

Root behavior Goal1 Joint Goal2 Seq. Behavior1 Joint Behavior2 Mental

Agent2’s ABT

Root behavior Goal5 Seq. Behavior5 Act Joint Goal2 Joint Behavior6

Intention to enter G2 Intention to enter G2

Conflicting intentions Conflicting intentions

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

Root behavior Goal1 Joint Goal2

Succeeds

Root behavior Goal3 Seq. Behavior1 Joint Goal2 Joint Behavior2 Act

Fails

Root behavior Goal4 Seq. Behavior3 Joint Goal2 Joint Behavior4 Act

Suspends

Resolution: intentions are precedence ordered Resolution: intentions are precedence ordered

Mental Goal5

Problem: Problem: asynchronous asynchronous agents enter conflicting states agents enter conflicting states

slide-11
SLIDE 11

11

Inconsistent subtree execution Inconsistent subtree execution

ABT

Root behavior Joint Goal1 G2 Seq. Behavior1 Joint Behavior2 Joint Goal2 Act

Succeeds

Resolution: freeze Resolution: freeze subtree 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: continuing continuing execution execution leads to ABT inconsistencies leads to ABT inconsistencies

Variably coupled agents Variably coupled agents

Agent1’s ABT

Seq. Behavior1 Root behavior Goal1 Joint Goal2 Joint Behavior2 Act

Agent2’s ABT

Root behavior Goal3 Joint Goal2 Joint Behavior4 Mental Seq. Behavior3

Effects propagate across ABTs

Mental Goal4

Effects propagate within ABTs

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

slide-12
SLIDE 12

12

Example: Coordinating dialog Example: Coordinating dialog

Beat goal showing dialog Beat goal showing dialog-line level agent 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.

Meta-behaviors Meta-behaviors

  • Meta

Meta-behaviors manipulate the runtime state of behaviors manipulate the runtime state of

  • ther behaviors (e.g. succeed or fail steps).
  • ther 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)

slide-13
SLIDE 13

13

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

Behaviors for a dramatic beat with default Behaviors for a dramatic beat with default

  • rder of activity and handlers to respond to
  • rder of activity and handlers to respond to

interaction. interaction.

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

  • Difficult to specify responsive sequential activity

Difficult 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

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

  • Explicitly encode sequential activity in ABT
  • Modify future activity through dynamic ABT modification
slide-14
SLIDE 14

14

Conclusions Conclusions

Behavioral coding vs. Behavioral coding vs. FSMs FSMs

  • Behaviors support mixing (can be in more than one “state” at
  • nce)
  • Behavior hierarchy more expressive than flat FSMs
  • Dynamic coupling between goals and behaviors

Behavioral coding vs. rules Behavioral coding vs. rules

  • Behaviors support sequential activity
  • Behaviors support hierarchy

For more info For more info

www.interactivestory.net www.interactivestory.net

Façade project site (includes latest slides)

www.grandtextauto.org www.grandtextauto.org

Group blog on games and new media

egl.gatech.edu egl.gatech.edu

Experimental Game Lab (includes projects using ABL)