// Note: Service providers schedule actions. // Only puzzle runners call step(). // interface for ProbabilisticScheduler (#1031949) sinterface IProbabilisticScheduler extends Steppable { // schedule an action at an absolute probability void at(double probability, Runnable action); // schedule an action at a probability relative to // currentProbability() default void atRelative aka schedule(double probability, Runnable action) { at(currentProbability()*probability, action); } double currentProbability(); // for thread, only while running a step long stepCount(); double lastExecutedProbability(); default void run aka schedule aka at(Runnable x) { if (x == null) ret; initAction(x); x.run(); } default void scheduleAll(Iterable> l) { fOr (var x : l) at(x.probability(), x!); } default void initAction(O action) { if (action cast IProbabilistic) action.setScheduler(this); } }