@@ -126,6 +126,7 @@ function PlayerCtrl ($scope, $timeout, $interval, $element) {
126126 }
127127
128128 function onFrameChange ( frame ) {
129+ // one frame in this method is one game turn, and contains subframes for each agent's actions
129130 for ( let i in ctrl . data . ids ) {
130131 $scope . agents [ i ] . stdout = null
131132 $scope . agents [ i ] . stderr = null
@@ -134,7 +135,7 @@ function PlayerCtrl ($scope, $timeout, $interval, $element) {
134135 $scope . referee = { }
135136 const frameData = ctrl . parsedGameInfo . frames [ frame ]
136137 for ( let i in ctrl . data . ids ) {
137- const subframe = frameData . subframes [ i ]
138+ const subframe = frameData . subframes . find ( subframe => subframe . agentId === i )
138139 if ( subframe ) {
139140 if ( subframe . stdout ) {
140141 $scope . agents [ i ] . stdout = subframe . stdout
@@ -148,9 +149,11 @@ function PlayerCtrl ($scope, $timeout, $interval, $element) {
148149 $scope . referee . stdout = frameData . referee . stdout
149150 $scope . referee . stderr = frameData . referee . stderr
150151 $scope . summary = frameData . gameSummary
152+ console . log ( frameData )
151153 }
152154
153155 function convertFrameFormat ( data ) {
156+ // 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
154157 const frames = data . views . map ( v => {
155158 let f = v . split ( '\n' )
156159 let header = f [ 0 ] . split ( ' ' )
@@ -168,12 +171,18 @@ function PlayerCtrl ($scope, $timeout, $interval, $element) {
168171 frames [ i ] . referee [ newKey ] = data [ key ] . referee [ i ]
169172 }
170173 }
171-
172174 for ( let pi in data . ids ) {
173175 frames [ i ] . stderr = frames [ i ] . stderr || data . errors [ pi ] [ i ]
174176 frames [ i ] . stdout = frames [ i ] . stdout || data . outputs [ pi ] [ i ]
177+ for ( let agentId in data . outputs ) {
178+ let output = data . outputs [ agentId ]
179+ // check that at turn i, agent has output not null, so it is agent's turn
180+ if ( output [ i ] != null && agentId !== 'referee' ) {
181+ frames [ i ] . agentId = agentId
182+ break
183+ }
184+ }
175185 }
176- frames [ i ] . agentId = - 1
177186 }
178187 const agents = data . agents . map ( a => Object . assign ( a , { avatarUrl : a . avatar } ) )
179188 const tooltips = data . tooltips . map ( JSON . stringify )
0 commit comments