diff --git a/package.json b/package.json index bff31b6..3efeca7 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,9 @@ "description": "TODO: Write a project description", "main": "index.js", "dependencies": { - "@tensorflow/tfjs": "^0.14.0", + "@tensorflow/tfjs-node": "^0.1.17", + "@tensorflow/tfjs-node-gpu": "^0.1.17", + "fs-extra": "^7.0.0", "canvas": "^2.1.0", "jsdom": "^13.0.0", "phaser": "^3.15.1" diff --git a/src/js/config.js b/src/js/config.js index 4af17e5..6adcbb3 100644 --- a/src/js/config.js +++ b/src/js/config.js @@ -12,6 +12,7 @@ module.exports = { max_floor_tiles: 50, round_length: 1000, min_body_delta: 0, - min_leg_delta: 0.0, + min_leg_delta: 0.0, + action_repeat: 4, }; diff --git a/src/js/walker.js b/src/js/walker.js index 26cb587..6fd78bb 100644 --- a/src/js/walker.js +++ b/src/js/walker.js @@ -17,7 +17,7 @@ class Walker { this.floor = floor this.config = config - this.rewardAverage = new MovingAverage(1000) + this.rewardAverage = new MovingAverage(5000) this.density = 106.2; // common for all fixtures, no reason to be too specific @@ -554,7 +554,9 @@ class Walker { @action: (Integer) The action to take (can be null if no action) */ this.simulationPreStep(motorSpeeds) - this.world.Step(1 / this.config.time_step, this.config.velocity_iterations, this.config.position_iterations); + for (let i = 0; i < this.config.action_repeat; i++) { + this.world.Step(1 / this.config.time_step, this.config.velocity_iterations, this.config.position_iterations); + } this.steps++ /* score/reward */ // reward copied from OpenAI Gym Humanoid Walker https://github.com/openai/gym/blob/master/gym/envs/mujoco/humanoid.py @@ -615,7 +617,7 @@ class Walker { var done = 0 this.world.ClearForces(); this.rewardAverage.add(this.reward) - if (this.steps % 500 == 0) + if (this.steps % 1000 == 0) console.debug('reward', this.steps, this.rewardAverage.mean()) return [this.getState(), this.reward, done, info] } @@ -635,11 +637,11 @@ class Walker { } reset() { /** Reset position to initial or random position TODO */ - console.log('reset not implemented') + // console.log('reset not implemented') } shuffle() { /** Reset position to initial or random position TODO */ - console.log('shuffle not implemented') + // console.log('shuffle not implemented') } }