示例#1
0
    // Use this for initialization
    void Start()
    {
        isTheChosenOne    = true;
        filePathPosResNum = Application.dataPath + pathPosNum;
        if (File.Exists(filePathPosResNum))
        {
            fileContent = File.ReadAllText(filePathPosResNum);
            trajectory  = JsonUtility.FromJson <JsonRobotData>(fileContent);
            Debug.Log(trajectory.time);
            filePos.Close();
            if (trajectory.time == 0.0f)
            {
                CheckIteration();
            }
        }

        alpha = startingAlpha;
        beta  = startingBeta;

        if (alpha + beta < 1f)
        {
            CheckIteration();
        }

        timer       = Timer();
        robot       = GameObject.Find("Robot");
        robotScript = robot.GetComponent <Robot>();
        rPl         = robot.GetComponent <RobotPlanning>();
        rP          = robot.GetComponent <RobotProgress>();
        rDMUtility  = robot.GetComponent <RobotDMUtilityCloseWall>();

        rDMUtility.alpha             = startingAlpha;
        rDMUtility.beta              = startingBeta;
        robotScript.forgettingFactor = forgettingFactor[startingDelta];
        rP.pathMapNum = pathMapNum + iteration.ToString() + ".json";
        rP.pathPosNum = pathPosNum + iteration.ToString() + ".json";

        alpha      = startingAlpha;
        beta       = startingBeta;
        deltaIndex = startingDelta;

        //robotScript.SetVariables();
        rP.DefiningFolderAndFile();
        rP.SetAlpha(alpha);
        rP.SetBeta(beta);
        rP.SetDelta(forgettingFactor[deltaIndex]);
        rP.SetMapName(mapName);

        Debug.Log(rDMUtility.alpha);
        Debug.Log(rDMUtility.beta);
        Debug.Log(robotScript.forgettingFactor);

        StartCoroutine(timer);
    }
示例#2
0
    private void OnLevelWasLoaded(int level)
    {
        if (!isTheChosenOne)
        {
            Destroy(this.gameObject);
        }
        else
        {
            iteration = 1 + iteration;
            if (alpha < maxAlpha)
            {
                alpha = 0.1f + alpha;
            }
            else if (beta < maxBeta)
            {
                beta  = 0.1f + beta;
                alpha = minAlpha;
            }
            else if (deltaIndex < maxDeltaIndex)
            {
                deltaIndex = deltaIndex + 1;
                alpha      = minAlpha;
                beta       = minBeta;
            }

            filePathPosResNum = Application.dataPath + pathPosNum;
            if (File.Exists(filePathPosResNum))
            {
                fileContent = File.ReadAllText(filePathPosResNum);
                trajectory  = JsonUtility.FromJson <JsonRobotData>(fileContent);
                Debug.Log(trajectory.time);
                filePos.Close();
                if (trajectory.time == 0.0f)
                {
                    CheckIteration();
                }
            }

            if (alpha + beta < 1f)
            {
                CheckIteration();
            }

            timer                        = Timer();
            robot                        = GameObject.Find("Robot");
            robotScript                  = robot.GetComponent <Robot>();
            rPl                          = robot.GetComponent <RobotPlanning>();
            rP                           = robot.GetComponent <RobotProgress>();
            rDMUtility                   = robot.GetComponent <RobotDMUtilityCloseWall>();
            rDMUtility.alpha             = alpha;
            rDMUtility.beta              = beta;
            robotScript.forgettingFactor = forgettingFactor[deltaIndex];
            rP.pathMapNum                = pathMapNum + iteration.ToString() + ".json";
            rP.pathPosNum                = pathPosNum + iteration.ToString() + ".json";

            //robotScript.SetVariables();
            rP.DefiningFolderAndFile();
            rP.SetAlpha(alpha);
            rP.SetBeta(beta);
            rP.SetDelta(forgettingFactor[deltaIndex]);
            rP.SetMapName(mapName);

            Debug.Log(alpha);
            Debug.Log(beta);
            Debug.Log(forgettingFactor[deltaIndex]);

            StartCoroutine(timer);
        }
    }