| 5 | class Population { |
| 6 | |
| 7 | constructor(size) { |
| 8 | this.popSize = size; |
| 9 | this.players = []; |
| 10 | for (let i = 0; i < size; i++) { |
| 11 | this.players.push(new Player()); |
| 12 | } |
| 13 | |
| 14 | this.showingFail = false; |
| 15 | this.failPlayerNo = 0; |
| 16 | this.bestPlayerIndex = 0; |
| 17 | this.currentHighestPlayerIndex = 0; |
| 18 | this.fitnessSum = 0; |
| 19 | this.gen = 1; |
| 20 | this.bestHeight = 0; |
| 21 | this.showingLevelNo = 0; |
| 22 | this.currentBestLevelReached = 0; |
| 23 | this.purgeTheSlackers = false; |
| 24 | this.reachedBestLevelAtActionNo = 0; |
| 25 | this.newLevelReached = false; |
| 26 | this.cloneOfBestPlayerFromPreviousGeneration = this.players[0].clone(); |
| 27 | } |
| 28 | |
| 29 | Update() { |
| 30 | for (let i = 0; i < this.players.length; i++) { |