@@ -126,6 +126,7 @@ function PlayerCtrl ($scope, $timeout, $interval, $element) {
126
126
}
127
127
128
128
function onFrameChange ( frame ) {
129
+ // one frame in this method is one game turn, and contians subframes for each agent's actions
129
130
for ( let i in ctrl . data . ids ) {
130
131
$scope . agents [ i ] . stdout = null
131
132
$scope . agents [ i ] . stderr = null
@@ -134,7 +135,14 @@ function PlayerCtrl ($scope, $timeout, $interval, $element) {
134
135
$scope . referee = { }
135
136
const frameData = ctrl . parsedGameInfo . frames [ frame ]
136
137
for ( let i in ctrl . data . ids ) {
137
- const subframe = frameData . subframes [ i ]
138
+ let subframe
139
+ if ( frameData . subframes . length > 1 ) {
140
+ subframe = frameData . subframes [ i ]
141
+ } else {
142
+ if ( frameData . subframes [ 0 ] . agentId === i ) {
143
+ subframe = frameData . subframes [ 0 ]
144
+ }
145
+ }
138
146
if ( subframe ) {
139
147
if ( subframe . stdout ) {
140
148
$scope . agents [ i ] . stdout = subframe . stdout
@@ -148,9 +156,11 @@ function PlayerCtrl ($scope, $timeout, $interval, $element) {
148
156
$scope . referee . stdout = frameData . referee . stdout
149
157
$scope . referee . stderr = frameData . referee . stderr
150
158
$scope . summary = frameData . gameSummary
159
+ console . log ( frameData )
151
160
}
152
161
153
162
function convertFrameFormat ( data ) {
163
+ // one frame in this method means one output, if in a single game turn two agents act, the two actions are put in separate frames
154
164
const frames = data . views . map ( v => {
155
165
let f = v . split ( '\n' )
156
166
let header = f [ 0 ] . split ( ' ' )
@@ -168,12 +178,17 @@ function PlayerCtrl ($scope, $timeout, $interval, $element) {
168
178
frames [ i ] . referee [ newKey ] = data [ key ] . referee [ i ]
169
179
}
170
180
}
171
-
172
181
for ( let pi in data . ids ) {
173
182
frames [ i ] . stderr = frames [ i ] . stderr || data . errors [ pi ] [ i ]
174
183
frames [ i ] . stdout = frames [ i ] . stdout || data . outputs [ pi ] [ i ]
184
+ for ( let agentId in data . outputs ) {
185
+ let output = data . outputs [ agentId ]
186
+ // check that at turn i, agent has output not null, so it is agent's turn
187
+ if ( output [ i ] != null && agentId !== 'referee' ) {
188
+ frames [ i ] . agentId = agentId
189
+ }
190
+ }
175
191
}
176
- frames [ i ] . agentId = - 1
177
192
}
178
193
const agents = data . agents . map ( a => Object . assign ( a , { avatarUrl : a . avatar } ) )
179
194
const tooltips = data . tooltips . map ( JSON . stringify )
0 commit comments