Hey Kirupians
I’ve been reading some stuff on neural networks, and I’m now trying to implement it in AS3. One thing thats giving me a hard time, is the way the individuals with the best fitness, has a probability of getting selected. It’s described as spinning a large roulette wheel, where individuals has more space on, relative to their fitness. The wheel is then spinned, and the larger regions, have a higher change of getting selected.
It might be explained better by this image

My question is, how do i implement this in code?
My best idea so far, is adding all the fitnesses, and then generating a random number. Then go through an array, and if this random number is between this fitness and all its previous fitnesses summed, and the next fitness with all its previous summed, we got a winner.
I just somehow got the feeling that this is not the best way to do this. I could also just select the 2 individuals with the best fitness, but thats not how evolution works.
Thanks in advance