swarm-support
[Top][All Lists]
Advanced

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

Passing arguments in a list


From: Marcus Vinicius Pereira Pessoa
Subject: Passing arguments in a list
Date: Sat, 10 May 1997 13:46:41 -0300

Hi,

I’ve been listening to this list for a long time and now I’m trying to
make my first simulation. I am modifying the hello-world example and
trying to create a list of moves that will be a characteristic from each
person. They will move trough the world during a finite time. In each
step they will try the next possible move (choosing sequentially from
the list).
But I am having a problem with the code. I tried to make the list in the
ModelSwarm and in the Person itself and none of these tries worked, in
both of them I always receive an empty list in the Person’s step method.

ModelSwarm:

    id moves;
    id index;
    neighbor_t temp_move;

// build the list of moves
    moves = [List create: [person getZone] ];
    index = [moves begin: [person getZone]];
    for (inck = 1; inck < 8; inck++) {
      temp_move =  [uniformUnsRand getUnsignedWithMin: 1L withMax:
VNSet];
      [moves addLast: (void *) &temp_move];
    }
// tell the person what her comm numbers are
    [person setPerson: name Move_list: moves index_pointer: index ];

Person:

-step {

    // look for a place to move
    index = [moves begin: [self getZone]];
    [index setLoc: Start];
for (inci=0; inci < 8; inci++) {
      newNeigh = (neighbor_t) [index get]; 
// if we found an empty one, exit the loop
       if ([self getAgentAtNeighbor: newNeigh] == nil) {
        gotOne = 1;
        break;
      }
        else {
        [index next];
      }
}


-setPerson: (id) n  
  Move_list: (id) mm
  index_pointer: (id) p {
    name = n;
    moves = mm;
    index = p;
    stillhere = 1;   // always here when initialized
  return self;
}

I would appreciate if someone could give me some advice.

Thanks in advance,

Vinicius.

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