DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual...

31
DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th , 2007 Kathryn Merrick and Owen Macindoe DESC9180 Designing Virtual Worlds University of Sydney, September 2007
  • date post

    15-Jan-2016
  • Category

    Documents

  • view

    212
  • download

    0

Transcript of DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual...

Page 1: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

DESC9180 Designing Virtual Worlds

Week 9

Interactivity II – Agent Models for Dynamic Virtual Worlds

6pm – 9pm

Tuesday, September 18th, 2007

Kathryn Merrick and Owen Macindoe

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Page 2: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Lecture Overview

What is an agent?

The role of agents in virtual worlds

Designing agents for dynamic virtual worlds

Demonstrations and examples

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Page 3: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

What is an Agent?

A software process that: Monitors its environment using sensors Reasons about sensor data using some

characteristic reasoning process

Acts in its environment using effectors

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Page 4: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Other Properties of an Agent (I)

Reflexive: Pre-programmed responses to the state of the virtual environment

Reactive: Reasoning within a fixed set of goals

Reflective: Hypothesises about possible goals

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Page 5: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Other Properties of an Agent (I)

Autonomous: Includes reasoning processes to create new goals

Proactive: Anticipate the needs or intentions of others

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Implementation complexity

scriptedbehaviours

reactive,reflectiveagents

reflexiveagents

autonomous,proactive

agents

Behavioural com

plexity

Page 6: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

The Role of Agents in Virtual Worlds (I)

Agents provide a structured approach to implementing dynamic virtual worlds

Believable characters Incredible objects

A single agent program may be applicable in many scenarios

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Page 7: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

The Role of Agents in Virtual Worlds (II)

Enemies or opposition

Partners

Support characters

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Page 8: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Designing Agents for Dynamic Virtual Worlds

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

effectors

Current state of the virtual world or some part of it

action

A change to the virtual world

state

reasoning

sensors

AGENT

Agents generally monitor and act in only a small part of the world

There may be multiple agents

Page 9: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

A LSL Approach to Agents

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

default{ state_entry() { state sensation; }}

state sensation{ state_entry() { // Gather information // about the world… state reasoning; }}

state reasoning{ state_entry() { // Process information // about the world… state reasoning; }}

state activation{ state_entry() { // Perform an action… state sensation; }}

Sensation

Reasoning

Activation

Page 10: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Monitoring the Virtual World

Agents generally monitor only a small part of the world:

Monitor properties that are necessary for deciding how to act

What to monitor? Self Other objects or scripts Avatars or chat Virtual land

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Page 11: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Self-Monitoring Objects

llGet… functions are useful for this: Shape and location properties Physics properties Meta-data Ownership and permissions Script properties

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Page 12: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Monitoring Other Objects and Avatars

Monitoring other objects: llSensor (see last week’s lecture) llDetected… functions

Monitoring avatars llSensor for generic properties llListen for chat touch_start for avatar touches collision for collisions

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Page 13: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Monitoring the Virtual Land

llGet... And llGround… functions for: Time and sun position Parcel and region flags Camera position Properties of the ground

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Page 14: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Reasoning: Artificial Intelligence for Virtual Worlds

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Artificial Intelligence (AI) techniques used in virtual worlds lag behind the current state of the art in AI research:

AI techniques are complex Behaviour may be unpredictable

But some techniques have been used with great success…

Page 15: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Rule-Based Systems

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Define a set of rules about states of the virtual world

Rules have the form: If <condition> then <action>

Simple to implement for a single agent A lot of work when there are multiple

agents requiring different rules

Page 16: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Flocking

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

A special example of

rule-based reasoning Used to control groups

crowds or animals

Three rules governing: Separation Alignment Cohesion

Craig Reynold’s flocking rules for boids

Page 17: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

State Machines

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Divide the reasoning process into internal states

Each state defines rules about: How to act while in that state When to transition to a different internal

state

One of the most popular control strategies for dynamic virtual worlds

Page 18: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

AI Implant

Page 19: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Fuzzy Logic

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

A way for agents draw a conclusion based on facts that may be vague, ambiguous, inaccurate, incomplete

Classical rules Fuzzy logic

Page 20: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Fuzzy Rules

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Fuzzy logic can be used to create a rule-base with rules of the form:

If <X is A> then <Y is B> Eg: if number of avatars is large then

overcrowding is likely

Can be used in rule based approaches and state machines

Page 21: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Supervised Learning

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Agents gradually modify their internal structure in response to examples

Examples of desirable behaviour provided by human controlled avatars

Learning agents can adapt Learning can be slow or inaccurate

Page 22: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

How a Supervised Learner Works

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Many variants of supervised learning exist Agent monitors:

State of virtual world Actions performed by avatars

Agent stores: State-action pair Weight indicating confidence

Agent acts autonomously when a recognised state is encountered

State 1 Action1 0.3

State 2 Action 5 0.9

State 3 Unknown

State 4 Action 3 0.8

Page 23: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Reinforcement Learning

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Learning by trial and error Agents modify their internal structure in

response to reward or punishment from: Human controlled avatars Internal function

Learning agents can develop better policies than programmed agents

Learning can take a long time

Page 24: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

How a Reinforcement Learner Works

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Many variants exist Action is initially random trial and error Agent monitors:

State of virtual world Reward or punishment

Agent stores: State-action pair Cumulative reward or punishment

Agent acts by choosing action with highest reward (or lowest punishment)

State 1 Action1 0.9

Action 2 0.5

State 2 Action 1 0.3

Action 2 0.8

Page 25: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Evolutionary Algorithms

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

A society of characters evolve individuals with advantageous characteristics

Karl Sims’ evolved virtual creatures

Page 26: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Acting in the Virtual World

Individual agents generally act in or change only a small part of the world

Multiple agents may control larger regions of the virtual environment

How to act? Changes to self Avatars Changes to other objects Environment eg: chat

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Page 27: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Self-Changing Objects

llSet… functions are useful for this: Shape and location properties Physics properties Meta-data Ownership and permissions Script properties

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Page 28: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Changing Avatars

You can’t put scripts in avatars… But you can:

Apply an animation to an avatar Attach scripted objects to an avatar to

control: Avatar location Other avatar attachments

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Page 29: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Changing Other Objects

You can’t directly change an object from a script inside a different object…

But you can: Send messages to an object telling it

how to change itself (remember the light switch example from last week)

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Page 30: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Tutorial: Advanced LSL techniques

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Download the agent framework LSL script:

http://www.it.usyd.edu.au/~kkas0686/desc9180readings/Agent%20Framework.txt

Copy a sheep from thetruck in Furness (236, 10, 55)

Write your own agentscripts to create someintelligent sheep (see tutorial sheet)

Page 31: DESC9180 Designing Virtual Worlds Week 9 Interactivity II – Agent Models for Dynamic Virtual Worlds 6pm – 9pm Tuesday, September 18 th, 2007 Kathryn Merrick.

Next Week (s)

DESC9180 Designing Virtual Worlds University of Sydney, September 2007

Next week (25/9) is the mid semester break No lecture or tutorial

The following week (2/10) will be our paper review session

Please send me your slides in advance so I can have them installed, ready for class