Print

Print


Thanks Sean, I've just came up with this and wanted to update my post.
What I did is I specified a Stoppable stopme variable within agent. And
assigned schedule.scheduleRepeating(agent) to it. This way it works.

Best,

Aydar


On Thu, Aug 15, 2013 at 2:24 PM, Sean Luke <[log in to unmask]> wrote:

> On Aug 14, 2013, at 7:55 PM, Aуdar Aliev wrote:
>
> > The problem is that I need to remove an agent from the schedule (I
> presume that after removing it from the schedule garbage collector will get
> to it) when his internal condition becomes true. For example, when agent
> stepped more than 50 times. How do I do that?
>
> When you schedule an agent repeating, the scheduleRepeating() method
> returns a Stoppable object.  Store that Stoppable somewhere (perhaps in the
> agent itself), and call it when the condition has become true.  The agent
> will then not be rescheduled any more.  You don't need to implement the
> Stoppable interface.
>
> You can also do this if you have scheduled an agent once but may wish to
> prevent his upcoming step() from ever occurring: this is done by using
> TentativeStep (see the manual).
>
> Sean
>