swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Swarm-Support] Simulating Eating


From: Doug Donalson
Subject: Re: [Swarm-Support] Simulating Eating
Date: Tue, 1 Apr 2003 16:13:46 -0800

Simple bug means exactly that.  If you want to really get into spatial
predator/prey simulations, you need to expand the concept of space.  Instead
of having a grid location contain a Predator" or a "prey", have it contain
the handle of an object called, say, SpatialCell.  Now you have a spatial
object in which you can include lots of information.  For instance, it can
contain its own x and y coordinates.  It can have a flag that represents
empty or occupied, and it can have a flag for whether, if it is occupied, it
is a predator or prey.  Also, it can contain the handles of the occupants.
Now, if a predator is in cell 4,5 and wants to know/eat what is in cell 4,6,
you can do

if(myWorld[4][6]->occupied && myWorld[4][6]->prey )
    [myWorld[4,6]->prey: die]

Where of course your prey object has a procedure to handle dying.

Cheers,

D4

----- Original Message -----
From: "Eliezer Gurarie" <address@hidden>
To: <address@hidden>
Sent: Tuesday, April 01, 2003 1:48 PM
Subject: [Swarm-Support] Simulating Eating


> Dear Swarm Support,
>
> I am working on a Predator-Prey model in a Stream - using SimpleBug as a
> template - and am having technical/strategic difficulty having randomly
> moving Predators eat randomly moving Prey.   Basically, if a Predator
> agent chooses to step into a space occupied by a Prey agent, the Prey
> agent needs to be removed.
>
> My main questions are:  How can one kind of agent "detect" what kind of
> agent is occupying a neighboring grid? Can one agent remove another
> agent from it's list?  Ideally, a single eating function within the
> [predator step] method would look like:
>
> if( [world getObjectAtX: newX Y:newY]=="a prey"])
>     {
>         "remove the prey in that spot";
>         [putSelfAtX: newX Y: newY];
>     }
>
> But since I don't know how to detect the "nature" of an occupied space
> (only whether it is occupied or not) I have to go through a whole
> rigamarole that tracks Prey locations with a "HasPrey" switch in the
> StreamSpace.  The schedule looks like:
>
> 1) [prey step1] -> the Prey move randomly (for the moment avoiding
> predators by going into empty spaces)
> 2) [predator step1]  ->  the Predator selects a potential spot (newX,
> newY) to move to.  those that choose empty spots move, those that choose
> spots with "HasPrey==1" turn on a FeedingEvent switch at that spot,
>             i.e.:    if ([stream getHasPreyAtX: newX Y: newY]==1)
> [stream putFeedingEvent: 1 atX: newX Y: newY]
> 2) [prey step2]  ->  all Prey in FeedingEvent spots are removed from the
> world
> 3) [predator step2] -> the Predators move into FeedingEvent spots
>
> This seems inefficient and counter to the concept of "realistic,"
> straightforward agent interactions without having to go through the
> Stream environment to effectuate interactions.
>
> Any advice on simulating "eating" would be appreciated.
>
>
> Thanks,
>
> Elie Gurarie
> Quantitative Ecology and Resource Management
> University of Washington, Seattle
>
> _______________________________________________
> Support mailing list
> address@hidden
> http://www.swarm.org/mailman/listinfo/support




reply via email to

[Prev in Thread] Current Thread [Next in Thread]