Ejemplo n.º 1
0
        // testing purposes
        static void Test()
        {
            var dto  = new DTO.EnMapData();
            var path = Path.Combine(Directory.GetCurrentDirectory(), "Maps\\classic.map.txt");

            dto.Rows = File.ReadAllLines(path);

            Console.WriteLine("Done");

            var map = new Map(dto, new List <EnPoint>(), new EnPoint());
            //var client = new TacManClient(ConfigurationManager.AppSettings["connection"]);
        }
Ejemplo n.º 2
0
        private static void TestGraph()
        {
            var dto  = new DTO.EnMapData();
            var path = Path.Combine(Directory.GetCurrentDirectory(), "Maps\\map5.txt");

            dto.Rows   = File.ReadAllLines(path);
            dto.Width  = dto.Rows[0].Length;
            dto.Height = dto.Rows.Count();

            //var ghosts = new EnPoint[] { new EnPoint() { Row = 3, Col = 5 } };
            var ghosts = new EnPoint[] { };
            var graph  = new Graph.MapGraph(dto, new EnPoint()
            {
                Row = 1, Col = 10
            }, ghosts);

            // Find some/any cookie
            var cookieLocation = graph.Vertices.FirstOrDefault(c => c.HasCookie == true);

            Console.WriteLine($"Cookie location: {cookieLocation.X}; {cookieLocation.Y}");

            // Set tacman location to arbitrary location
            var tacmanLocation = graph.Vertices.FirstOrDefault(v => v.HasTacman);

            Console.WriteLine($"Tacman location: {tacmanLocation.X}; {tacmanLocation.Y}");

            // Find shortest path between tacman and cookie
            var shortestPath = graph.GetShortestPath(tacmanLocation, cookieLocation);

            // Print graph
            PrintGraph(dto, graph);

            Console.WriteLine("");
            Console.WriteLine("=========================================");
            Console.WriteLine("");

            //Print with shortest path
            PrintGraph(dto, graph, shortestPath);

            Console.ReadKey();
        }