Пример #1
0
    // Use this for initialization
    void Start()
    {
        loseGame.text = "";

        cubeCtrlScriptRef = cube.GetComponent <CubeController>();

        varForPrefab           = Resources.Load("prefabs/MainCube", typeof(GameObject)) as GameObject;
        numIterationsScriptRef = varForPrefab.GetComponent <numIterationsScript>();


        while ((mazeWidth = cell.GetComponent <MazeGenerator>()._width) == -1 || (mazeHeight = cell.GetComponent <MazeGenerator>()._height) == -1)
        {
        }
        mazeWidth  = cell.GetComponent <MazeGenerator>()._width;
        mazeHeight = cell.GetComponent <MazeGenerator>()._height;
        Debug.Log(mazeWidth);
        Debug.Log(mazeHeight);
        // for n * n mazes (n(n+2) - 1) / 2
        hitFactDenom = energyPenaltyDivFactor(mazeWidth, mazeHeight);

        energyHitFactor = (mazeWidth * (mazeWidth + 2) - 1) / hitFactDenom; // the denomitaor here scales out the large penalty do to errors ai will make
        // different function for non square mazes

        Debug.Log(hitFactDenom);
        Debug.Log(energyHitFactor);
    }
    void Start()
    {
        energyScriptRef = energyBarr.GetComponent <energyScript>();
        lookupTable     = GetComponent <QTable>();
        lookupTable.qTableInit();
        tableMessenger = GetComponent <TextWriteTest>();
        // keep reference to numIterations alive when scene reload
        variableForPrefab      = Resources.Load("prefabs/MainCube", typeof(GameObject)) as GameObject;
        numIterationsScriptRef = variableForPrefab.GetComponent <numIterationsScript>();
        // run the read function to update Qtable from local text files
        read();
        numIterationsScriptRef.numIterations += 1;    // increment numIterations
        completeText.text = "";
        StartCoroutine(runStartText());

        // if aiEnabled = false hide the aiCube and render in the playerCube
        if (aiEnabled == false)
        {
            cube.SetActive(false);
            CubeController scriptRef = GetComponent <CubeController>();
            scriptRef.enabled = false;  // disable the mlScript so computations dont use resources in background
        }
        if (playerEnabled == false)
        {
            //playerCube.SetActive(false);
            GameObject.Destroy(playerCube);
            //CubeController scriptRefTwo = GetComponent<playerController>();
            //scriptRefTwo.enabled = false;
        }
        else
        {
            aiCam.enabled = false;
        }
        dataObj         = GetComponent <DataCollect>();
        positions       = dataObj.getPositions();
        directionsTaken = dataObj.getdDirectionTaken();
        distToGoal      = dataObj.getDistToGoal();
        canMoveLeft     = dataObj.getCanMoveLeft();
        canMoveRight    = dataObj.getCanMoveRight();
        canMoveBack     = dataObj.getCanMoveBack();
        canMoveForward  = dataObj.getCanMoveForward();
        rewardGiven     = dataObj.getRewardGiven();
    }