public void GenerateInitalPopulation() { population = new List <GeneticPlayer>(); aliveCount = populationCount; for (int i = 0; i < populationCount; i++) { Vector3 pos = GetPos(i); GeneticPlayer geneticPlayer = Instantiate(geneticPlayerPrefab, pos, Quaternion.Euler(spawnRotation)); Genom genom; if (geneticPlayerPrefab.mode == Mode.LoadAndTrain) { genom = Genom.LoadFromFile(geneticPlayerPrefab.GetSavePath()); if (i > 0) { genom = Genom.MutateAll(genom, 0.01f); } } else { genom = geneticPlayer.InitGenom(); genom.RandomizeAll(); //случайные гены } geneticPlayer.SetGenom(genom); population.Add(geneticPlayer); } }
private void Start() { //sensors = InitSensors(); //Debug.Log("ApplyGenom"); if (mode == Mode.Train || mode == Mode.LoadAndTrain) { if (!genomInistalized) { Debug.LogWarning("Genom is not inistalized.\n Maybe you forgot add GeneticGame.cs on scene?"); Genom newgenom = InitGenom(); newgenom.RandomizeAll(); SetGenom(newgenom); } } else if (mode == Mode.LoadAndTest) { SetGenom(Genom.LoadFromFile(GetSavePath())); } //Debug.Log(genom); ApplyGenom(genom); }