let us specify start load etc

This commit is contained in:
wassname
2018-12-04 17:17:47 +08:00
parent 3dbccfc316
commit 50dcbebbc7
8 changed files with 44 additions and 40 deletions
+1 -1
View File
@@ -21,7 +21,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"display": "webpack-dev-server -d",
"train": "node --max-old-space-size=4096 scripts/train | tee outputs/train_$(date +\"%Y-%m-%d_%H-%M-%S\").log"
"train": "node --max-old-space-size=8192 scripts/train | tee outputs/train_$(date +\"%Y-%m-%d_%H-%M-%S\").log"
},
"repository": {
"type": "git",
File diff suppressed because one or more lines are too long
+16 -2
View File
@@ -3,14 +3,14 @@
<head>
<title>Reinforcement Learning 2D Biped Walkers</title>
<style link="css/walkers.css"></style>
</head>
<body>
<div id="main_holder">
<h1>Reinforcement Learning 2D Humanoid Walkers</h1>
<h3 id="page_quote">"Play that funky music, robot"</h3>
<canvas id="main_screen" width="800" height="350" style="background: url('./images/background.png')"></canvas>
<canvas id="main_screen2" width="800" height="350" style="background: url('./images/background.png')"></canvas>
<image style="display: none" src="./images/background.png"></image><!-- for google and previews-->
@@ -47,5 +47,19 @@
</body>
<script>
function init() {
var canvas_id = 'main_screen2'
window.game = new Game(config, canvas_id)
game.agent.restore('./checkpoints', 'model-ddpg-walker-22h/model') // load checkpoint
game.agent.restore('../outputs', 'model-ddpg-walker/model') // load latest
game.loop()
chooseQoute()
var canvas=document.getElementById(canvas_id)
canvas.style.background=''
}
window.addEventListener("load", init, false);
</script>
</html>
+5 -13
View File
@@ -1,15 +1,7 @@
const { Game } = require('./js/game')
const { Game, chooseQoute } = require('./js/game')
window.b2 = require('./vendor/jsbox2d')
const config = require('./js/config')
window.config = require('./js/config')
window.chooseQoute = chooseQoute
window.Game = Game
require('./css/walkers.css')
var game
window.game = game
function init() {
window.game = new Game(config)
}
window.addEventListener("load", init, false);
module.exports = {game, Game}
module.exports = {Game}
+4 -1
View File
@@ -23,7 +23,10 @@ function createFloor(world, max_floor_tiles) {
edges[edges.length - 1].y + (ratio * Math.random() - ratio / 2)));
// edges.push(new b2.Vec2(edges[edges.length-1].x + 1,-0.16));
}
edges.push(new b2.Vec2(edges[edges.length - 1].x, edges[edges.length - 1].y + 18)); // front wall
edges.push(new b2.Vec2(edges[edges.length - 1].x + 5, edges[edges.length - 1].y + 5)); // front wall
edges.push(new b2.Vec2(edges[edges.length - 1].x + 7, edges[edges.length - 1].y + 15)); // front wall
edges.push(new b2.Vec2(edges[edges.length - 1].x + 8, edges[edges.length - 1].y + 35)); // front wall
edges.push(new b2.Vec2(edges[edges.length - 1].x + 8, edges[edges.length - 1].y + 45)); // front wall
fix_def.shape.CreateChain(edges, edges.length);
body.CreateFixture(fix_def);
return body;
+6 -9
View File
@@ -93,23 +93,20 @@ class HeadlessGame {
}
}
var removeCanvasBackground = function (){
var canvas=document.getElementById('main_screen')
canvas.style.background=''
}
class Game extends HeadlessGame {
constructor(config) {
constructor(config, canvas_id) {
config.canvas_id = canvas_id
super(config)
this.agent.stop()
this.agent.restore('./checkpoints', 'model-ddpg-walker-22h/model') // load checkpoint
this.agent.restore('../outputs', 'model-ddpg-walker/model') // load latest
}
loop() {
setInterval(() => {
this.play()
}, 1000/this.config.draw_fps)
chooseQoute()
removeCanvasBackground()
}
/**
+2 -2
View File
@@ -4,8 +4,8 @@ class Renderer {
this.walkers = [walker]
this.floor = floor
this.main_screen = document.getElementById("main_screen");
this.ctx = main_screen.getContext("2d");
this.main_screen = document.getElementById(config.canvas_id);
this.ctx = this.main_screen.getContext("2d");
this.resetCamera();
}
+7 -9
View File
@@ -8,14 +8,12 @@ var ENV = process.env.NODE_ENV || "development";
module.exports = {
entry: {
app: './src/index.js',
// lib: './src/vendor/index.js'
},
target: 'web',
devtool: ENV==="development"? 'dev-source-map': null,
devtool: ENV==="development"? 'dev-source-map': false,
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].bundle.js',
// path:'/dist',
},
module: {
rules: [
@@ -46,16 +44,16 @@ module.exports = {
}
},
plugins: [
new webpack.DefinePlugin({
// A flag to disable node imports, and enable window/dom usage
WEB: true
}),
new HtmlWebpackPlugin({ template: '!!html-loader!src/index.html' }),
new CopyWebpackPlugin([
{ from: 'src/images', to: 'images' },
{from:'checkpoints',to:'checkpoints'}
{ from: 'checkpoints', to: 'checkpoints' },
{from:'src/css',to:'css'}
]),
new webpack.DefinePlugin({
// A flag to disable node imports, and enable window/dom usage
WEB: true
}),
]
};