Example #1
0
        internal static void Dump <T>(VirtualConsole console, IEnumerable <T> enumerable, IEnumerable <Column <T> > columns)
        {
            var fmt = "";
            var tit = new List <object>();
            var i   = 0;

            foreach (var column in columns)
            {
                fmt += "{" + i + "," + column.Width + "}";
                tit.Add(column.Title);
                i++;
            }

            console.WriteLine(string.Format(fmt, tit.ToArray()));
            foreach (var item in enumerable)
            {
                var l = new List <object>();
                foreach (var column in columns)
                {
                    l.Add(column.m(item));
                }
                console.WriteLine(string.Format(fmt, l.ToArray()));
            }
        }
Example #2
0
        public static async ValueTask <(int exitCode, MemoryStreamWriter stdOut, MemoryStreamWriter stdErr)> BuildAndRunTestAsync(this CliApplicationBuilder applicationBuilder,
                                                                                                                                  ITestOutputHelper testOutput,
                                                                                                                                  IReadOnlyList <string> commandLineArguments,
                                                                                                                                  IReadOnlyDictionary <string, string> environmentVariables,
                                                                                                                                  bool isInputRedirected = true,
                                                                                                                                  string?input           = null)
        {
            var(console, stdIn, stdOut, stdErr) = VirtualConsole.CreateBufferedWithInput(isInputRedirected: isInputRedirected);

            CliApplication application = applicationBuilder.UseConsole(console)
                                         .Build();

            if (input is not null)
            {
                stdIn.WriteString(input.TrimEnd('\r') + "\rexit\r");
            }

            int exitCode = await application.RunAsync(commandLineArguments, environmentVariables);

            testOutput.WriteLine("Exit Code: {0}", exitCode);
            testOutput.Print(stdOut, stdErr);

            return(exitCode, stdOut, stdErr);
        }
Example #3
0
        public async Task Default_command_is_executed_if_provided_arguments_do_not_match_any_named_command()
        {
            // Arrange
            await using var stdOut = new MemoryStream();
            var console = new VirtualConsole(output: stdOut);

            var application = new CliApplicationBuilder()
                              .AddCommand(typeof(DefaultCommand))
                              .AddCommand(typeof(ConcatCommand))
                              .AddCommand(typeof(DivideCommand))
                              .UseConsole(console)
                              .Build();

            // Act
            var exitCode = await application.RunAsync(
                Array.Empty <string>(),
                new Dictionary <string, string>());

            var stdOutData = console.Output.Encoding.GetString(stdOut.ToArray()).TrimEnd();

            // Assert
            exitCode.Should().Be(0);
            stdOutData.Should().Be("Hello world!");
        }
        public void Application_can_be_created_with_VirtualConsole_MemoryStreamWriter()
        {
            // Arrange
            IConsole console = new VirtualConsole(output: new MemoryStreamWriter(), isOutputRedirected: false,
                                                  error: new MemoryStreamWriter(Encoding.UTF8), isErrorRedirected: true);

            // Act
            var app = new CliApplicationBuilder()
                      .AddCommand <DefaultCommand>()
                      .AddCommandsFrom(typeof(DefaultCommand).Assembly)
                      .AddCommands(new[] { typeof(DefaultCommand) })
                      .AddCommandsFrom(new[] { typeof(DefaultCommand).Assembly })
                      .AddCommandsFromThisAssembly()
                      .AddDirectivesFrom(new[] { typeof(DefaultCommand).Assembly })
                      .AddDirective <DebugDirective>()
                      .AddDirective <PreviewDirective>()
                      .AddDirective <CustomInteractiveModeOnlyDirective>()
                      .AddDirective <CustomDirective>()
                      .UseConsole(console)
                      .Build();

            // Assert
            app.Should().NotBeNull();
        }
Example #5
0
        public async Task Help_text_is_printed_if_provided_arguments_contain_the_help_option()
        {
            // Arrange
            var(console, stdOut, _) = VirtualConsole.CreateBuffered();

            var application = new CliApplicationBuilder()
                              .AddCommand <DefaultCommand>()
                              .AddCommand <NamedCommand>()
                              .AddCommand <NamedSubCommand>()
                              .UseConsole(console)
                              .Build();

            // Act
            int exitCode = await application.RunAsync(new[] { "--help" });

            // Assert
            exitCode.Should().Be(ExitCodes.Success);
            stdOut.GetString().Should().ContainAll(
                "Default command description",
                "Usage"
                );

            _output.WriteLine(stdOut.GetString());
        }
Example #6
0
        public async Task Help_text_is_printed_if_no_arguments_were_provided_and_default_command_is_not_defined()
        {
            // Arrange
            await using var stdOut = new MemoryStream();
            var console = new VirtualConsole(output: stdOut);

            var application = new CliApplicationBuilder()
                              .AddCommand(typeof(ConcatCommand))
                              .AddCommand(typeof(DivideCommand))
                              .UseConsole(console)
                              .UseDescription("This will be visible in help")
                              .Build();

            // Act
            var exitCode = await application.RunAsync(
                Array.Empty <string>(),
                new Dictionary <string, string>());

            var stdOutData = console.Output.Encoding.GetString(stdOut.ToArray()).TrimEnd();

            // Assert
            exitCode.Should().Be(0);
            stdOutData.Should().Contain("This will be visible in help");
        }
Example #7
0
        static void Main(string[] args)
        {
            Console.Title          = "Simple Curses Example";
            Console.CursorVisible  = false;
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            var virtualConsole = VirtualConsole.Create();

            currentController = new HomeController();

            while (!virtualConsole.Ended)
            {
                virtualConsole.Update(currentController.CurrentView().GetRenderable());

                if (Console.KeyAvailable)
                {
                    currentController.CurrentView().HandleKeyPress(Console.ReadKey(true));
                }

                Thread.Sleep(1);
            }

            Console.ReadKey();
        }
Example #8
0
        public async Task Named_command_should_execute_even_when_default_takes_a_parameter()
        {
            // Arrange
            var(console, stdOut, _) = VirtualConsole.CreateBuffered();

            var application = new CliApplicationBuilder()
                              .AddCommand <DefaultCommandWithParameter>()
                              .AddCommand <NamedCommand>()
                              .UseConsole(console)
                              .AddDirective <DefaultDirective>()
                              .Build();

            // Act
            int exitCode = await application.RunAsync(
                new[] { "named" },
                new Dictionary <string, string>());

            // Assert
            exitCode.Should().Be(ExitCodes.Success);
            stdOut.GetString().Should().NotBeNullOrWhiteSpace();
            stdOut.GetString().Should().Contain(NamedCommand.ExpectedOutputText);

            _output.WriteLine(stdOut.GetString());
        }
Example #9
0
 protected internal abstract void Draw(VirtualConsole console);
Example #10
0
 public void FileSystem_IsAtty_ReflectsContextState()
 {
     Assert.AreEqual(MainApplicationContext.Current.IsAtty, VirtualConsole.IsAtty());
 }
Example #11
0
 private void DrawCards()
 {
     VirtualConsole.DrawBox(0, 0, VirtualConsole.instance.width - 1, 15);
     DrawIndividualCards();
 }
Example #12
0
 private void DrawLog()
 {
     VirtualConsole.DrawBox(47, 16, VirtualConsole.instance.width - 48, 7);
     DrawLogMessages();
 }
 protected ExampleBase()
 {
     Console = new VirtualConsole();
 }
Example #14
0
 protected virtual void TaskComplete()
 {
     VirtualConsole.Log("Task completed");
     running = false;
 }
        /*****************************************************************************************************
        *  Session 1 Touchpanel Events setup, adding  page flips and basic logic
        *****************************************************************************************************/

        //  This is where our Touchpanel Signal changes are processed.   Digitals, Analogs, and Serials All end up here.
        private void MyXpanel_SigChange(BasicTriList currentDevice, SigEventArgs args)
        {
            VirtualConsole.Send(String.Format("TP Sig Change  Type={0} Number={1} State={2}",
                                              args.Sig.Type, args.Sig.Number, args.Sig.BoolValue), true); // Question: What is all this? What does {0} mean?
                                                                                                          // and yes a line can be on 2 lines
                                                                                                          // Answer: Look up String.Format and read up on the specifier string.  This is like the Trace and MakeString in Simpl Plus.

            // Important to split it like this for more flexibility.   Check if it's a digital, then anything below is for digitals
            if (args.Sig.Type == eSigType.Bool) // Is it a digital?
            {
                //SESSION 1: Create a Momentary Button  (This has to be outside the check if true below)
                if (args.Sig.Number == 11)
                {
                    // This passes the button events back to the feedback
                    myXpanel.BooleanInput[11].BoolValue = args.Sig.BoolValue;  // we want both the press and release here
                }

                //SESSION 1:  Check if it is pressed
                if (args.Sig.BoolValue == true) // Look for only pressed button events
                {
                    // Page Navigation                  Session 1: Instructor put in the first page nav code The rest are student lab
                    switch (args.Sig.Number)
                    {
                    case 1:
                        myXpanel.BooleanInput[1].BoolValue  = true;     // Traditional way of setting it high then low
                        myXpanel.BooleanInput[1].BoolValue  = false;
                        myXpanel.StringInput[1].StringValue = "Front Page";
                        break;

                    case 2:
                        myXpanel.BooleanInput[2].Pulse();      // using the built in method to pulse it
                        myXpanel.StringInput[1].StringValue = "Projector";
                        break;

                    case 3:
                        myXpanel.BooleanInput[3].Pulse();
                        myXpanel.StringInput[1].StringValue = "Phone Book";
                        break;
                    }

                    /******************************************************************************************
                    *   Session 1 Lab work below (Momentary is above outside the "true" check for boolvalue)
                    ******************************************************************************************/

                    // Create a Toggle Button
                    if (args.Sig.Number == 10)
                    {
                        // We read the current feedback and use the compliment or NOT by using ! to toggle between states
                        myXpanel.BooleanInput[10].BoolValue = !myXpanel.BooleanInput[10].BoolValue; // Invert The Feedback
                    }

                    // Interlock with simple Logic. Pay attention to the join numbers used

                    /*
                     * switch(args.Sig.Number)
                     * {
                     *  case 12:
                     *      myXpanel.BooleanInput[13].BoolValue = false;
                     *      myXpanel.BooleanInput[14].BoolValue = false;
                     *      myXpanel.BooleanInput[12].BoolValue = true;
                     *      break;
                     *
                     *  case 13:
                     *      myXpanel.BooleanInput[12].BoolValue = false;
                     *      myXpanel.BooleanInput[14].BoolValue = false;
                     *      myXpanel.BooleanInput[13].BoolValue = true;
                     *      break;
                     *
                     *  case 14:
                     *      myXpanel.BooleanInput[12].BoolValue = false;
                     *      myXpanel.BooleanInput[13].BoolValue = false;
                     *      myXpanel.BooleanInput[14].BoolValue = true;
                     *      break;
                     * }
                     */

                    //Interlock leveraging the power of a method
                    if (args.Sig.Number >= 12 && args.Sig.Number <= 14)            // We only want joins 12,13,14
                    {
                        Interlock(myXpanel.BooleanInput, 12, 14, args.Sig.Number); // Look for this custom method below
                    }

                    /**********************************************************************************************
                    *  Session 2
                    **********************************************************************************************/


                    // ####     Projector Button Press Logic
                    // ####     All of this SHOULD exist in a method or even another class to make the code more manageable and organized
                    //
                    //          We are still inside the pair of IF statements for "was this a boolean(digital) and was it true(pressed)
                    //          Nested If statements can get complex and hard to navigate quickly.

                    ProjectorButtonPress(args.Sig.Number);  // Call our method below

                    //  Hidden Challenge:   Make the projector Connect when it is on the projector Page,
                    //                      and Disconnect when the user leaves the projector page.

                    // Second hidden Challenge: Do not use join numbers but instead use an enum with names
                    //                          so you can easily remap to different buttons

                    /********************************************************************************************
                    *  Session 3
                    ********************************************************************************************/

                    // File Read and Sort button management  Methods start down near line 370
                    switch (args.Sig.Number)
                    {
                    case 30:
                        LoadFile();      // Call our method to load the file and display the contents
                        break;

                    case 31:
                        SortFile();      // Call our method to sort the strings and present them
                        break;
                    }
                }
            }
        }
 public ColorConsoleTraceListener(int identLevel)
 {
     _console = new VirtualConsole(22, Console.WindowHeight);
     _il      = identLevel;
 }
Example #17
0
 public void ColorBlock(int x, int y, float r, float g, float b)
 {
     VirtualConsole.ColorBlock(x - instance.posX + VirtualConsole.instance.width / 2, y - instance.posY + ((VirtualConsole.instance.height - 15) / 2) + 15, r, g, b);
 }
Example #18
0
 // Start is called before the first frame update
 void Start()
 {
     instance         = this;
     backgroundBlocks = new SpriteRenderer[width, height];
     letters          = new TextMesh[width, height];
     for (int x = 0; x < width; x++)
     {
         for (int y = 0; y < height; y++)
         {
             float xPos = (xOffset * 2 * (x + 1) / (width + 1)) - xOffset;
             float yPos = (yOffset * 2 * (y + 1) / (height + 1)) - yOffset;
             var   go   = Instantiate(bgPrefab);
             go.GetComponent <MapBlockMouseControls>().x = x;
             go.GetComponent <MapBlockMouseControls>().y = y;
             go.transform.position = new Vector3(xPos, yPos, -0.25f);
             go.transform.SetParent(letterCollection.transform);
             backgroundBlocks[x, y] = go.GetComponent <SpriteRenderer>();
             if (testMode)
             {
                 float randomR = Random.Range(0f, 1f);
                 float randomG = Random.Range(0f, 1f);
                 float randomB = Random.Range(0f, 1f);
                 backgroundBlocks[x, y].color = new Color(randomR, randomG, randomB);
             }
             else
             {
                 backgroundBlocks[x, y].color = new Color(0, 0, 0);
             }
             var go2 = Instantiate(textPrefab);
             go2.transform.position = new Vector3(xPos, yPos, -0.25f);
             go2.transform.SetParent(letterCollection.transform);
             letters[x, y] = go2.GetComponent <TextMesh>();
             if (testMode)
             {
                 int randomLetter = Random.Range(0, 52);
                 if (randomLetter < 26)
                 {
                     letters[x, y].text = ((char)('a' + randomLetter)).ToString();
                 }
                 else
                 {
                     letters[x, y].text = ((char)('A' + randomLetter - 26)).ToString();
                 }
             }
             else
             {
                 letters[x, y].text = " ";
             }
             if (testMode)
             {
                 float randomR = Random.Range(0f, 1f);
                 float randomG = Random.Range(0f, 1f);
                 float randomB = Random.Range(0f, 1f);
                 letters[x, y].color = new Color(randomR, randomG, randomB);
             }
             else
             {
                 letters[x, y].color = new Color(1, 1, 1);
             }
         }
     }
 }
Example #19
0
    protected void GenerateOutputs(float[] variableValues)
    {
        //VirtualConsole.Log ("Executing code...");
        string codeToRun = (inTestMode) ? testCodeText : code;

        compiler = new VirtualCompiler(codeToRun);

        compiler.availableFuncsWthoutReturnV.Add("testMethod", testMethod);
        compiler.AddOutputFunction("testMethod2");

        for (int i = 0; i < taskInfo.outputs.Length; i++)
        {
            compiler.AddOutputFunction(taskInfo.outputs[i].name);
        }
        for (int i = 0; i < taskInfo.constants.Length; i++)
        {
            compiler.AddInput(taskInfo.constants[i].name, taskInfo.constants[i].value);
        }
        for (int i = 0; i < variableValues.Length; i++)
        {
            compiler.AddInput(taskInfo.variables[i], variableValues[i]);
        }

        //VirtualConsole.LogInputs (inputNames, inputValues);

        List <VirtualFunction> outputs = compiler.Run();

        if (outputs.Count > 0)
        {
            foreach (VirtualFunction vFunc in outputs)
            {
                //object[] mParams = new object[vFunc.values.Count];
                //Array.Copy(vFunc.values.ToArray(), mParams, vFunc.values.Count);
                if (vFunc.delFunc != null)
                {
                    vFunc.delFunc.Invoke(this, null);
                }


                if (vFunc.FunctionWithoutParam != null && vFunc.FunctionWithParam != null)
                {
                    if (vFunc.values.Count <= 1)
                    {
                        vFunc.FunctionWithoutParam.Invoke();
                    }
                    else
                    {
                        string vFuncReturnValue = vFunc.FunctionWithParam.Invoke(vFunc.values[0].ToString());
                    }
                }
            }

            float val = 0;
            if (outputs[0].values.Count > 0 && outputs[0].values[0] is float)
            {
                val = (float)outputs[0].values[0];
            }
            var func = new Function()
            {
                name = outputs[0].name, value = val
            };
            outputQueue.Enqueue(func);

            VirtualConsole.LogOutput(func.name, func.value);
        }
    }
Example #20
0
 public void StartTask(string code)
 {
     this.code = code;
     StartCoroutine(StartTaskRoutine());
     VirtualConsole.Clear();
 }
Example #21
0
        public int Execute(string argString)
        {
            using (MainApplicationContext.AcquireCurrentThread())
            {
                var envp = VirtualEnvironment.GetEnvironmentVariables();
                var args = CommandLine.PreprocessSingleQuotes(argString);

                int status = 1;

                // The very first thing we do is handle some very special command-line
                // options, since they affect how the environment is setup:
                //
                //   --verify            ; turns on memory tracing
                //   --verbose           ; turns on logging
                //   --debug CATEGORY    ; turns on debug logging
                //   --trace LEVEL       ; turns on trace logging
                //   --memory            ; turns on memory usage tracing
                //   --init-file         ; directs ledger to use a different init file
                GlobalScope.HandleDebugOptions(args);
                // initialize_memory_tracing - [DM] #memory-tracing
                Logger.Current.Info(() => LedgerStarting);
                // ::textdomain("ledger"); - [DM] #localization
                GlobalScope globalScope = null;
                try
                {
                    // Create the session object, which maintains nearly all state relating to
                    // this invocation of Ledger; and register all known journal parsers.
                    globalScope = new GlobalScope(envp);
                    globalScope.Session.FlushOnNextDataFile = true;

                    // Look for options and a command verb in the command-line arguments
                    BindScope boundScope = new BindScope(globalScope, globalScope.Report);
                    args = globalScope.ReadCommandArguments(boundScope, args);

                    if (globalScope.ScriptHandler.Handled)
                    {
                        // Ledger is being invoked as a script command interpreter
                        globalScope.Session.ReadJournalFiles();

                        status = 0;

                        using (StreamReader sr = FileSystem.GetStreamReader(globalScope.ScriptHandler.Str()))
                        {
                            while (status == 0 && !sr.EndOfStream)
                            {
                                string line = sr.ReadLine().Trim();
                                if (!line.StartsWith("#"))
                                {
                                    status = globalScope.ExecuteCommandWrapper(StringExtensions.SplitArguments(line), true);
                                }
                            }
                        }
                    }
                    else if (args.Any())
                    {
                        // User has invoke a verb at the interactive command-line
                        status = globalScope.ExecuteCommandWrapper(args, false);
                    }
                    else
                    {
                        // Commence the REPL by displaying the current Ledger version
                        VirtualConsole.Output.WriteLine(globalScope.ShowVersionInfo());

                        globalScope.Session.ReadJournalFiles();

                        bool exitLoop = false;

                        VirtualConsole.ReadLineName = "Ledger";

                        string p;
                        while ((p = VirtualConsole.ReadLine(globalScope.PromptString())) != null)
                        {
                            string expansion = null;
                            int    result    = VirtualConsole.HistoryExpand(p.Trim(), ref expansion);

                            if (result < 0 || result == 2)
                            {
                                throw new LogicError(String.Format(LogicError.ErrorMessageFailedToExpandHistoryReference, p));
                            }
                            else if (expansion != null)
                            {
                                VirtualConsole.AddHistory(expansion);
                            }

                            CancellationManager.CheckForSignal();

                            if (!String.IsNullOrWhiteSpace(p) && p != "#")
                            {
                                if (String.Compare(p, "quit", true) == 0)
                                {
                                    exitLoop = true;
                                }
                                else
                                {
                                    globalScope.ExecuteCommandWrapper(StringExtensions.SplitArguments(p), true);
                                }
                            }

                            if (exitLoop)
                            {
                                break;
                            }
                        }
                        status = 0;    // report success
                    }
                }
                catch (CountError errors)
                {
                    // used for a "quick" exit, and is used only if help text (such as
                    // --help) was displayed
                    status = errors.Count;
                }
                catch (Exception err)
                {
                    if (globalScope != null)
                    {
                        globalScope.ReportError(err);
                    }
                    else
                    {
                        VirtualConsole.Error.WriteLine(String.Format(ExceptionDuringInitialization, err.Message));
                    }
                }

                if (globalScope != null)
                {
                    globalScope.QuickClose();
                    globalScope.Dispose();              // {DM] It is the most appropriate place to call Dispose for the global scope.
                }
                Logger.Current.Info(() => LedgerEnded); // let global_scope leak!

                // Return the final status to the operating system, either 1 for error or 0
                // for a successful completion.
                return(status);
            }
        }
Example #22
0
 protected ExampleBase()
 {
     Console = new VirtualConsole();
 }
        // This is how you create a Virtual Console Command Method: This is a freebie that is not a part of the Masters Session
        private string TestFunc(string s)
        {
            VirtualConsole.Send(string.Format("Test Command line Called and  after it was sent {0}", s));

            return("");  //return an empty string.
        }
Example #24
0
 protected virtual void TestFailed()
 {
     running = false;
     VirtualConsole.LogTaskFailed();
 }
Example #25
0
        public static void Main(string[] args)
        {
            var idbuf = new byte[16];

            new Random().NextBytes(idbuf);

            var id         = new BotIdentifier(idbuf);
            var listenPort = 33333;
            var peers      = new List <PeerInfo>();

            foreach (var arg in args)
            {
                var v = arg.Substring(1);
                switch (arg[0])
                {
                case 'p':
                    int.TryParse(v, out listenPort);
                    break;

                case 'c':
                    foreach (var peerInfo in v.Split(new[] { ';' }))
                    {
                        peers.Add(PeerInfo.Parse(peerInfo));
                    }
                    break;

                case 'i':
                    id = BotIdentifier.Parse(v);
                    break;
                }
            }

            agent = new Agent(listenPort, id);
            agent.Run();
            agent.Bootstrap(peers);

            var console = new VirtualConsole(0, 20);

            ConsolesManager.Instance.SetFocus(console);
            Console.SetCursorPosition(0, 21);
            Console.Write(new string('=', Console.BufferWidth));
            var repl = new CommandLineReader(console);

            var suite = new CommandSet("vicha", null, console, console)
            {
                "usage: COMMAND [OPTIONS]+.",
                "Available commands are:",
                "",
                // { "v:", "verbosity", (int? v) => Verbosity = v.HasValue ? v.Value : Verbosity+1 },
                // Commands may also be specified
                new DDoSStartCommand(agent, repl),
                new DDoSStopCommand(agent, repl),
                new ExecuteCommand(agent, repl),
                new BackdoorCommand(agent, repl),
                new AddNodeCommand(agent, repl),
                new DebugCommand(agent, repl),
                new Command("clear", "Clear the screen")
                {
                    Run = x => repl.Clear()
                },
                new Command("exit", "Finished the control seesion and close the agent")
                {
                    Run = x => Environment.Exit(0)
                }
            };

            repl.NewCommand += (sender, eventArgs) =>
                               suite.Run(eventArgs.Command.Split(new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
            repl.Run();
        }
Example #26
0
    static void Main(string[] args)
    {
        string[] inputs;
        inputs = VirtualConsole.ReadLine().Split(' ');
        int R = int.Parse(inputs[0]); // number of rows.
        int C = int.Parse(inputs[1]); // number of columns.
        int A = int.Parse(inputs[2]); // number of rounds between the time the alarm countdown is activated and the time the alarm goes off.

        RoundEndCounter = A;


        MapNode searchNode;
        string  dir = "";

        // game loop
        while (true)
        {
            inputs = VirtualConsole.ReadLine().Split(' ');
            int pY = int.Parse(inputs[0]); // row where Kirk is located.
            int pX = int.Parse(inputs[1]); // column where Kirk is located.

            MapNode.resetNodes();
            for (int y = 0; y < R; y++)
            {
                string ROW = VirtualConsole.ReadLine(); // C of the characters in '#.TC?' (i.e. one line of the ASCII maze).
                for (int x = 0; x < C; x++)
                {
                    new MapNode(x, y, ROW[x].ToString());
                }
            }
            MapNode.connectNodes();

            var startingNode = MapNode.MapNodes.Find(item => item.value == "T");
            var playerNode   = MapNode.MapNodes.Find(item => item.x == pX && item.y == pY);

            if (playerNode.value == Solution.Goal)//we standing on the goal, alarm must of gone off, new goal to get back
            {
                Solution.Goal = "T";
            }

            var goalNodeConnected = MapNode.checkIfGoalConnected(startingNode);

            if (goalNodeConnected == null) //goal is not connected so we keep exploring map
            {
                var closestNode = MapNode.findClosestHiddenNode(playerNode);
                MapNode.resetVistedNodes();
                searchNode = closestNode;
            }
            else
            {
                searchNode = goalNodeConnected;
            }

            var nextConnectedNodeInPath = playerNode.FindNextNodeToPath(searchNode);
            MapNode.resetVistedNodes();
            dir = playerNode.DirectionOfConnectedNode(nextConnectedNodeInPath);


            VirtualConsole.WriteLine(dir); // Kirk's next move (UP DOWN LEFT or RIGHT).
        }
    }