Beispiel #1
0
        /// <summary>
        /// Initializes the <see cref="GameMaster"/> singleton. This is called in
        /// the <see cref="GameMasterMonobehavior.Awake"/> method so that all
        /// <see cref="GameMasterMonobehavior"/> sub-classes can access the
        /// <see cref="GameMaster"/> instance.
        ///
        /// Grabs Unity prefab resources for UI and sprites, instantiates the
        /// random seed, the grid, and the Turing machines, and then begins
        /// the simulation update co-routine.
        /// </summary>
        public void Initialize()
        {
            if (UseCustomSeed)
            {
                Random.InitState(RandomSeed);
            }
            else
            {
                RandomSeed = Random.Range(int.MinValue, int.MaxValue);
                print("SEED: " + RandomSeed.ToString());
                Random.InitState(RandomSeed);
            }

            TuringMachineHeadPrefab        = (GameObject)Resources.Load("Turing Machine Head");
            TuringMachineEditorPanelPrefab = (GameObject)Resources.Load("TuringMachineEditorCanvas");

            GridData       = new GridData();
            TuringMachines = new TuringMachine[NumberOfTuringMachines];
            for (int machineID = 0; machineID < NumberOfTuringMachines; machineID++)
            {
                TuringMachine newMachine = new TuringMachine(machineID, NumberStatesPerMachine);
                if (RandomStartingTransitions)
                {
                    newMachine.GenerateRandomTransitions();
                }
                TuringMachines[machineID] = newMachine;
            }

            RunSimulation = false;
            IEnumerator simulationUpdater = TuringMachineUpdateClock();

            StartCoroutine(simulationUpdater);
        }