From 5520cf4584f9f75d3957c8634ef1a91f17ddabe1 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 26 Nov 2020 22:27:57 -0600 Subject: [PATCH] DO evolve only once per generation --- src/scenes/game/GameScene.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scenes/game/GameScene.js b/src/scenes/game/GameScene.js index 17f8943..b455e9c 100644 --- a/src/scenes/game/GameScene.js +++ b/src/scenes/game/GameScene.js @@ -208,6 +208,8 @@ class GameScene extends Phaser.Scene { * Handle game restart */ onGameRestart() { + this.trainer.train(); + console.log(this.trainer.ga.mostFit.genome, this.trainer.ga.mostFit.fitness); this.isPlaying = true; this.readyToRestart = false; @@ -230,8 +232,6 @@ class GameScene extends Phaser.Scene { * Handle gameover */ onGameOver() { - this.trainer.train(); - console.log(this.trainer.population[0].genome); const { width: gameWidth, height: gameHeight } = this.scale.gameSize; this.isPlaying = false;