mirror of
https://github.com/wassname/rl_2d_walker.js.git
synced 2026-09-10 12:32:46 +08:00
improve html
This commit is contained in:
@@ -103,7 +103,7 @@ class DDPGAgent {
|
||||
}
|
||||
}
|
||||
|
||||
async restore(folder, name) {
|
||||
async restore(folder, name, callback) {
|
||||
/*
|
||||
Restore the weights of the network
|
||||
*/
|
||||
@@ -131,6 +131,8 @@ class DDPGAgent {
|
||||
this.ddpg.perturbedActor = copyModel(this.ddpg.actor, Actor);
|
||||
//this.adaptivePerturbedActor = copyModel(this.actor, Actor);
|
||||
this.ddpg.setLearningOp();
|
||||
|
||||
if (callback) callback()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -137,8 +137,8 @@ class Game extends HeadlessGame {
|
||||
}
|
||||
|
||||
|
||||
loadBrain(folder, name) {
|
||||
this.agent.restore(folder, name)
|
||||
loadBrain(folder, name, callback) {
|
||||
this.agent.restore(folder, name, callback)
|
||||
// var title = name.replace('model-ddpg-walker-', '').replace('/model', '').replace('model-ddpg-walker', '')
|
||||
// document.getElementById('brain-name').innerText = title
|
||||
|
||||
|
||||
+2
-5
@@ -19,15 +19,15 @@ class Renderer {
|
||||
this.config.draw_fps = fps;
|
||||
if (this.draw_interval)
|
||||
clearInterval(this.draw_interval);
|
||||
if (fps > 0 && this.config.simulation_fps > 0) {
|
||||
if (fps > 0 && this.config.draw_fps > 0) {
|
||||
this.draw_interval = setInterval(this.drawFrame.bind(this), Math.round(1000 / this.config.draw_fps));
|
||||
}
|
||||
}
|
||||
|
||||
drawFrame() {
|
||||
// clear
|
||||
this.ctx.clearRect(0, 0, this.main_screen.width, this.main_screen.height);
|
||||
this.ctx.save();
|
||||
this.ctx.clearRect(0, 0, this.main_screen.width, this.main_screen.height);
|
||||
|
||||
// camera
|
||||
var minmax = this.getMinMaxDistance();
|
||||
@@ -48,10 +48,7 @@ class Renderer {
|
||||
for (let i = 0; i < this.walkers[0].balls.length; i++) {
|
||||
const ball = this.walkers[0].balls[i];
|
||||
this.drawCircle(ball)
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.ctx.restore();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user