red42 / HTML5_Genetic_Cars

A genetic algorithm car evolver in HTML5 canvas.
zlib License
1.19k stars 290 forks source link

Purpose of 'elite' clones #25

Closed codyd51 closed 7 years ago

codyd51 commented 8 years ago

Looking at the is_elite var in cawro.js, it seems the only difference elite clones have with standard ones are their color. Do they serve any other purpose?

ojcm commented 7 years ago

From the information at the bottom of the HTML page:

Elite clones: The top n cars that will be copied over to the next generation.

So "Elite clones" are clones of the best performing "n" cars from the previous generation. There is nothing else special about these cars. They are colored differently so the user can distinguish between clones and new cars.

I'd be interested to hear what people have found about the impact of more or fewer Elite clones has on the evolution of their cars.

This section of code copies the top cars to the next generation (link):

for(var k = 0; k < gen_champions; k++) {
    cw_carScores[k].car_def.is_elite = true;
    cw_carScores[k].car_def.index = k;
    newGeneration.push(cw_carScores[k].car_def);
  }

gen_champions is set with (link):

function cw_setEliteSize(clones) {
  gen_champions = parseInt(clones, 10);
}

Which, in turn, is called when one changes the "Elite clones" field on the page (link):

Elite clones:
        <select id="elitesize" onchange="cw_setEliteSize(this.options[this.selectedIndex].value)">
          <option value="0">0</option>
          <option value="1" selected="selected">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
          <option value="6">6</option>
          <option value="7">7</option>
          <option value="8">8</option>
          <option value="9">9</option>
          <option value="10">10</option>
        </select>
codyd51 commented 7 years ago

I see. Thanks for the info!