-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathegi.ts
More file actions
176 lines (138 loc) · 2.87 KB
/
Copy pathegi.ts
File metadata and controls
176 lines (138 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
// External Game Interface
declare var PlayEGI : EGI;
interface EGI {
onSignal(handler: (signal: Signal) => void): void;
ready(): void;
pong(): void;
finish(metrics: Metrics, memory: any): void;
motor(preset: "positive" | "negative"): void;
}
// Signals
type Signal
= { "type": "Hello", settings: Settings, memory: any }
| { "type": "Ping" }
| { "type": "Suspend" }
| { "type": "Resume" }
| { "type": "Step", direction: Direction, isSynthetic: boolean }
| { "type": "Release", direction: Direction, isSynthetic: boolean }
| { "type": "SensoState", state: SensoState }
;
type Direction
= "Center" | "Up" | "Right" | "Down" | "Left";
interface SensoState {
center: Activation;
up: Activation;
right: Activation;
down: Activation;
left: Activation;
}
interface Activation {
x: number;
y: number;
f: number;
}
// Commands
type Command
= { "type": "Ready" }
| { "type": "Ready" }
| { "type": "Pong" }
| { "type": "Finish", metrics: Metrics }
| { "type": "Error", error: any }
| { "type": "Motor", preset: "positive" | "negative" }
;
// Settings
type Settings = {
[label: string]: Setting;
};
type Setting
= Time
| DirectionDistribution
| Float
| Int
| Percentage
| String
| Bool
;
// a time value, unit: ms
interface Time {
"type": "Time";
value: number;
}
// a probability distribution for the four plate directions
interface DirectionDistribution {
"type": "DirectionDistribution";
value: { element: "Up" | "Right" | "Down" | "Left", p: number }[];
}
// a unitless float value
interface Float {
"type": "Float";
value: number;
}
// a unitless integer value
interface Int {
"type": "Int";
value: number;
}
// a percentage value (0.5 is 50 %)
interface Percentage {
"type": "Percentage";
value: number;
}
// a string value
interface String {
"type": "String";
value: string;
}
// boolean flag
interface Bool {
"type": "Bool";
value: boolean;
}
// Metrics
type Metrics = {
[label: string]: MetricValue;
};
type MetricValue
= RawFloat
| RawInt
| Distance
| ReactionTime
| Duration
| Text
| Flag
;
// a float without special semantics
interface RawFloat {
"type": "RawFloat";
value: number;
}
// an int without special semantics
interface RawInt {
"type": "RawInt";
value: number;
}
// distance, unit: mm
interface Distance {
"type": "Distance";
value: number;
}
// (average) time for some reaction, unit: ms
interface ReactionTime {
"type": "ReactionTime";
value: number;
}
// duration (usually of game), unit: ms
interface Duration {
"type": "Duration";
value: number;
}
// free text value
interface Text {
"type": "Text";
value: string;
}
// boolean flag
interface Flag {
"type": "Flag";
value: boolean;
}