Commit 1b9025ff authored by Tomás Teijeiro Campo's avatar Tomás Teijeiro Campo

Changed mutation effect on range borders

parent 048fae6e
...@@ -25,9 +25,10 @@ invadersApp.evolution = { ...@@ -25,9 +25,10 @@ invadersApp.evolution = {
if (Math.random() < mutation) { if (Math.random() < mutation) {
// Mutate this gene // Mutate this gene
var value = chance.pickone([-1.0, 1.0]) * Math.random() * (genes[gen].max - genes[gen].min) * effect; var value = chance.pickone([-1.0, 1.0]) * Math.random() * (genes[gen].max - genes[gen].min) * effect;
if (children[gen] + value < genes[gen].min || children[gen]+value > genes[gen].max) value = -value;
children[gen] = children[gen] + value; children[gen] = children[gen] + value;
if (children[gen] < genes[gen].min) children[gen] = genes[gen].min; //if (children[gen] < genes[gen].min) children[gen] = genes[gen].min;
if (children[gen] > genes[gen].max) children[gen] = genes[gen].max; //if (children[gen] > genes[gen].max) children[gen] = genes[gen].max;
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment