swarm-support
[Top][All Lists]
Advanced

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

Re: Help request from a SWARM newbie


From: Paul E. Johnson
Subject: Re: Help request from a SWARM newbie
Date: Wed, 27 Jan 1999 10:50:25 -0600

Without spending lots of time trying to figure out your terminology, let
me point you at the swarm ftp for an app called sss. "Swarm Sugar Scape"
is swarm code by Nelson M that has many great educational features, in
my opinion. One of them is the implementation of the "reaperQueue" for
killing off agents.  For your simulation, I think you want to study that
and figure a way to have agents added to the death queue where they are
removed from the simulation periodically.  

Good luck
pj


Fabio Mascelloni wrote:
> 
> I'd like to modify simpleSwarmBug2 in this way:
> 
> Each Bug has a certain amount of strenght (a float value initially set
> to 0) that increases of ,let's say, 0.1 every time it eats.
> Then, when a Bug  wants to move to anather location (-step) that is
> already occupied by another Bug, it checks if its own strenght is
> higher than that of its "enemy" :if it's so,
> it destroys it (in my mind,that would mean to make the bugList remove
> the defeated Bug), otherwise goes on.
> Here are the parts of source I've modified:
> In "Bug.h":
> 
> added inst.variables id bugEnemy and float strenght;
> added inst.var id myList; (the List whose the bug is part)
> added method -getStrenght (returns Bug's strenght)
> added method -setList:(id) aList (sent by bugList as a message to set
> itself
>                                                       as the bug list)
> 
> In "Bug.m",I added the following lines to the -step method:
> .....
> //Check that no other bug is at the new site
> 
>      if ((enemy=[world getObjectAtX: newX Y: newY])==nil)
>                   {
> 
>             [world putObject:nil atX:xPos Y:yPos];
>             [world putObject:self atX:newX Y: newY];
>             xPos=newX;
>             yPos=newY;
> 
>                   }
>        else if (strenght >= [enemyBug getStrenght]) //space is not
> free and
> 
> //you're stronger
>          {
>             [myList remove:enemyBug];
>          }
> 
>          if ([foodSpace getValueAtX: xPos Y: yPos]==1)
>         {
>           [foodSpace putValue:0 AtX: xPos Y: yPos];
>           strenght+=0.1;
>          } .........
> 
> In "ModelSwarm.m" I added the following bold line:
> .....
> aBug = [Bug createBegin: self];
>           [aBug setWorld: world Food: food];
>           [aBug setList:bugList];
>           aBug = [aBug createEnd];
> .......
> 
> The rest of code is left unchanged.
> Because it's only three days since I begun to study SWARM,I couldn't
> pretend my varation would have worked,infact the runtime system
> complains:Exception:STATUS_ACCES_VIOLATION
> What was my error?
> Finally a question on leaving unspecified the return value of a method
> (making it to return the default type id) even when it hasn't to
> return any value:it's a matter of  style or is there something behind
> that?
> 
> Thank you in advance for your advice.
> _______________________________________________________________
> Fabio Mascelloni.
> Dept. of Computer Science - University of Pisa,Italy
> e-mail: address@hidden

-- 
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
University of Kansas                  Office: (913) 864-9086
Lawrence, Kansas 66045                FAX: (913) 864-5700

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

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