//Here is a code fragment from Bob Kewley. I'll fit it into a swarm boilerplate someday, //if I get time. // originalList is the original list of agents // there are M different lists to partition these into id lists; id agent; int j; lists = [Array create: [self getZone] setCount: M]; for (i = 0; i < M; i++) { [lists atOffset: i put: [List create: [self getZone]]; } while ((agent = [originalList removeFirst]) != nil) { // for each original agent j = [uniformIntRand getRandomSampleWithMin: 0 withMax: (M-1)]; [[lists atOffset: j] addLast: agent]; } //pj should probably use uniformUnsRand here.