Applying Reactive Planning Idioms to Behavior Trees

30
expressive intelligence studio Applying Reactive Planning Idioms to Behavior Trees Ben Weber UC Santa Cruz [email protected]

Transcript of Applying Reactive Planning Idioms to Behavior Trees

expressiveintelligencestudio

Applying Reactive Planning Idioms to Behavior Trees

Ben Weber

UC Santa Cruz

[email protected]

expressiveintelligencestudio UC Santa Cruz

Motivation

Reactive planning systems provide several useful behavior authoring idioms

Behavior trees and reactive planners use similar representations

Several of these idioms can be used to extend functionality of behavior trees

expressiveintelligencestudio UC Santa Cruz

Multi-Scale Problems

expressiveintelligencestudio UC Santa Cruz

Reactive Planning

HTN planning with no look-ahead

Properties

Reactive vs. Deliberative

Hierarchical vs. Flat

Single or Multiple entity planning

Non-optimal and Incomplete plans

Advantages

Efficient behavior selection

Incomplete domain model

expressiveintelligencestudio UC Santa Cruz

A Behavior Language (ABL)

Language for authoring believable agents

Provides semantics for multi-agent collaboration

ABL Features

Concurrent goal pursuit

Behavior intermixing

Joint goals and behaviors

Compiled language

expressiveintelligencestudio UC Santa Cruz

ABL Primitives

An agent is a collection of behaviors

Behavior

Collection of steps

Sequential or parallel

Conditions

Step types

Subgoal

Physical act

Mental act

Wait

Success / Failure

sequential behavior melee() {

subgoal moveToTarget();

subgoal meleeTarget();

}

expressiveintelligencestudio UC Santa Cruz

ABL Agent

Active Behavior Tree (ABT)

Rootbehavior

Goal1 Goal2

Seq.Behavior1

Par.Behavior2

Mental Act Goal3

Available for execution

Behavior library

Behavior1 Behavior2

Working memory

WME1 WME2 WMEn

Sensors

Sensor1

Game

expressiveintelligencestudio UC Santa Cruz

Decision Cycle Process

Asynchronous

ABT is expanded at runtime

Instantiated as a single root node

Child nodes expanded via subgoaling

Update algorithm

Remove completed steps

Update world state

Pick next step

expressiveintelligencestudio UC Santa Cruz

Behavior Tree Primitives

Sequence

Parallel

Selector

Decorator

Behavior

expressiveintelligencestudio UC Santa Cruz

Behavior Tree / ABL Primitives

Sequence

Parallel

Selector

Decorator

Behavior

Sequential behavior

Parallel behavior

Subgoal

Step modifier

Step

Physical Action

Mental act

Wait

Success / Failure

expressiveintelligencestudio UC Santa Cruz

Spawn goal

Adds a new goal to the root of the ABT

The new goal is pursued concurrently

Analogous to spawning a new thread of execution

Rootbehavior

Goal1

Seq.Behavior1

Spawn goal Goal3

Rootbehavior

Goal1 Goal2

Seq.Behavior1

Goal3

expressiveintelligencestudio UC Santa Cruz

Success Test

Suspends the execution of a behavior until a condition is met

sequential behavior retaliate() {

spawngoal grenade();

...

}

sequential behavior grenade() {

with (success_test { (hasGrenade==true) }) wait;

act throwGrenade();

}

expressiveintelligencestudio UC Santa Cruz

EISBot

ABL StarCraft bot

Partitions gameplay into distinct competencies

Uses a blackboard for coordination between components

expressiveintelligencestudio UC Santa Cruz

Reactive Planning Idioms

Daemon Behaviors

Message Passing

Managers

Sub Tasks

[Flash, Pro-gamer]

expressiveintelligencestudio UC Santa Cruz

Daemon Behaviors

Enable concurrent goal pursuit

Spawns a new goal which is persistently pursued by the agent

EISBot uses daemon behaviors to manage subtasks and implement managers

Current Goal

New Goal

Spawn Goal

expressiveintelligencestudio UC Santa Cruz

Example Daemon Behavior

sequential behavior initializeAgent() {

spawngoal incomeManager();

mental_act {

System.out.println(“Started daemon behavior”);

}

}

sequential behavior incomeManager() {

with (persistent) subgoal mineMinerals();

}

expressiveintelligencestudio UC Santa Cruz

Message Passing

Uses ABL’s working memory as a blackboard

Producer behaviors post to working memory

Consumer behaviors read messages from memory

Facilitates communication between managers

Implemented using mental acts in ABL

Producer Consumer

Message

expressiveintelligencestudio UC Santa Cruz

Example Message Passing

sequential behavior producer() {

mental_act {

WorkingMemory.add(new MessageWME());

}

}

sequential behavior consumer() {

precondition { message = (MessageWME) }

mental_act {

WorkingMemory.delete(message);

}

/* process message */

}

expressiveintelligencestudio UC Santa Cruz

Managers

Conceptually partition an agent into distinct areas of competence

A manager is a collection of behaviors responsible for a specific aspect of gameplay

Enables decoupling of components and modularity in an agent

expressiveintelligencestudio UC Santa Cruz

EISBot Managers

Strategy Manager

Income Manager

Construction Manager

Tactics Manager

Scouting Manager

Gather Resources

ConstructBuildings

AttackOpponent

ScoutOpponent

expressiveintelligencestudio UC Santa Cruz

Sub Tasks

Behaviors that temporarily claim a unit to perform a task

EISBot sub tasks

Micromanagement

Worker defense

Building construction

Modify working memory

expressiveintelligencestudio UC Santa Cruz

Flee Sub Task

sequential behavior flee() {

with (success_test {

dragoon = (DragoonWME fleeCondition==true)

}) wait;

spawngoal flee(dragoon);

}

sequential behavior flee(DragoonWME dragoon) {

act move(dragoon, fleeX, fleeY);

subgoal wait(24);

act attackMove(dragoon, targetX, targetY);

}

expressiveintelligencestudio UC Santa Cruz

EISBot Demo!

expressiveintelligencestudio UC Santa Cruz

Discussion

Performance

Debugging

Authoring

expressiveintelligencestudio UC Santa Cruz

Takeaway

Behavior trees can adopt design patterns and idioms from reactive planning

Apply these design patterns and idioms to extend behavior trees

expressiveintelligencestudio UC Santa Cruz

Questions

[email protected] @bgweber

Macro!

Micro!

expressiveintelligencestudio UC Santa Cruz

Center for Games and Playable Media

expressiveintelligencestudio UC Santa Cruz

Further Reading

ABL Documentation Wiki

http://abl.soe.ucsc.edu/index.php/Main_Page

A Behavior Language for Story-Based Believable Agents

Provides an overview of the ABL language

http://www.cs.cmu.edu/~michaelm/publications/AI-IE2002.pdf

Reactive Planning Idioms for Multi-Scale Game AI

Presents ABL idioms used in EISBot

http://game.itu.dk/cig2010/proceedings/papers/cig10_015_075.pdf

Interactive drama, art, and artificial intelligence

Michael Mateas' dissertation, which includes a chapter on ABL

http://games.soe.ucsc.edu/sites/default/files/CMU-CS-02-206.pdf

Believable Agents: Building Interactive Personalities

Bryan Loyall's dissertation, which includes an overview of Hap, the predecessor to ABL.

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.62.2436&rep=rep1&type=pdf

expressiveintelligencestudio UC Santa Cruz

Idioms in EISBot

Root

Tactics Manager Production Manager Strategy Manager

Assign Dragoon

Dragoon Manager

Dragoon Task Squad Task

Train Dragoon Attack Enemy

Harass Unit Flee

Legend

Subgoal

Daemon behavior

Message passing

expressiveintelligencestudio UC Santa Cruz

Overview

Multi-Scale Game AI

Reactive Planning

Relation to Behavior Trees

Reactive Planning Idioms

Application to EISBot

Discussion