Ejemplo n.º 1
0
        void Start()
        {
            if (neuralNetworks == null && NetworkSerializator.HasData())
            {
                neuralNetworks = NetworkSerializator.Load();
                Debug.Log("Network Available");
            }

            Debug.Log("Network Loaded");
            Debug.Log(neuralNetworks);
        }
Ejemplo n.º 2
0
        void Update()
        {
            if (currentIterationsNumber == 0)
            {
                currentIterationsNumber = iterationsNumber;
            }

            if (!isGameCreated)
            {
                game = new Game();
                if (neuralNetworks == null)
                {
                    game.CreateGame();
                }
                else
                {
                    game.CreateGame(neuralNetworks);
                }
                SetWholeLevel();

                isGameCreated    = true;
                gameIterationsCD = gameIterations;
                gameTimeCD       = gameTime;
                iterationSpeed   = uint.Parse(PreferencesScript.iterSpeed);
                iterationsNumber = uint.Parse(PreferencesScript.iterNum);
            }
            else
            {
                // todo: the same when only one opponent left
                if (CheckIfGameEnded())
                {
                    isGameCreated  = false;
                    neuralNetworks = game.ExportNeuralNetworks();
                    neuralNetworks.NextGeneration();
                    NetworkSerializator.Save(neuralNetworks);
                    RemoveWholeLevel();
                    currentIterationsNumber--;
                    Debug.Log("Iterations Left: " + currentIterationsNumber);
                    if (currentIterationsNumber <= 0)
                    {
                        SceneManager.LoadScene("StartMenu");
                    }
                }
                else
                {
                    game.MakeIteration((int)iterationSpeed);
                    gameIterationsCD -= iterationSpeed;
                    gameTimeCD       -= Time.deltaTime;
                }
            }

            // todo : updates position and rotation of all enemies
        }