Well, I'm not even sure if they are actually bugs, but these 2 Things kept making me concerned.
1) In both the "getFittest" and the "getAverage" function, you first check if the scores are undefined. If so you call the "evaluate" function to recalculate the scores.
The problem I had was "evaluate" being an async function, so when you return the result the score might not even be updated yet.
2) In the "getFittest" and the "getParent" function, you check if the population is sorted by comparing only the first two values. I'm not an expert but, unless you didn't make sure the first genome has the lowest score if the population isn't sorted this won't work for sure!!!
I hope I didn't break something else in the process but I "fixed" the problem like this for me:
Well, I'm not even sure if they are actually bugs, but these 2 Things kept making me concerned.
1) In both the "getFittest" and the "getAverage" function, you first check if the scores are undefined. If so you call the "evaluate" function to recalculate the scores. The problem I had was "evaluate" being an async function, so when you return the result the score might not even be updated yet.
2) In the "getFittest" and the "getParent" function, you check if the population is sorted by comparing only the first two values. I'm not an expert but, unless you didn't make sure the first genome has the lowest score if the population isn't sorted this won't work for sure!!!
I hope I didn't break something else in the process but I "fixed" the problem like this for me:
https://imgur.com/UrAYyMN