improve html

This commit is contained in:
wassname
2019-01-14 13:44:19 +08:00
parent 4a3513e018
commit b16ab6a8ca
3 changed files with 7 additions and 8 deletions
+3 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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();
}