File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ let model = null
4646class Policy {
4747 constructor ( ) {
4848 this . step = 0
49+ this . state = null
4950 }
5051 evaluate_step ( state ) {
5152 state . observe ( )
@@ -92,18 +93,19 @@ class Policy{
9293 }
9394 }
9495 const observation_description = document . getElementById ( "observations" ) . observation
95- let input = math . matrix ( [ [ observation_description . split ( "." ) . map ( x => get_obs ( x ) ) . flat ( ) ] ] )
96+ let input = math . matrix ( [ observation_description . split ( "." ) . map ( x => get_obs ( x ) ) . flat ( ) ] )
9697 const input_offset = default_trajectory ( this . step / 100 )
9798 input_offset . forEach ( ( x , i ) => {
98- input . _data [ 0 ] [ 0 ] [ i ] = input . _data [ 0 ] [ 0 ] [ i ] - x
99+ input . _data [ 0 ] [ i ] = input . _data [ 0 ] [ i ] - x
99100 } )
100- const output = model . evaluate_step ( input )
101+ const [ output , new_state ] = model . evaluate_step ( input , this . state )
102+ this . state = new_state
101103 this . step += 1
102- return output . valueOf ( ) [ 0 ] [ 0 ]
104+ return output . valueOf ( ) [ 0 ]
103105 }
104106 reset ( ) {
105107 this . step = 0
106- model . reset ( )
108+ this . state = null
107109 }
108110}
109111
You can’t perform that action at this time.
0 commit comments