public void ResetAndLogCarTermination(bool usurped = false) { if (!isDemo) { GameObject car = this.gameObject; PopulationManager popMan = evolutionManager.GetComponent <PopulationManager>(); car.GetComponent <NeuralNetwork>().Sleep(); CalculateTheIndividualsFitness(); popMan.PositionCarAtStartLine(car); lastPosition = transform.position; isDriving = false; culled = false; } else { GameObject car = this.gameObject; PopulationManager popMan = evolutionManager.GetComponent <PopulationManager>(); // Stop // Meant to be a check to penalize the known best if it crashes - but not working right if (!culled && NumberCarsFinished > 15 && !usurped) { float distCovered = Vector3.Distance(StartPos, this.gameObject.transform.position); if (distanceTravelled != 0) { tempStoreOfDistTravelled = distanceTravelled; } float latestFitness = CalculateTheIndividualsFitness(); if (latestFitness < 0.9f * popMan.GlobalBestNN_Fitness && tempStoreOfDistTravelled > 100 && isDriving) { this.gameObject.transform.position = StartPos; // need to get the corresponding Personal-Best and adjust by same amount for (int x = 0; x < popMan.PersonalBestNN_Fitness.Count; x++) { if (popMan.PersonalBestNN_Fitness[x] == popMan.GlobalBestNN_Fitness) { popMan.PersonalBestNN_Fitness[x] = latestFitness; popMan.GlobalBestNN_Fitness = latestFitness; } } } } popMan.PositionCarAtStartLine(car); lastPosition = transform.position; distanceTravelled = 0; finishingBonus = 1; car.GetComponent <NeuralNetwork>().Sleep(); isDriving = false; culled = false; popMan.ResetDemoCar(); } }