예제 #1
0
        public void SimpleTest() //?
        {
            Game.Map = Map_creator.CreateMap(@"
WWWWWWWWWWWWWWWW
W              W
W    S         W
W              W
W           P  W
WWWWWWWWWWWWWWWW", "\n");
            Game.PackMansPosition = new Point(5, 2);
            Game.PointsAtLevel    = 7;
            Game.PointsEated      = 2;
            Game.CurrentBehavior  = MonsterBehavior.chase;

            var pinkyPos = new Point(12, 4);
            var pinky    = new Blinky(Directions.Right);

            var result = new List <Point>()
            {
                pinkyPos
            };

            for (var i = 0; i < 10; i++)
            {
                var move = pinky.Act(pinkyPos.X, pinkyPos.Y);
                pinkyPos.X += move.DeltaX;
                pinkyPos.Y += move.DeltaY;
                result.Add(pinkyPos);
            }
            Assert.IsNotEmpty(result);
            Assert.AreEqual(new Point(4, 2), pinkyPos);
        }
예제 #2
0
        public void TestCurrentDirectionGame()
        {
            Game.Map = Map_creator.CreateMap(@"
WWWWWW
WS   W
W    W
W    W
W    W
WWWWWW", "\n");
            Game.PackMansPosition = new Point(1, 1);
            Game.PacMansDirection = Directions.Right;
            Game.PointsAtLevel    = 7;
            Game.PointsEated      = 2;
            var PacmanPos = new Point(1, 1);
            var pacman    = new PackMan(Directions.Right);

            for (var i = 0; i < 3; i++)
            {
                var a = pacman.Act(PacmanPos.X, PacmanPos.Y);
                PacmanPos.X += a.DeltaX;
                PacmanPos.Y += a.DeltaY;
            }
            pacman.CurrentDirection = Directions.Down;
            for (var i = 0; i < 3; i++)
            {
                var a = pacman.Act(PacmanPos.X, PacmanPos.Y);
                PacmanPos.X += a.DeltaX;
                PacmanPos.Y += a.DeltaY;
            }
            Assert.AreEqual(new Point(4, 4), PacmanPos);
            Assert.AreEqual(Game.PacMansDirection, Directions.Down);
        }
예제 #3
0
        public void TestFindGoal1()
        {
            Game.Map = Map_creator.CreateMap(@"
WWWWWWWWWWWWWWWW
WS             W
W              W
W              W
W              W
WWWWWWWWWWWWWWWW", "\n");
            Game.PackMansPosition = new Point(1, 1);
            Assert.AreEqual(Pinky.GetGoal(), new Point(1, 1));
        }
예제 #4
0
        public void TestFindGoal()
        {
            Game.Map = Map_creator.CreateMap(@"
WWWWWWWWWWWWWWWW
W              W
W    S         W
W              W
W             KW
WWWWWWWWWWWWWWWW", "\r\n");
            Game.PackMansPosition = new Point(5, 2);
            Assert.AreEqual(Klaid.GetGoal(14, 4), Game.PackMansPosition);
            Assert.AreEqual(Klaid.GetGoal(5, 3), new Point(0, Game.MapHeight - 1));
        }
예제 #5
0
        public void SimpleTest()
        {
            Game.Map = Map_creator.CreateMap(@"
WWWWWWWWWWWWWWWW
W              W
W    S         W
W              W
W           K  W
WWWWWWWWWWWWWWWW", "\r\n");
            Game.PackMansPosition = new Point(5, 2);
            Game.PointsAtLevel    = 7;
            Game.PointsEated      = 2;
            Game.CurrentBehavior  = MonsterBehavior.chase;

            var klaidPos = new Point(12, 4);
            var klaid    = new Klaid(Directions.Right);

            var result = new List <Point>()
            {
                klaidPos
            };

            for (var i = 0; i < 10; i++)
            {
                var move = klaid.Act(klaidPos.X, klaidPos.Y);
                klaidPos.X += move.DeltaX;
                klaidPos.Y += move.DeltaY;
                result.Add(klaidPos);
            }
            Assert.IsNotEmpty(result);
            Assert.AreEqual(new Point(3, 3), klaidPos);
            for (var i = 0; i < 2; i++)
            {
                var move = klaid.Act(klaidPos.X, klaidPos.Y);
                klaidPos.X += move.DeltaX;
                klaidPos.Y += move.DeltaY;
                result.Add(klaidPos);
            }
            Assert.AreEqual(new Point(2, 4), klaidPos);
            for (var i = 0; i < 2; i++)
            {
                var move = klaid.Act(klaidPos.X, klaidPos.Y);
                klaidPos.X += move.DeltaX;
                klaidPos.Y += move.DeltaY;
                result.Add(klaidPos);
            }
            Assert.AreEqual(new Point(1, 3), klaidPos);
        }
예제 #6
0
        public void TestChaseMode()
        {
            Game.Map = Map_creator.CreateMap("    \r\n    \r\n    \r\n    \r\nB   ", "\r\n");
            Game.PackMansPosition = new Point(3, 0);
            Game.CurrentBehavior  = MonsterBehavior.chase;
            Game.PointsAtLevel    = 7;
            Game.PointsEated      = 2;
            var blinkyPos = new Point(0, 3);
            var blinky    = new Blinky(Directions.Right);

            for (var i = 0; i < 6; i++)
            {
                var a = blinky.Act(blinkyPos.X, blinkyPos.Y);
                blinkyPos.X += a.DeltaX;
                blinkyPos.Y += a.DeltaY;
            }
            Assert.AreEqual(Game.PackMansPosition, blinkyPos);
        }
예제 #7
0
        public void TestFrightenedMode()
        {
            Game.Map = Map_creator.CreateMap("    \r\n    \r\n    \r\nB   ", "\r\n");
            Game.PackMansPosition = new Point(3, 0);
            Game.CurrentBehavior  = MonsterBehavior.frightened;
            var blinkyPos = new Point(0, 3);
            var blinky    = new Blinky(Directions.Right);
            var res       = new List <CreatureCommand>();

            for (var i = 0; i < 6; i++)
            {
                var a = blinky.Act(blinkyPos.X, blinkyPos.Y);
                blinkyPos.X += a.DeltaX;
                blinkyPos.Y += a.DeltaY;
                res.Add(a);
            }
            Assert.IsNotEmpty(res);
            Assert.AreEqual(res.Count, 6);
        }
예제 #8
0
        public void TestScatterMode()
        {
            var game = new Game();

            Game.Map = Map_creator.CreateMap("WWWWWW\r\nW    W\r\nW    W\r\nW    W\r\nWB   W\r\nWWWWWW", "\r\n");
            Game.PackMansPosition = new Point(4, 1);
            Game.CurrentBehavior  = MonsterBehavior.scatter;
            Game.PointsAtLevel    = 7;
            Game.PointsEated      = 2;
            var blinkyPos = new Point(1, 4);
            var blinky    = new Blinky(Directions.Right);

            for (var i = 0; i < 6; i++)
            {
                var a = blinky.Act(blinkyPos.X, blinkyPos.Y);
                blinkyPos.X += a.DeltaX;
                blinkyPos.Y += a.DeltaY;
            }
            Assert.AreEqual(Game.PackMansPosition, blinkyPos);
        }
예제 #9
0
        public void SimpleTest()
        {
            Game.Map = Map_creator.CreateMap(TestGhost.Map, "\r\n");
            var blinky    = new Blinky(Directions.Left);
            var blinkyPos = new Point(14, 10);

            Game.PackMansPosition = new Point(14, 27);
            var result = new List <Point>()
            {
                blinkyPos
            };

            while (blinkyPos != Game.PackMansPosition)
            {
                var move = blinky.Act(blinkyPos.X, blinkyPos.Y);
                blinkyPos.X += move.DeltaX;
                blinkyPos.Y += move.DeltaY;
                result.Add(blinkyPos);
            }
            Assert.IsNotEmpty(result);
            Assert.AreEqual(46, result.Count);
        }
예제 #10
0
        public void TestScatterMode()
        {
            Game.Map             = Map_creator.CreateMap(@"
WWWWWW
W   KW
W    W
W    W
W    W
WWWWWW", "\r\n");
            Game.CurrentBehavior = MonsterBehavior.scatter;
            Game.PointsAtLevel   = 7;
            Game.PointsEated     = 2;
            var klaidPos = new Point(4, 1);
            var klaid    = new Klaid(Directions.Left);

            for (var i = 0; i < 6; i++)
            {
                var a = klaid.Act(klaidPos.X, klaidPos.Y);
                klaidPos.X += a.DeltaX;
                klaidPos.Y += a.DeltaY;
            }
            Assert.AreEqual(new Point(1, Game.MapHeight - 2), klaidPos);
        }
예제 #11
0
        public void TestSteeps()
        {
            Game.Map = Map_creator.CreateMap(@"
WWWWW
WS  W
W   W
WP  W
WWWWW", "\n");
            Game.PackMansPosition = new Point(1, 1);
            Game.PointsAtLevel    = 7;
            Game.PointsEated      = 2;
            Game.CurrentBehavior  = MonsterBehavior.chase;

            var pinkyPos = new Point(1, 3);
            var pinky    = new Blinky(Directions.Right);

            for (var i = 0; i < 2; i++)
            {
                var a = pinky.Act(pinkyPos.X, pinkyPos.Y);
                pinkyPos.X += a.DeltaX;
                pinkyPos.Y += a.DeltaY;
            }
            Assert.AreEqual(Game.PackMansPosition, pinkyPos);
        }
예제 #12
0
        public void TestScatterMode()
        {
            Game.Map = Map_creator.CreateMap(@"
WWWWWW
W    W
W    W
W    W
W   PW
WWWWWW", "\n");
            Game.PackMansPosition = new Point(4, 1);
            Game.CurrentBehavior  = MonsterBehavior.scatter;
            Game.PointsAtLevel    = 7;
            Game.PointsEated      = 2;
            var pinkyPos = new Point(4, 1);
            var pinky    = new Pinky(Directions.Left);

            for (var i = 0; i < 7; i++)
            {
                var a = pinky.Act(pinkyPos.X, pinkyPos.Y);
                pinkyPos.X += a.DeltaX;
                pinkyPos.Y += a.DeltaY;
            }
            Assert.AreEqual(new Point(1, 1), pinkyPos);
        }
예제 #13
0
        public void TestSteeps()
        {
            Game.Map = Map_creator.CreateMap(@"
WWWWW
WS KW
W   W
W   W
WWWWW", "\r\n");
            Game.PackMansPosition = new Point(1, 1);
            Game.PointsAtLevel    = 7;
            Game.PointsEated      = 2;
            Game.CurrentBehavior  = MonsterBehavior.chase;

            var klaidPos = new Point(3, 1);
            var klaid    = new Klaid(Directions.Left);

            for (var i = 0; i < 4; i++)
            {
                var a = klaid.Act(klaidPos.X, klaidPos.Y);
                klaidPos.X += a.DeltaX;
                klaidPos.Y += a.DeltaY;
            }
            Assert.AreEqual(new Point(1, 3), klaidPos);
        }
예제 #14
0
 public static void CreateMap(string MapPacman)
 {
     teleports = new Teleport();
     Map       = Map_creator.CreateMap(MapPacman, "\r\n");
     GameLives = 3;
 }