Example #1
0
        static void DrawGrid(SquareGrid field) //Prints the playing field to console. FOR DEBUGGING PURPOSES ONLY; DO NOT USE WHEN TESTING
        {
            field.CopyObstaclesToWalls();
            HashSet <Location> path = field.GetShortestPath();

            for (int y = field.Width; y >= 0; y--)
            {
                for (int x = 0; x <= field.Height; x++)
                {
                    Location here = new Location(x, y);
                    if (here.Equals(field.Start))
                    {
                        Console.Write("S ");
                    }
                    else if (here.Equals(field.Goal))
                    {
                        Console.Write("G ");
                    }
                    else if (Util.ContainsLoc(field.walls, here))
                    {
                        Console.Write("# ");
                    }
                    else if (Util.ContainsLoc(path, here))
                    {
                        Console.Write($"{Util.LocIndex(path, here)} ");
                    }
                    else
                    {
                        Console.Write("* ");
                    }
                }
                Console.WriteLine();
            }
        }
Example #2
0
 static void DrawPassable(SquareGrid field) // Prints the playing field to console and highlights which points are passable. See warning above.
 {
     field.CopyObstaclesToWalls();
     for (int y = field.Width; y >= 0; y--)
     {
         for (int x = 0; x <= field.Height; x++)
         {
             Location here = new Location(x, y);
             if (field.Passable(here))
             {
                 Console.Write("$ ");
             }
             else if (Util.ContainsLoc(field.walls, here))
             {
                 Console.Write("# ");
             }
             else
             {
                 Console.Write("* ");
             }
         }
         Console.WriteLine();
     }
 }