示例#1
0
        static void Main(string[] args)
        {
            //Initialize needed functions
            var t = new TuringMachineFunction();
            var d = new DelayFunction();
            var e = new ExitFunction();


            DoWelcomeScreen();
        }
        public void DoInstructions(string[] instructionLine)
        {
            if (!GetCompleted())
            {
                if (!GetPaused())
                {
                    elements[header.GetPosition()] = instructionLine[2].ToCharArray()[0];
                    if (instructionLine[3].ToCharArray()[0] == 'L')
                    {
                        header.MoveHeaderLeft();
                    }
                    else
                    {
                        header.MoveHeaderRight();
                    }

                    if (instructionLine[4].ToCharArray()[0] == 'X')
                    {
                        //Console.Clear();
                        StopSimulation();
                    }
                    else
                    {
                        string[] newInstructions = FindInstructionsForSymbolAndState(GetSymbolAtPosition(header.GetPosition()), instructionLine[4]);
                        currentInstructions = newInstructions;
                        Thread.Sleep(TuringMachineFunction.delay);
                        if (newInstructions != null)
                        {
                            DoInstructions(newInstructions);
                        }
                        else
                        {
                            StopSimulation();
                            Console.WriteLine();
                            Console.WriteLine("Cannot continue the simulation. Press any key to return to the menu...");
                            Console.ReadKey();
                            Program.DoWelcomeScreen();
                            TuringMachineFunction.Reset();
                        }
                    }
                }
            }
        }