swarm-support
[Top][All Lists]
Advanced

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

[no subject]


From: DARREN MATTHEW SCHREIBER
Date: Tue, 7 Sep 1999 12:41:34 -0700 (PDT)

I am working on an algorithm that parses a list of agents and merges some
of them.  Since I am removing some agents while the algorithm is looping,
I have been having trouble making sure that I don't go past the end of the
list (I solved this by changing to a do while loop) and checking each of
the agents.  I was thinking of that one solution would be to put a
placeholder in the list that I could then remove once the algorithm had
run.  Could I just put an integer there?  How would I do that?  I want to
avoid having to create a dummy object.

Here is what I am currently using:

i=0;
listLength=[availableList getCount];
do {
 id newCoalition;

 agent1=[availableList atOffset: i];
 agent2=[agent1 getClosestNeighbor];
 agent3=[agent2 getClosestNeighbor];
 if (agent1==agent3) {
  newCoalition=[self formNewCoalition: agent1 two: agent2];
  [availableList atOffset: i put: newCoalition];
 }
 listLength=[availableList getCount];
 i=i++;
} while (i<listLength)

Any ideas would be appreciated...


                Darren



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