[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Swarm-Support] Re: Re: working with (indexed) lists: beginner's Q
From: |
Jurgen van der Pol |
Subject: |
[Swarm-Support] Re: Re: working with (indexed) lists: beginner's Q |
Date: |
Tue, 4 May 2004 00:59:36 +0200 |
Paul,
Thanks. Partial success, but not quite. it works somewhat, but not as I
would like.
In bug.m:
- (void) setMyCargoList: aList // this gets its input from modelswarm.m
-buildObject via [aBug setMyCargoList: cargoList];
{
myCargoList = aList; // the list in a bug variable
myCargoIndex = [myCargoList begin: [self getZone]]; // the index in a
bug variable
}
- setMyCargo
{
Cargo *myCargo; // ok, pointer to a cargo object
myCargo = [myCargoIndex next]; // or get, anyways bug variable gets
input from(via?) the index
xDest = [myCargo getXDest]; // x destination coordinates from cargo
object
yDest = [myCargo getYDest]; // ditto y destination
credits = [myCargo getCargoValue]; // the value from the cargo
object
}
This works a bit. In that the bugs at least get their three variables
set with the data from the cargo object. However, due to
modelswarm.m
-buildObject
{
...
[aBug setMyCargoList: cargoList];
...
}
during bug construction, each bug has the same local instance of the
cargo list made in modelswarm. However, - setMyCargo in bug.m causes
all bugs (assume 10 bugs, 10 cargo's) to get the same destination for
each 'cycle' (bug #1 thru #10 get cargo #1's specifics like x,y
destination), so they all head off to the same spot, then get the next
one from the list (bug #1 thru #10 get cargo #2), all head to there
etc. What I need is to have bug #1 to get cargo #1, bug #2 cargo #2
etcetera. I'm not sure how to fix this (yet).
Ultimo, I want to have one global list with independent cargo movements
on it (cargo appears, gets allocated to a truck, dies if not picked up,
etc). The other independent bit are the bugs whom all should have have
updatable (refresh) access to this constantly shifting cargo list
entity, can bid on what's present, get some, do the chores and get back
for more. So there is a model schedule issue here, but that's another
question ;-)
cargoIndex = [cargoList begin: [self getZone]]; //note, in Model swarm,
//use begin: self, in Bug,
//use this
Ok, thanks for pointing out the difference.
Cargo * anObject; //specific declaration for clarity
for (anObject = [cargoIndex next]; [cargoIndex getLoc]==Member;
anObject= [cargoIndex next])
{
//do something to cargo objects
}
[cargoIndex drop];
It' still not clear to me from the documentation & examples what the
specifics are for a list and for an index thereof. E.g. where does
Member gome from?
All the other stuff about making the changes show on the grid is really
a separate problem.
Understood, that's not where the problem is anyways.
Thanks for the examples, they clarified some, but not all.
Ok, back to trail & error on a sunny North Sea coast tomorrow...
Cheers,
Jurgen.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Swarm-Support] Re: Re: working with (indexed) lists: beginner's Q,
Jurgen van der Pol <=