swarm-support
[Top][All Lists]
Advanced

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

Re: Please, Help me out!!


From: Glen Ropella
Subject: Re: Please, Help me out!!
Date: Wed, 2 Oct 1996 15:53:22 -0600

> the instance of Machine. All the instances of parts are put in a list
> and all the instaces of machines are put in another list. The code is
> written in the Part class to send a message to Machine list. Now, when I 
> run, part is unable to identify the machine list which was initiated in
> Model swarm. Is it because the parts & machines are initiated in Model
> Swarm? Can any one please help me out. Thanks a lot.
> 
> -Naga Krothapalli

Do you have a pointer in each Part back to the machine list in the 
Model Swarm?  Without the code, it's hard to tell what might be
wrong.  But, in order for a Part to send a message to the Machine
List instance, it must have a valid pointer to that list.  So,
either you need to carry around a variable in each Part that points
to the Machine list or you have to pass the id of the Machine list
into the method in the Part that is trying to send the message to 
the list.

If you look in Heatbugs, the bug gets a pointer called "world"
that it can send messages to asking about the space around it.

In HeatbugModelSwarm.m:
    // Create the heatbug, set the creation time variables
    hbug = [Heatbug createBegin: [self getZone]];
>>> [hbug setWorld: world Heat: heat];
    hbug = [hbug createEnd];

sends a message to the newly created bug giving it a pointer
to the world its in.  Thus, when the bug queries the world:

>>> while ([world getObjectAtX: newX Y: newY] != nil && tries < 10) {
      newX = (x + [uniformRandom rMin: -1 Max: 2] + worldXSize) % worldXSize;
      newY = (y + [uniformRandom rMin: -1 Max: 2] + worldYSize) % worldYSize;
      tries++;                                    // don't try too hard.
    }

it has a pointer called "world" to query, which is declared in Heatbug.h as:
  Grid2d * world;                                 // the world I live in



If this isn't your problem, then you may want to post some code
to show a little more  detail.

glen

-- 
+-------------------------------------------------------------------------+
|glen e. p. ropella (address@hidden) |                                  |
|Hive Drone, SFI Swarm Project         |            Hail Eris!            |
|www.santafe.edu/~gepr/home.html       |                                  |
+-------------------------------------------------------------------------+


reply via email to

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