Example #1
0
    void Update()
    {
        if (canStart)
        {
            //Change waiting time with the slider at runtime
            maxTimer = 5.3f - slider.value;

            timer += Time.deltaTime;
            if (!end)
            {
                if (timer > maxTimer)
                {
                    Vector2 action;

                    if (DQLearning)
                    {
                        //Path Finding with deep network
                        action = agentDQL.ChooseAction();
                        agentDQL.PerformAction(action);
                    }
                    else
                    {
                        //Path Finding Q-Table
                        action = agentQTable.ChooseAction();
                        agentQTable.PerformAction(action);
                    }
                    timer = 0;
                }
            }
            else
            {
                if (timer > maxTimer)
                {
                    Restart();
                    print("Restart");
                    timer = 0;
                }
            }

            //Not best solution
            epsilonText.text     = "EPSILON: " + epsilon.ToString("F3");
            stepsText.text       = "STEPS: " + steps;
            epochText.text       = "EPISODE: " + epoch;
            totalRewardText.text = "TOTAL REWARD: " + totalReward;
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            canStart = true;
        }
    }