def birdCheckCollision(bird): ''' Handles collision for the birds and updates game messages ''' if (bird.x + bird.radius) > (self.pipes[0].x + 75) and self.pipes[0].z == 0: bird.score += 1 # Handles the case in which a new high score is set if bird.score > self.highscore: self.bestBirdBrain = bird.brain self.foundBestBird = True self.highscore = bird.score self.pipes[0].z = 1 # Handles wall or pipe collision by adding and removing birds from the lists if bird.collidingWall() or bird.collidingPipe(): self.savedBirds.append(bird) self.birds.remove(bird) # Handles the death of the last bird if len(self.birds) == 0: self.gameDisplay.blit(self.image, [0, 0]) self.pipes = [] self.counter = 0 ga = GA(self) ga.nextGeneration() self.generation += 1 self.gameLoop()