Transpiled version (4735L) is out of date.
1 | // Note: Service providers schedule actions. |
2 | // Only puzzle runners call step(). |
3 | // interface for ProbabilisticScheduler (#1031949) |
4 | sinterface IProbabilisticScheduler extends Steppable {
|
5 | // schedule an action at an absolute probability |
6 | void at(double probability, Runnable action); |
7 | |
8 | // schedule an action at a probability relative to |
9 | // currentProbability() |
10 | default void atRelative aka schedule(double probability, Runnable action) {
|
11 | at(currentProbability()*probability, action); |
12 | } |
13 | |
14 | double currentProbability(); // for thread, only while running a step |
15 | long stepCount(); |
16 | |
17 | double lastExecutedProbability(); |
18 | |
19 | default void run aka schedule aka at(Runnable x) {
|
20 | if (x == null) ret; |
21 | initAction(x); |
22 | x.run(); |
23 | } |
24 | |
25 | default void scheduleAll(Iterable<WithProbability<? extends Runnable>> l) {
|
26 | fOr (var x : l) |
27 | at(x.probability(), x!); |
28 | } |
29 | |
30 | default void initAction(O action) {
|
31 | if (action cast IProbabilistic) |
32 | action.setScheduler(this); |
33 | } |
34 | } |
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
| Snippet ID: | #1031995 |
| Snippet name: | IProbabilisticScheduler |
| Eternal ID of this version: | #1031995/19 |
| Text MD5: | 0499651dc005842595cf6a56cd4f6172 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2021-10-25 03:16:47 |
| Source code size: | 1034 bytes / 34 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 451 / 715 |
| Version history: | 18 change(s) |
| Referenced in: | [show references] |