Created
July 15, 2022 11:23
-
-
Save LiorB-D/93ee72308bf73f22878364d53579c404 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
frameCount += 1; | |
// If 200 frames has passed plus a scaled of the highestScore, then start next generation | |
if (frameCount > 200 + topFitnessScore * 3) { | |
startNewGen(); | |
frameCount = 0; | |
} else if (frameCount > 80) { // Check for inactivity after 80 frames | |
let stillActive = false; | |
// Make sure atleast one car has made progress without dying | |
cars.forEach((car) => { | |
if (car.fitness > 3 && car.dead == false) { | |
stillActive = true; | |
} | |
}); | |
if (stillActive == false) { | |
startNewGen(); | |
frameCount = 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment