public override void TraceEvent(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string format, params object[] args)
 {
     IndentLevel = _il;
     IndentSize  = 2;
     //var originalColor = Console.ForegroundColor;
     //Console.ForegroundColor = GetEventColor(eventType, originalColor);
     _console.WriteLine(string.Format("{2} {0} {1}: {3}", source, eventType, DateTime.Now.TimeOfDay, string.Format(format, args)));
     //Console.ForegroundColor = originalColor;
 }
Ejemplo n.º 2
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()));
            }
        }
Ejemplo n.º 3
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).
        }
    }