public static void UpdateDiagram(IList<StateFunction> list, StateFunction fn) { if (highlightedFn != null) { string mOld = string.Empty; foreach (var mov in highlightedFn.Movement) { mOld += mov; } var sOld = string.Format("({0}, {1}) = ({2}, {3}, {4})", highlightedFn.CurrentState, highlightedFn.Read, highlightedFn.NewState, highlightedFn.Write, mOld); //TODO Tools.Write(Console.WindowWidth - 50, list.IndexOf(highlightedFn), sOld); } ConsoleColor f = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Yellow; string m = string.Empty; foreach (var mov in fn.Movement) { m += mov; } var s = string.Format("({0}, {1}) = ({2}, {3}, {4})", fn.CurrentState, fn.Read, fn.NewState, fn.Write, m); Tools.Write(Console.WindowWidth - 50, list.IndexOf(fn), s); highlightedFn = fn; Console.ForegroundColor = f; }
public override bool MakeStep() { StateFunction fn = GetPossibleFunction(); if (fn == null) { Tools.WriteSteps(Steps, TapeAmount); Tools.WriteState(CurrentState, TapeAmount); return(false); } CurrentState = fn.NewState; fn.Used = true; for (int i = 0; i < TapeAmount; i++) { Tapes[i].Write(fn.Write[i]); Tapes[i].Move(fn.Movement[i]); } ++Steps; return(true); }
public void Move(StateFunction.Direction d) { switch (d) { case StateFunction.Direction.L: if (_current.Previous == null) { _list.AddBefore(_current, new LinkedListNode<char>('B')); _listIndex++; } _current = _current.Previous; _listIndex--; break; case StateFunction.Direction.R: if (_current.Next == null) { _list.AddAfter(_current, new LinkedListNode<char>('B')); } _current = _current.Next; _listIndex++; break; } }