Open
Description
When pressing the button "evolve new generation" it is showing the flowers drawings behind the button, instead of below the button.
The source of issue is in the method "reproduction()" of population.js, when the flowers are recreated, the value for y parameter is 80, instead of 120, which is the value used in the constructor.
reproduction() {
let nextFlowers = [];
// Create the next population with children from the mating pool
for (let i = 0; i < this.flowers.length; i++) {
// Sping the wheel of fortune to pick two parents
let parentA = this.weightedSelection();
let parentB = this.weightedSelection();
let child = parentA.dna.crossover(parentB.dna);
// Mutate their genes
child.mutate(this.mutationRate);
nextFlowers[i] = new Flower(child, 40 + i * 80, 80); // <---- y parameter should be 120 as in the constructor
}
// Replace the old population
this.flowers = nextFlowers;
this.generations++;
}
Metadata
Metadata
Assignees
Labels
No labels