Skip to content

Minor presentation bug in the example 9.4 Interactive Selection. #1092

Open
@alcides-schulz

Description

@alcides-schulz

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions