Skip to content

Instantly share code, notes, and snippets.

@LiorB-D
Created July 15, 2022 11:23
Show Gist options
  • Save LiorB-D/93ee72308bf73f22878364d53579c404 to your computer and use it in GitHub Desktop.
Save LiorB-D/93ee72308bf73f22878364d53579c404 to your computer and use it in GitHub Desktop.
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