public Menu_Lib(ControlledRun cr) : base("lib") { CR = cr; HelpText = "" + "lib [name]\n" + "Loads the specified TM definition from library, or\n" + "Displays all available definitions\n" + "\n" + "Examples:\n" + "\n" + "$ lib\n" + "BusyBeaver2 1RB 1LB, 1LA 1RH, K = 1\n" + "BusyBeaver3 1RB 1RH, 0RC 1RB, 1LC 1LA, K = 1\n" + "\n" + "$ lib bb 2\n" + "Loading BusyBeaver2\n"; Add("", s => { DefinitionLibrary.PrintContent(); }); Add("reexport", s => { DefinitionLibrary.ReexportJson(); }); Add(null, s => { var sdef = DefinitionLibrary.GetDefinitionByName(s); if (sdef != null) { Log.WriteLine("Loading " + sdef); CR._Def = DefinitionLibrary.Load(sdef); } }); }
static void Run( string sdef, bool useHistory, ulong ones, ulong shifts ) { var def = DefinitionLibrary.Load(sdef); var macro = (uint)(def.SuggestedMacroSize ?? 1); var tape = new PackedExponentTape(macro, def.Gamma, null); var hist = useHistory ? new History <PackedExponentTape> (def) : null; var tm = new MmRun(def, tape, new MacroLibrary(), null, hist); TmPrintOptions.PrintTapeSteps = true; TmPrintOptions.PrintTransitionLevel = PrintTransitionLevel.OnlyCTR; tm.Options.UseMacros = true; tm.Options.UseMacroForwarding = true; tm.Run(long.MaxValue); tm.Result.Print(); if (ones > 0) { Assert.AreEqual(true, tm.Result.Halted); Assert.AreEqual(ones, tm.Result.SymbolsOnTape); Assert.AreEqual(shifts, tm.Shifts); } else { Assert.AreEqual(false, tm.Result.Halted); } }
public ControlledRun(bool passive) { menu.CQ.PassiveMode = passive; menu.Add(new Menu_Print(this)); menu.Add(new Menu_Lib(this)); menu.Add(new Menu_Def(this)); menu.Add(new Menu_Create(this)); menu.Add(new Menu_Step(this)); menu.Add(new Menu_Run(this)); menu.Add(new Menu_Break(this)); menu.Add(new Menu_Stopwatch()); //menu.Add ("log-break", s => Log.AddBreakpoint (s)); menu.Add(new MI_Echo()); menu.Add(new MI_Pause()); var store = new FileRecordStore(); menu.Add(new MI_Record(store) { Selector = "{", EndRecordCommand = "}", }); menu.Add(new MI_Replay(menu, store) { Selector = "!", }); var mi_if = menu.Add(new MI_If()); mi_if.Conditions.Add("hist-has", Condition_HistHas); _Def = DefinitionLibrary.Load("BusyBeaver2"); }