Exemplo n.º 1
0
    //Construye la máquina
    void BuildMachine()
    {
        string tira = "βββ" + inputMachine.text + "βββ";

        CreateMachine(tira);

        switch (dropMachine.value)
        {
        case 0:
            //Machine Palindrome
            rm = mr.getPal();
            tm = new TuringMachine(tira, rm, new int[] { 11 });

            break;

        case 1:
            //Machine Copy
            rm = mr.getCopy();

            tm = new TuringMachine(tira, rm, new int[] { 1 });

            break;

        case 2:
            //Machine Mult
            rm = mr.getMult();

            tm = new TuringMachine(tira, rm, new int[] { 11 });

            break;

        case 3:
            //Machine Sum
            rm = mr.getSum();

            tm = new TuringMachine(tira, rm, new int[] { 3 });

            break;

        case 4:
            //Machine Sub
            rm = mr.getSub();

            tm = new TuringMachine(tira, rm, new int[] { 3 });

            break;
        }

        //Disble buttons when the machine is working
        btnNext.interactable      = false;
        inputMachine.interactable = false;
        dropMachine.interactable  = false;
        btnReset.interactable     = false;

        //And now Turn on the Machine
        //InvokeRepeating("MotorMachine", 0.5f, 0.5f);
        StartCoroutine(MotorMachine());
    }
Exemplo n.º 2
0
    //build the machine
    void BuildMachine()
    {
        string tira = "βββ" + inputMachine.text + "βββ";

        CreateMachine(tira);

        switch (dropMachine.value)
        {
        case 0:
            //Machine Palindrome
            string pattern = @"([0-1]+)$";      //validate String
            Match  match   = Regex.Match(inputMachine.text, pattern);

            if (match.Success)
            {
                rm = mr.getPal();
                tm = new TuringMachine(tira, rm, new int[] { 11 });
            }

            break;

        case 1:
            //Rehana's Language E={0^i1^j|i>j}
            string Rpattern = @"([0-1-X-Y]+)$";      //validate String
            Match  Rmatch   = Regex.Match(inputMachine.text, Rpattern);

            if (Rmatch.Success)
            {
                rm = mr.getRehana();
                tm = new TuringMachine(tira, rm, new int[] { 6 });
            }

            break;

        case 2:
            //Anber's Language WW^R W={ab}*
            string Apattern = @"([a-b]+)$";      //validate String
            Match  Amatch   = Regex.Match(inputMachine.text, Apattern);

            if (Amatch.Success)
            {
                rm = mr.getAnber();
                tm = new TuringMachine(tira, rm, new int[] { 8 });
            }

            break;

        case 3:
            //Anita's Language L={a^m b^n c^m*n|m,n>=1}
            string Anitapattern = @"([a-b-c]+)$";      //validate String
            Match  Anitamatch   = Regex.Match(inputMachine.text, Anitapattern);

            if (Anitamatch.Success)
            {
                rm = mr.getAnita();
                tm = new TuringMachine(tira, rm, new int[] { 6 });
            }

            break;
        }

        //Disble buttons when the machine is working
        btnNext.interactable      = false;
        inputMachine.interactable = false;
        dropMachine.interactable  = false;
        btnReset.interactable     = false;

        //And now Turn on the Machine
        //InvokeRepeating("MotorMachine", 0.5f, 0.5f);
        StartCoroutine(MotorMachine());
    }