Exemplo n.º 1
0
        private void Start()
        {
            m_aliveGenomes     = new List <Genometype>();
            m_weightOptimizers = new List <WeightOptimize>();

            startText.gameObject.SetActive(false);

            if (SavingSystem.DataFileExist(saveFileName))
            {
                readFileName = saveFileName;
            }

            if (readFileName != "")
            {
                GenomeStructEvolveData data;
                try
                {
                    data = SavingSystem.GetGenome <GenomeStructEvolveData>(readFileName, readFileName.EndsWith("json"));
                }
                catch (System.IO.FileNotFoundException) {
                    StartFromScratch();
                    m_gameStartTime = Time.unscaledTime;
                    base.ResetGame();
                    return;
                }

                m_aliveGenomes.AddRange(data.aliveBirds);
                m_structureGenerationCount = data.structureGenerationCount;

                for (int i = 0; i < m_aliveGenomes.Count; i++)
                {
                    m_weightOptimizers.Add(new WeightOptimize(this, genomeBirdCount, genomeBirdSurviveCount));
                    m_weightOptimizers[i].InsertGenome(m_aliveGenomes[i], fullyRandom: false);
                }
            }
            else
            {
                StartFromScratch();
            }

            m_gameStartTime = Time.unscaledTime;

            base.ResetGame();
        }