Sender: |
|
Date: |
Thu, 9 Jun 2005 13:22:32 -0700 |
Reply-To: |
|
Content-Transfer-Encoding: |
7bit |
Subject: |
|
From: |
|
Content-Type: |
text/plain; charset=ISO-8859-1; format=flowed |
In-Reply-To: |
|
MIME-Version: |
1.0 |
Comments: |
|
Parts/Attachments: |
|
|
Sean Luke wrote:
>> public Bag agents; // filled with parents and children
>> public void step() {
>> agents.shuffle(this.random);
>> for (int agentNdx=0 ; agentNdx<agents.numObjs ; 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
|
|
|