// "Probabilistic" - a probabilistic runnable // subclass must implement run {} to do first action and schedule // next steps with at() or atRelative() // Steppable is implemented only as convenience // (it steps the whole scheduler) // TODO: This is not very clear asclass Probabilistic implements IProbabilistic, Steppable { IProbabilisticScheduler ps; void initScheduler { if (ps == null) ps = new ProbabilisticScheduler; } public void setScheduler(IProbabilisticScheduler ps) { this.ps = ps; } void schedule aka at(Runnable action) { schedule(1.0, action); } void schedule aka at(double probability, Runnable action) { initScheduler(); ps.at(probability, action); } void scheduleRelative(double probability, Runnable action) { initScheduler(); ps.atRelative(probability, action); } void scheduleAll(double probability, Iterable actions) { forEach(actions, a -> schedule(probability, a)); } void scheduleAllRelative(double probability, Iterable actions) { forEach(actions, a -> scheduleRelative(probability, a)); } // call run() before void stepAll() { main stepAll(ps); } // call run() before public bool step() { ret ps.step(); } }