[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Passing arguments in a list
From: |
Marcus Vinicius Pereira Pessoa |
Subject: |
Re: Passing arguments in a list |
Date: |
Mon, 21 Jul 1997 08:42:04 -0300 |
Thanks for your help Ken,
First, you were right, my machine's date wasn't correctly set. I did
everything you said but it didnt solve completely the problem. As the
Persons methods were already corrected I changed my focus from the
Persons step to the Modelswarm´s buildObjects. So I inspected the list
and saw that it was receiving wrong values: the list wasnt been built
correctly.
Vinicius.
ModelSwarm:
id moves;
id index;
-> neighbor_t* temp_move;
// build the list of moves
moves = [List create: [person getZone] ];
for (inck = 1; inck < 8; inck++) {
temp_move = [uniformUnsRand getUnsignedWithMin: 1L withMax:
VNSet];
-> [moves addLast: temp_move];
}
// tell the person what her comm numbers are
[person setPerson: name Move_list: moves];
Ken Cline wrote:
>
> Vinicius,
>
> First, I'm not sure why your message is dated 10 May; did
> you really send it 2 monthes ago? I'll presume that that
> just a mistake.
> It looks to me as if you are trying to access a list member
> at "Start". "Start" doesn't point to a valid member of a
> list, but instead is a special pointer location. (This is
> also true for "End".)
>
> So, in your "step" method, you might try:
>
> -step {
> // look for a place to move
> index = [moves begin: [self getZone]];
> [index setLoc: Start];
>
> --> [index next];
> 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];
> }
> }
> }
>
> Let me know if this solves the problem.
>
> BTW, you could eliminate the passing of "index" to the
> person. That is, since ModelSwarm doesn't make use of
> "index", there's no need to declare it there. Then the
> "setPerson" method becomes:
>
> -setPerson: (id) n Move_list: (id) mm {
> name = n;
> moves = mm;
> index = [moves begin: [self getZone]];
> stillhere = 1; // always here when initialized
> return self;
> }
>
> Also, since index is an instance variable of "Person", the
> "step" method shouldn't need to keep reassigning it, unless
> of course the "moves" list was reassigned. That is, in
> "step", you should only need "[index setLoc: Start]" and can
> eliminate "index = [moves begin: [self getZone]]".
>
> }
>
>I hope this helps.
>
>Ken.
==================================
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.
==================================