From 9ec0f62bae11e235bdfb0fa5214d61ff3b028cc1 Mon Sep 17 00:00:00 2001 From: Kaustubh Olpadkar Date: Thu, 16 May 2019 10:46:15 +0530 Subject: [PATCH 1/2] change map after few successful rounds of map for model generalization --- sketch.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/sketch.js b/sketch.js index 92d883c..d4fdc3a 100644 --- a/sketch.js +++ b/sketch.js @@ -26,6 +26,15 @@ let inside = []; let outside = []; let checkpoints = []; +// around 5-6 successfully completed rounds will make the fitness of 500+ +// so maxFitness is set to 500 +// thus the changeMap will flag becomes true and we will create new map +// when any of the particle completes multiple rounds in current map +// this will help to make the current generation to work on new map +// and generalize to variety of maps +const maxFitness = 500; +let changeMap = false; + function buildTrack() { checkpoints = []; inside = []; @@ -104,6 +113,22 @@ function draw() { if (particle.dead || particle.finished) { savedParticles.push(population.splice(i, 1)[0]); } + + if (!changeMap && particle.fitness > maxFitness) { + changeMap = true; + } + } + + if (population.length !== 0 && changeMap) { + console.log("i ma here") + for (let i = population.length - 1; i >= 0; i--) { + savedParticles.push(population.splice(i, 1)[0]); + } + + buildTrack(); + nextGeneration(); + generationCount++; + changeMap=false; } if (population.length == 0) { From fd075490500b69aec298a3815c139a5b30c31ca4 Mon Sep 17 00:00:00 2001 From: Kaustubh Olpadkar Date: Thu, 16 May 2019 10:56:02 +0530 Subject: [PATCH 2/2] quickfix --- sketch.js | 1 - 1 file changed, 1 deletion(-) diff --git a/sketch.js b/sketch.js index d4fdc3a..b06d075 100644 --- a/sketch.js +++ b/sketch.js @@ -120,7 +120,6 @@ function draw() { } if (population.length !== 0 && changeMap) { - console.log("i ma here") for (let i = population.length - 1; i >= 0; i--) { savedParticles.push(population.splice(i, 1)[0]); }