Print

Print


Another potential solution is to use the scheduleOnce method.  In the
step() method of your agents, you could test if they are alive on the
current time step.  If so, then run
        scheduleOnce(state.schedule.time()+1.0f, this)

If they are dead, then just omit the previous line.  This will effectly
schedule the agents only when they are alive.  However, this method will
not work if you have agents that die and are later resurected.

Keith

On Tue, 5 Oct 2004, Rob Alexander wrote:

> Tony Bigbee wrote:
> > Is there a recommended way to dynamically remove specific Steppable
> > objects from the schedule?
>
> I've been doing:
>
> entity.setStoppable( schedule.scheduleRepeating(entity) );
>
> ...which then allows me to do.....
>
>         if( this.stoppable != null )
> {
>       this.stoppable.stop();
> }
>
> (you'll need to define stoppable and setStoppable() in your entity class)
>
> I had a quick look at the Mason scheduler code, but couldn't figure out
> whether this truly takes the entity off the schedule (and, hence,
> whether its any more efficient than your current approach). I'll have
> another look when I have time (if Sean doesn't provide a better answer
> in the mean time, of course).
>
>
> yours,
> rob
>
> --
> Rob Alexander                   (E-mail: [log in to unmask])
> Research Associate, Dept of Computer Science, The University of York,
> York, YO10 5DD, UK
> Tel: 01904 432792       Fax: 01904 432708
>