Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        timeTicker -= Time.deltaTime;

        Time.timeScale = 2;

        if (timeTicker < 0)
        {
            generationCount++;
            UpdateGenerationText();

            population = genAlg.Epoch(ref population);


            for (int i = 0; i < noOfLoaders; ++i)
            {
                NeuralNetwork    neuralNetwork    = loaders[i].GetComponent <NeuralNetwork>();
                LoaderController loaderController = loaders[i].GetComponent <LoaderController>();

                float        randomX = Random.Range(-4.5f, 4.5f);
                float        randomZ = Random.Range(-4.5f, 4.5f);
                List <float> weights = new List <float>(population[i].GetWeights());

                neuralNetwork.PutWeights(ref weights);

                Debug.Log(i);

                loaders[i].transform.position = new Vector3(randomX, 0.3f, randomZ);
                loaderController.ResetFitness();
                weights.Clear();
            }

            timeTicker = timeLeft;
        }
    }
Ejemplo n.º 2
0
 // Called third
 void OnSceneLoaded(Scene scene, LoadSceneMode mode)
 {
     Log.Color("OnSceneLoaded: " + scene.name, this);
     if (!loader)
     {
         GameObject newLoader = Instantiate(loaderPrefab, this.transform);
         loader = newLoader.GetComponent <LoaderController>();
     }
     loader.SetLoader(false);
 }
Ejemplo n.º 3
0
 void Start()
 {
     if (main)
     {
         Destroy(gameObject);
     }
     else
     {
         main = this;
         DontDestroyOnLoad(gameObject);
     }
 }
Ejemplo n.º 4
0
 void Start()
 {
     if (retryButton != null)
     {
         retryButton.onClick.AddListener(ReloadLevel);
     }
     if (quitButton != null)
     {
         quitButton.onClick.AddListener(QuitGame);
     }
     loaderController = FindObjectOfType <LoaderController>();
 }
Ejemplo n.º 5
0
        public async Task LoaderControllerGiphyFail()
        {
            var cloud = new FakeCloudHandler();

            cloud.Result.Setup(m => m.Execute(It.IsAny <GiphyCmd>()))
            .Returns(ActionConfirm.CreateFailure("Something went wrong"));

            var controller = new LoaderController(Data, cloud, Logic)
            {
                CurrentUser = StandardUser
            };
            var result = await controller.Gif(UserData.FirstId) as NotFoundResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <NotFoundResult>();

            cloud.HasExecuted.Should().BeTrue();
        }
Ejemplo n.º 6
0
        public async Task LoaderControllerGiphySuccess()
        {
            var cloud = new FakeCloudHandler();

            cloud.Result.Setup(m => m.Execute(It.IsAny <GiphyCmd>()))
            .Returns(ActionConfirm.CreateSuccess("https://image.com/img.png"));

            var controller = new LoaderController(Data, cloud, Logic)
            {
                CurrentUser = StandardUser
            };
            var result = await controller.Gif(UserData.FirstId) as JsonResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <JsonResult>();

            cloud.HasExecuted.Should().BeTrue();
        }
Ejemplo n.º 7
0
        public async Task LoaderControllerUploadSuccess()
        {
            var data  = new VisibleApiDataHandler();
            var logic = new CoreApiLogicHandler();
            var model = VisibleData.GetFirst();

            logic.Result.Setup(m => m.Execute(It.IsAny <ProcessFile>())).Returns(ActionConfirm.CreateSuccess(model));

            var controller = new LoaderController(data, Cloud, logic)
            {
                CurrentUser = StandardUser
            };
            var result = await controller.Upload(VisibleData.GetFile()) as JsonResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <JsonResult>();

            data.HasExecuted.Should().BeFalse();
            logic.HasExecuted.Should().BeTrue();
        }