public void StartChecking(string input, Turing turing) { turing.StopChechingInput(); if (_checking == null) { _checking = StartCoroutine(DoCheck(input, turing)); } }
static void Main(string[] args) { Turing.IsWordBinary("0001011100**"); Turing.IsWordBinary("1111011a011b100**"); Turing.ShowDistinctSymbolsAmount("**abbbaaa**"); Turing.ShowDistinctSymbolsAmount("**bbb**"); Turing.ShowDistinctSymbolsAmount("**bbabcc**"); Console.ReadLine(); }
private IEnumerator DoCheck(string input, Turing turing) { bool result = false; bool isHalt = false; if (!turing.DeterministicCheck()) { isHalt = true; } DState current = turing.GetStartState(); StringBuilder tape = new StringBuilder(input); int head = 0; while (!isHalt) { if (head >= tape.Length || head < 0) { if (head < 0) { head = 0; } tape.Insert(head, '□'); } var next = turing.GetNextState(current, tape[head]); if (next == null) { isHalt = true; result = current.IsFinal(); } else { var tagFormat = current.GetTags(tape[head])[0]; tape[head] = tagFormat.machine; head += tagFormat.machineCommand.ToLower().Contains("r") ? +1 : -1; current = next; } yield return(null); } turing.IsAnswerReady = true; turing.Result = result; _checking = null; }