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