private float[] CalculateFitness(Agent.Abstract.AAgentController[] agents) { var fitnesses = new float[agents.Length]; var popVectors = new List <Vector2>(agents.Length); foreach (var item in agents) { popVectors.Add(Vec3ToVec2(item.transform.position)); } for (int i = 0; i < agents.Length; i++) { var vecPos = Vec3ToVec2(agents[i].transform.position); var compToArch = _novelty_Archive.CompareToArchive(vecPos, 5); if (compToArch > _noveltyThreshold) { _novelty_Archive.Add(vecPos); } var compToPop = Novelty_archive.CompareToPopulation(popVectors, vecPos, 5); fitnesses[i] = compToArch + compToPop; } return(fitnesses); }
public AgentListEvaluator(IGenomeDecoder <NeatGenome, IBlackBox> decoder, GameObject gameObject, GameObject agentPrefab, IntContainer tickPerEvalCount) { _gameObject = gameObject; _decoder = decoder; _agentPrefab = agentPrefab; _tickPerEvalCount = tickPerEvalCount; _evaluationCount = 0; _novelty_Archive = new Novelty_archive(); _novelty_Archive.Add(Vec3ToVec2(gameObject.transform.position)); UnityThread.InitUnityThread(); }