swarm-support
[Top][All Lists]
Advanced

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

Re: Inter-agent communication in Discrete2d


From: Steve Railsback
Subject: Re: Inter-agent communication in Discrete2d
Date: Fri, 10 May 2002 12:06:48 +0100
User-agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1

John Langley wrote:

Hi,

I have agent running around on a Discrete2d object.

I would like to have them access each others variables when they bump
into each other, using this kind of approach:

-(int)someMethod
{
return somePointer;
}


I cannot find a way of getting one agent to send a message directly to
another agent, based on grid reference, and be returned some internal
value, e.g. somePointer.


It is possible for one agent to check if a neighbouring cell is occupied
by e.g.:

if ([world getObjectAtX: newX Y: newY] = 1    -> 'cell occupied'

if ([world getObjectAtX: newX Y: newY] = nil  -> 'cell empty'


Where 'world' is the pointer, or 'id' to Discrete2d.

The getObjectAtX: xPos Y:yPos method only allows an agent to detect if
there is another agent at some other position, but apparently does not
allow returning of internal values from methods.


Hmm, Discrete2d should do what you want- getObjectAtX: Y: returns the object at X,Y, not a 1. (It is just a typo in your email that you use a single "=" instead of "==" ?)

You should be able to do stuff like:

if  ([world getObjectAtX: newX Y: newY] != nil)
  neighborsSize = [[world getObjectAtX: newX Y: newY] getSize];


where getSize is just a method that the agents have that returns their size.

Check for typos or syntax errors...







                 ==================================
  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]