2 ms·
Nice! Yeah I was thinking about trying to genericise it so you could plug your own fitness function in, but didn't get around to it. I got an error when playin
by user24 16y ago
Nice! Yeah I was thinking about trying to genericise it so you could plug your own fitness function in, but didn't get around to it.
I got an error when playing with the values though; pop 400, mutation 0.2, crossover 0.8: "When executing function:this.people[peopleSize - i] is undefined"
- icefox 16y agoIn mine the two options have be less than 1.0 when combined. So out of all genomes, 20% (.2) goes to crossover, 80% (.8) goes to crossover and the rest live. The two numbers have to be less than 1.0 for some to remain alive from one round to the next. This gives the option to also specify how many survive from one round to the next v.s (correct me if this is wrong) a random amount each time in your example. For what it is worth you graph looks much nicer :) Back when I first made mine the canvas tag wasn't around and js was much slower. Really should remove the 'you might get an image!' text before the graph.
- user24 16y agoAh, right I see :) > This gives the option to also specify how many survive from one round to the next v.s (correct me if this is wrong) a random amount each time in your example. in mine the population is constant. A set of two parents always have exactly two children. Breeding occurs until there are exactly as many children as there are parents, then the children mutate, and murder their parents. Genetics is fun! Yeah I'm really happy with the graph, thanks! Canvas API is a bit clunky, but powerful (especially now we're allowed to write text into it!) edit: what selection method are you using?
- icefox 16y agoSay 10% mutate and 60% crossover, that leaves 30% to live another round and be the parents for the crossover and mutation. After the fitness function is run the results are sorted by the fitness value. The lowest get to live and be part of the 30% the live/mutate/crossover. Link to the js: http://icefox.github.com/javascript_genetic_algorithm/javascriptgeneticalgorithm.js http://icefox.github.com/javascript_genetic_algorithm/javasc...