Ejemplo n.º 1
0
        public void TestCase01()
        {
            StringBuilder output = new StringBuilder();

            Envornment env = new Envornment(5, 5);

            env.AddMapData("#####");
            env.AddMapData("#@  #");
            env.AddMapData("#   #");
            env.AddMapData("#  $#");
            env.AddMapData("#####");
            env.buildMap();
            Robot  bender = new Robot(env);
            string move   = "";

            while (move != "DONE" && move != "LOOP")
            {
                move = bender.NextMove();
                Console.WriteLine(move);
            }

            output.AppendLine("SOUTH")
            .AppendLine("SOUTH")
            .AppendLine("EAST")
            .AppendLine("EAST");

            Assert.AreEqual(output.ToString(), bender.OuptutPath());
        }
Ejemplo n.º 2
0
        public void TestCase11()
        {
            StringBuilder output = new StringBuilder();

            Envornment env = new Envornment(15, 15);

            env.AddMapData("###############");
            env.AddMapData("#      IXXXXX #");
            env.AddMapData("#  @          #");
            env.AddMapData("#E S          #");
            env.AddMapData("#             #");
            env.AddMapData("#  I          #");
            env.AddMapData("#  B          #");
            env.AddMapData("#  B   S     W#");
            env.AddMapData("#  B   T      #");
            env.AddMapData("#             #");
            env.AddMapData("#         T   #");
            env.AddMapData("#         B   #");
            env.AddMapData("#N          W$#");
            env.AddMapData("#        XXXX #");
            env.AddMapData("###############");
            env.buildMap();
            Robot  bender = new Robot(env);
            string move   = "";

            while (move != "DONE" && move != "LOOP")
            {
                move = bender.NextMove();
                Console.WriteLine(move);
            }

            output.AppendLine("LOOP");
            Assert.AreEqual(output.ToString(), bender.OuptutPath());
        }
Ejemplo n.º 3
0
        public Robot(Envornment env)
        {
            this.env = env;

            /*priority.Enqueue("SOUTH");
             * priority.Enqueue("EAST");
             * priority.Enqueue("NORTH");
             * priority.Enqueue("WEST");*/
        }
Ejemplo n.º 4
0
        public void TestCase12()
        {
            StringBuilder output = new StringBuilder();

            Envornment env = new Envornment(15, 30);

            env.AddMapData("###############");
            env.AddMapData("#  #@#I  T$#  #");
            env.AddMapData("#  #    IB #  #");
            env.AddMapData("#  #     W #  #");
            env.AddMapData("#  #      ##  #");
            env.AddMapData("#  #B XBN# #  #");
            env.AddMapData("#  ##      #  #");
            env.AddMapData("#  #       #  #");
            env.AddMapData("#  #     W #  #");
            env.AddMapData("#  #      ##  #");
            env.AddMapData("#  #B XBN# #  #");
            env.AddMapData("#  ##      #  #");
            env.AddMapData("#  #       #  #");
            env.AddMapData("#  #     W #  #");
            env.AddMapData("#  #      ##  #");
            env.AddMapData("#  #B XBN# #  #");
            env.AddMapData("#  ##      #  #");
            env.AddMapData("#  #       #  #");
            env.AddMapData("#  #       #  #");
            env.AddMapData("#  #      ##  #");
            env.AddMapData("#  #  XBIT #  #");
            env.AddMapData("#  #########  #");
            env.AddMapData("#             #");
            env.AddMapData("# ##### ##### #");
            env.AddMapData("# #     #     #");
            env.AddMapData("# #     #  ## #");
            env.AddMapData("# #     #   # #");
            env.AddMapData("# ##### ##### #");
            env.AddMapData("#             #");
            env.AddMapData("###############");

            env.buildMap();
            Robot  bender = new Robot(env);
            string move   = "";

            while (move != "DONE" && move != "LOOP")
            {
                move = bender.NextMove();
                Console.WriteLine(move);
            }
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("EAST");
            output.AppendLine("EAST");
            output.AppendLine("EAST");
            output.AppendLine("EAST");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("WEST");
            output.AppendLine("WEST");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("EAST");
            output.AppendLine("EAST");
            output.AppendLine("EAST");
            output.AppendLine("NORTH");
            output.AppendLine("WEST");
            output.AppendLine("WEST");
            output.AppendLine("WEST");
            output.AppendLine("WEST");
            output.AppendLine("WEST");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("EAST");
            output.AppendLine("EAST");
            output.AppendLine("EAST");
            output.AppendLine("EAST");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("WEST");
            output.AppendLine("WEST");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("EAST");
            output.AppendLine("EAST");
            output.AppendLine("EAST");
            output.AppendLine("NORTH");
            output.AppendLine("WEST");
            output.AppendLine("WEST");
            output.AppendLine("WEST");
            output.AppendLine("WEST");
            output.AppendLine("WEST");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("EAST");
            output.AppendLine("EAST");
            output.AppendLine("EAST");
            output.AppendLine("EAST");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("WEST");
            output.AppendLine("WEST");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("EAST");
            output.AppendLine("EAST");
            output.AppendLine("EAST");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("WEST");
            output.AppendLine("WEST");
            output.AppendLine("WEST");
            output.AppendLine("WEST");
            output.AppendLine("WEST");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("EAST");
            output.AppendLine("EAST");
            output.AppendLine("EAST");
            output.AppendLine("EAST");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("NORTH");
            output.AppendLine("WEST");
            output.AppendLine("WEST");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("SOUTH");
            output.AppendLine("EAST");
            output.AppendLine("EAST");
            output.AppendLine("EAST");
            output.AppendLine("EAST");


            Assert.AreEqual(output.ToString(), bender.OuptutPath());
        }