Skip to content

Commit ed0717d

Browse files
fixing classic controller interface
1 parent 0916659 commit ed0717d

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

index.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,24 @@ class ProxyController{
4141
this.policy.reset()
4242
}
4343
}
44+
class MultiController{
45+
constructor(Controller){
46+
this.Controller = Controller
47+
this.controllers = null
48+
}
49+
evaluate_step(state){
50+
if(this.controllers === null || this.controllers.length !== state.length){
51+
this.controllers = state.map(() => new this.Controller())
52+
}
53+
return state.map((state, i) => this.controllers[i].evaluate_step(state))
54+
}
55+
reset(){
56+
if(this.controllers === null){
57+
return
58+
}
59+
this.controllers.forEach(controller => controller.reset())
60+
}
61+
}
4462

4563
let model = null
4664
class Policy{
@@ -211,7 +229,7 @@ async function main(){
211229
const url = URL.createObjectURL(blob);
212230
const Controller = (await import(url)).default
213231
URL.revokeObjectURL(url);
214-
proxy_controller.policy = new Controller()
232+
proxy_controller.policy = new MultiController(Controller)
215233
window.controller = proxy_controller.policy
216234
}
217235
})

0 commit comments

Comments
 (0)