Last Modified 18 July 2005, except Overview corrected 23 March 2008
BOD Sheep & Dog Demo
This demo is being rewritten, but this page hasn't been much yet.
Apologies. The Overview just below is correct though.
This demo is intended to give you a feel for using Behavior
(BOD). Its created on top of the MASON
agent-based modelling platform. We have provided a sheep agent
and a dog agent, and also the files to get a bunch of sheep and one dog
to start up. You can try to make the sheep and / or the dog
smarter, or you can set out to create new agents by modifying the old
ones, for example turning the dogs into wolves, or the sheep into deer.
First you need to have or install a copy of BOD MASON,
which will automatically come
with this demo. If you've done this, to run the demo:
Note that if you kept all the default versions of the files in, your
dogs will be pretty dumb! (So will your sheep, but sheep are dumb.)
- Start the jyPOSH GUI. (run jython jyposh.py)
- Select the sheepDogDemo behavior library.
- The default values for the other files will work, or you can pus
the "choose" buttons to run other ones.
- Click Load Agent Init File
-- this again gives you a working default simulation.
- Click Initialise World and
Agent(s). This will start MASON.
- Click the black triangle in the lower left of the POSH Simulation
window. This will start the simulation.
Looking at what you have.
The first thing you need to do is have a look at the files you are
going to be modifying. BOD programs have two types of files:
The BOD specification strategy tells you that you should start from a
high-level description of what the agent does, then derive
these. That high-level description for our agents (note there are
two types of agents!) can be found at the bottom of this page.
- The behaviour libraries, which are plain code. These
determine how the agent acts.
- The POSH plans, which are in a scripting language. These
determine when (in what circumstances) the
In your jyPOSH directory, you should see a directory called modules. These are actually your behavior
libraries -- there is a directory called "mason" that contains all of
the behaviors that can be used in MASON simulations.
There are two java files, FlockingBehavior.java and
HerdingBehavior.java, which provide the basic behaviors for Flocking
and Herding, respectively. DogBehavior.py inherits from HerdingBehavior
and defines the behavior for the sheep dog in the Simulation.
PanicFlocking.py inherits from
FlockingBehavior and adds panicking to the standard flocking behavior.
There are two POSH scripts to start you off. Sheep.lap and Dog.lap in
directory. You can edit these scripts, but it would be better to
make your own copies and change those so that you can later see how
your sheep or dogs compare to the original ones.
The format for the POSH plans is explained on the POSH web page.
There are also more
For a very elaborate POSH plan, have a look at the one in the bodbot
directory -- this is for running under unreal
Suggestions for what to do
If you have watched the demo run for a
while, then you probably already have a bunch of ideas for how to
improve it! But just in case, here are a few suggestions:
- Modify the dogs to
act like wolves (eat the sheep, don't herd them).
- Modify the
sheep to act like deer (split the herd when attacked.)
- Make the dog do a better job of herding the sheep -- e.g. add an
action that goes around the sheep it is chasing so that it chases
them towards the center of the other sheep. This will require
- In the decomposition
below, the stuff in blue was stuff identified for advanced iterations,
not the initial prototype. So those are suggestions too.
The Initial Decomposition
- Behaviors provided from MASON : cohesion (center of mass),
avoidance (nearest neighbors), randomness (wobble), consistency /
alignment ( orientation &
speed(? may emerge)
with neighbors) , momentum (won't change.) Flick/panic variable
- Default: graze
- wander randomly a little, slowly
- low cohesion + alignment; highish avoidance + randomness.
- When predator too close:
- avoid predator + speed up, go to flock mode.
- When see neighbor flock & not flocking yet
- go to flock / panic mode.
- Flock mode:
- high cohesion & alignment, closer avoidance distance &
- propensity to slow down
- beginning of flock panic -- set panic variable high
- Panic level -- keeps track of current panic level,
primitives: max, decay.
- Motion -- determines direction using 4 provided actions.
Primitives: set vars to panic level, move.
- `Vision' (magic) -- Primitives: predator close?, predator
- Herd together: lie down & pant
- Herd spread out: shepherd them
- go towards closest outer-most sheep until it moves away.
- move around edge of herd (next outer-most sheep) if close to it.
- Herd moving fast: go
away, try to cut off & slow down.
- Add another dog, avoid
each other so that more likely to tighten herd not chase it faster.
- `Dog-vision': primitives: herd-width,
pick-outlier (of the three sheep closest to you, go to the one furthest
away from centre.
- motion -- needs bit of state `target'. Primitives:
go-to target (sheep or hang-spot), pick-hang-spot (halfway back away
from herd center)
- Don't stop -- pick a prey agent & pursue & eat it.
- Get tired? (Give the sheep
- Get full...
- Get confused when animals are
moving apart (the point of a
- Will have to give sheep a "die" behavior (maybe an "eaten" behavior too.)
Welcome to A Life!
- When predator gets really close, the herd should split, not
tighten (sheep have been bred to be stupid about this.)
page author: Joanna