source: src/main/java/genius/core/timeline/Timeline.java

Last change on this file was 127, checked in by Wouter Pasman, 6 years ago

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

File size: 1.7 KB
Line 
1package genius.core.timeline;
2
3/**
4 * A time line, running from t = 0 (start) to t = 1 (deadline).
5 */
6public abstract class Timeline implements TimeLineInfo {
7 protected boolean hasDeadline;
8 protected boolean paused = false;
9
10 /**
11 * In a time-based protocol, time passes within a round. In contrast, in a
12 * rounds-based protocol time only passes when the action is presented.
13 */
14 public enum Type {
15 /**
16 * Time passes with wall clock time. Usually the clock used is
17 * {@link System#nanoTime()} or similar so it also proceeds while others
18 * use the CPU.
19 */
20 Time,
21 /**
22 * time advances only when the action is presented. Time is frozen while
23 * an agent is computing its next step.
24 */
25 Rounds;
26 }
27
28 /**
29 * Gets the time, running from t = 0 (start) to t = 1 (deadline). The time
30 * is normalized, so agents need not be concerned with the actual internal
31 * clock.
32 *
33 * @return current time in the interval [0, 1].
34 */
35 public abstract double getTime();
36
37 /**
38 * @return amount of time in seconds, or amount of rounds depending on
39 * timeline type.
40 */
41 public abstract double getTotalTime();
42
43 /**
44 * @return amount of seconds passed, or amount of rounds passed depending on
45 * the timeline type.
46 */
47 public abstract double getCurrentTime();
48
49 /**
50 * @return true if deadline is reached.
51 */
52 public boolean isDeadlineReached() {
53 return hasDeadline && (getTime() >= 1.0);
54 }
55
56 /**
57 * @return type of time: Type.Time or Type.Rounds.
58 */
59 public Type getType() {
60 return Type.Time;
61 }
62
63 /**
64 * @return true if timeline is paused.
65 */
66 public boolean isPaused() {
67 return paused;
68 }
69}
Note: See TracBrowser for help on using the repository browser.