swarm-support
[Top][All Lists]
Advanced

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

Re: your mail


From: Ken Cline
Subject: Re: your mail
Date: Mon, 21 Apr 1997 11:16:52 -0400 (EDT)

Kevin,

I'm not sure if I completely understand what you're trying 
to do... Are you trying to access the agent's xPos and yPos
from within one of the interactors?

If so then you'll probably want methods in the Agent class,
e.g.
   -(int) getX { return xPos; }
   -(int) getY { return yPos; }

and in the "sense" method:
   hereX = [ agent getX ];
   hereY = [ agent getY ];

(of course, the interactor has to then have a pointer to
agent, i.e. id agent = [ModelSwarm getAgent]; )

Have I completely missed what you asking/doing?

I your second attempt you appear to have a pointer to the
agent but I'm confused by why in Agent.m you call
    [agent getX: &stepX Y: &stepY];
and not
    [self getX: &stepX Y: &stepY];

Where is getX: Y: defined?

Sorry I couldn't be more helpful.

Ken.


On Mon, 21 Apr 1997, Kevin Allen wrote:

> Hi Guys
> 
> I am trying to produce a simulation and I feel that I have missed something 
> important.
> 
> I have created a class Agent
> 
> @interface Agent: SwarmObject{
> int xPos,yPos;
> Grid2D * world;
> id environmentSpace;
> }
> 
> 
> I have created another class Interactor
> 
> @interface Interactor: Agent{
> }
> 
> 
> I then do the following:
> 
> I create a single agent and a list of interactors.
> 
> In buildActions of my model:
> 
> [Actions createActionTo: agent message: M(step)];
> [Actions createActionForEach: interactorList message M(sense)];
> 
> in Agent.m
> 
> -step{
> ...
> stepX = xPos;
> stepY = yPos;
> ...
> }
> 
> in Interactor.m
> 
> -sense{
> ...
> hereX = xPos;
> hereY = yPos
> ...
> }
> 
> Now I was under the impression that an instance of Interactor would take the 
> properties of Agent. I
> would then be able to use xPos and yPos from within an action called by 
> Interactor.
> in stepI get the expected result but in sense I get 0 (zero).
>
> I also tried to achive the same result by defing an action getX:Y:
> 
> -getX: (int *) x Y: (int *) y;
> 
> I do the following:
> 
> I create a single agent and a list of interactors.
> 
> In buildActions of my model:
> 
> [Actions createActionTo: agent message: M(step)];
> [Actions createActionForEach: interactorList message M(sense)];
> 
> in Agent.m
> 
> -step{
> ...
> [agent getX: &stepX Y: &stepY];
> ...
> }
> 
> in Interactor.m
> 
> -sense{
> ...
> [agent getX: &hereX Y: &hereY];
> ...
> }
> 
> 
> I had expected that [agent getX:Y:] would work in both places. In step I get 
> incorrect values and in
> sense I get a sementation fault.
> 
> Is this enough information and can anyone help?
> 
> 
> Kevin Allen
> Intelligent Autonomous Systems Engineering Lab, UWE.
> 
> 
>                   ==================================
>    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.
>                   ==================================
> 

_________________________________________________________
Ken Cline                             address@hidden
SAIC                                 VOICE (410) 571-0413
Annapolis, MD                          FAX (301) 261-8427


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