public void start() {
for(int i=0;i<initialAgents;i++) { Agent parent = new Agent(); }
schedule.scheduleRepeating(Schedule.EPOCH,0,parent,1);
Steppable reproduction = new Steppable() {
public void step(SimState state) {
for(int i=0;i<numAdultParents;i++) {
Agent child = new Agent ();
schedule.scheduleRepeating(schedule.time()+1,0,child,1);
}
}
};
schedule.scheduleRepeating(600, 1, reproduction, 300);
}
Sean Luke wrote:
>> public Bag agents; // filled with parents and children
>> public void step() {
>> agents.shuffle(this.random);
>> for (int agentNdx=0 ; agentNdx>> schedule.scheduleOnce(agents.objs[agentNdx]);
>> }
>> }
>
>
> FWIW, there's a tool which does this already: RandomSequence.
Does RandomSequence work for dynamic data structures? It appears from
the code:
-------------------
public Steppable[] steps;
[...]
for(int x=steps.length-1; x>0 ; x--)
{
int i = (shouldSynchronize ?
nextInt(state,x+1) : state.random.nextInt(x+1));
temp = steps[i];
steps[i] = steps[x];
steps[x] = temp;
}
super.step(state);
--------------------
that we're using a fixed size array. And if that's the case, I'd have
to recreate the RandomSequence at each cycle, thereby defeating the
purpose. But, perhaps I'm just not looking deep enough. To resize an
array, you'd have to replace the old Sequence instance variable with a
new array (with the new size), right?
--
glen e. p. ropella =><= Hail Eris!
H: 503-630-4505 http://ropella.net/~gepr
M: 503-971-3846 http://tempusdictum.com
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com