//Oblicza dopasowanie auta float FitnessFunc() { float fitness = 0, dist2 = 0.1f, dist3 = 0, dist4 = 0, dist5 = 0; int currentpoint = 0; currentpoint = ChPoints.NearestPoint(gameObject.transform); if (currentpoint > 0) { dist2 = Vector3.Distance(gameObject.transform.position, ChPoints.Points[currentpoint - 1].position); dist3 = Vector3.Distance(ChPoints.Points[currentpoint].position, ChPoints.Points[currentpoint - 1].position); } if (currentpoint < ChPoints.Points.Length - 1) { dist4 = Vector3.Distance(gameObject.transform.position, ChPoints.Points[currentpoint + 1].position); dist5 = Vector3.Distance(ChPoints.Points[currentpoint].position, ChPoints.Points[currentpoint + 1].position); } return(fitness += currentpoint - (dist3 / dist2) + (dist5 / dist4)); }