Example #1
0
        public void GetPlayerMatrix_ShouldBeAbleToMakeAMatrix_WhenCalledUpon()
        {
            map = new ListMap(11);
            map.TakeHex(PlayerType.Red, 1, 1);
            map.TakeHex(PlayerType.Red, 1, 2);
            map.TakeHex(PlayerType.Red, 1, 3);
            map.TakeHex(PlayerType.Red, 1, 4);
            map.TakeHex(PlayerType.Red, 1, 5);

            map.TakeHex(PlayerType.Blue, 1, 7);
            map.TakeHex(PlayerType.Blue, 1, 8);
            map.TakeHex(PlayerType.Blue, 1, 9);
            map.TakeHex(PlayerType.Blue, 1, 10);

            var blueMap = new ListMap(map.Size);

            blueMap.InjectFrom <CloneInjection>(map);

            var matrixForPlayer1 = blueMap.GetPlayerMatrix(PlayerType.Blue);

            TestContext.WriteLine("Player 1 matrix");
            TestContext.WriteLine(matrixForPlayer1.ToString());

            var matrixForPlayer2 = blueMap.GetPlayerMatrix(PlayerType.Red);

            TestContext.WriteLine("Player 2 matrix");
            TestContext.WriteLine(matrixForPlayer2.ToString());

            Assert.AreEqual(matrixForPlayer1, blueMap.HexAt(1, 7).Attached);
        }
Example #2
0
 public void TakeHex_ShouldChangeTheOwnerProperty_WhenHexIsUnowned()
 {
     map = new ListMap(11);
     map.TakeHex(PlayerType.Blue, 1, 3);
     Assert.AreEqual(PlayerType.Blue, map.HexAt(1, 3).Owner);
     Assert.AreEqual(120, map.Board.Count(x => x.Owner == PlayerType.White));
 }
Example #3
0
        public void TakeHex_ShouldFail_IfHexAskedForIsOutOfBounds()
        {
            map = new ListMap(11);
            var didItWork = map.TakeHex(PlayerType.Blue, -13, 5000);

            Assert.AreEqual(false, didItWork);
            Assert.AreEqual(121, map.Board.Count(x => x.Owner == PlayerType.White));
        }
        public void Inquisitor_ShouldWork()
        {
            var map    = new ListMap(6);
            var player = new ListPlayer(1, map.Size, new Config());

            map.TakeHex(PlayerType.Red, 3, 3);
            var inquisitor = new Inquisitor();
            var testMap    = new ListMap(map.Size);

            testMap.InjectFrom(map);
            inquisitor.StartInquisition(testMap, player);


//            Assert.AreEqual(1, 2);
        }
        public void GetPathForPlayerTest()
        {
            var map       = new ListMap(11);
            var player    = new ListPlayer(1, 11, new Config());
            var redPlayer = new ListPlayer(2, 11, new Config());

            var pathfinder = new Pathfinder(map, player.Me);



            //map.TakeHex(PlayerType.Red, 5, 1);
            pathfinder = new Pathfinder(map, player.Me);
            var path = pathfinder.GetPathForPlayer();

            //Assert.AreEqual(11, path.Count);


            map.TakeHex(PlayerType.Red, 3, 2);
            map.TakeHex(PlayerType.Red, 2, 2);
            map.TakeHex(PlayerType.Red, 2, 0);
            map.TakeHex(PlayerType.Red, 2, 1);
            map.TakeHex(PlayerType.Red, 2, 3);
            map.TakeHex(PlayerType.Red, 2, 4);
            map.TakeHex(PlayerType.Red, 2, 5);

            var blueMap = new ListMap(map.Size);

            blueMap.InjectFrom <CloneInjection>(map);

            pathfinder = new Pathfinder(map, redPlayer.Me);
            path       = pathfinder.GetPathForPlayer();
            TestContext.WriteLine(pathfinder.GetLog());
            path.ForEach(x => map.TakeHex(PlayerType.Red, x.Row, x.Column));
            TestContext.WriteLine(map.GetMapMatrix().ToString().Replace('0', '_'));

            //pathfinder = new Pathfinder(blueMap, player, true);
            //path = pathfinder.GetPathForPlayer();
            //path.ForEach(x => blueMap.TakeHex(PlayerType.Blue, x.Row, x.Column));
            //TestContext.WriteLine(pathfinder.GetLog());

            //TestContext.WriteLine(blueMap.GetMapMatrix().ToString().Replace('0', '_'));

            //Assert.AreEqual(11, path.Count);
        }
Example #6
0
        public void ScoreBoard_ShouldWork()
        {
            var map = new ListMap(11);

            var bluePlayer = new ListPlayer(1, map.Size, new Config());
            var redPlayer  = new ListPlayer(2, map.Size, new Config());

            map.TakeHex(PlayerType.Red, 1, 1);
            map.TakeHex(PlayerType.Red, 1, 2);
            map.TakeHex(PlayerType.Red, 1, 3);
            map.TakeHex(PlayerType.Red, 1, 4);
            map.TakeHex(PlayerType.Red, 1, 5);

            map.TakeHex(PlayerType.Blue, 1, 7);
            map.TakeHex(PlayerType.Blue, 1, 8);
            map.TakeHex(PlayerType.Blue, 1, 9);
            map.TakeHex(PlayerType.Blue, 1, 10);

            var matrixForPlayer1 = map.GetPlayerMatrix(PlayerType.Blue);

            TestContext.WriteLine("Player 1 matrix");
            TestContext.WriteLine(matrixForPlayer1.ToString());

            var matrixForPlayer2 = map.GetPlayerMatrix(PlayerType.Red);

            TestContext.WriteLine("Player 2 matrix");
            TestContext.WriteLine(matrixForPlayer2.ToString());

            var appraiser = new Appraiser();

            var player1score = appraiser.ScoreFromBoard(map, bluePlayer);
            var player2score = appraiser.ScoreFromBoard(map, redPlayer);

            Assert.AreNotEqual(player1score, player2score);

            Assert.AreEqual(4, player2score);
            Assert.AreEqual(-4, player1score);
        }
Example #7
0
        public void ValueInjecter_ShouldProperlyClone_AFullMap()
        {
            map = new ListMap(11);
            map.TakeHex(PlayerType.Red, 1, 1);
            map.TakeHex(PlayerType.Red, 1, 2);
            map.TakeHex(PlayerType.Red, 1, 3);
            map.TakeHex(PlayerType.Red, 1, 4);
            map.TakeHex(PlayerType.Red, 1, 5);

            map.TakeHex(PlayerType.Blue, 1, 7);
            map.TakeHex(PlayerType.Blue, 1, 8);
            map.TakeHex(PlayerType.Blue, 1, 9);
            map.TakeHex(PlayerType.Blue, 1, 10);

            var newMap = new ListMap(map.Size);

            newMap.InjectFrom <CloneInjection>(map);
            Assert.AreEqual(5, newMap.Board.Count(x => x.Owner == PlayerType.Red));
            Assert.AreEqual(4, newMap.Board.Count(x => x.Owner == PlayerType.Blue));
            Assert.AreEqual(map.HexAt(1, 1).ToTuple(), newMap.HexAt(1, 1).ToTuple());
            Assert.AreEqual(map.HexAt(1, 1).Attached, map.HexAt(1, 1).Attached);
            newMap.TakeHex(PlayerType.Blue, 1, 6);
            Assert.AreNotEqual(map.Board.Count(x => x.Owner == PlayerType.Blue), newMap.Board.Count(x => x.Owner == PlayerType.Blue));
        }
        public void GetPossibleMoves_ShouldGivePriorities_Appropriately()
        {
            var map     = new ListMap(6);
            var player  = new ListPlayer(1, map.Size, new Config());
            var player2 = new ListPlayer(2, map.Size, new Config());

            map.TakeHex(PlayerType.Blue, 0, 3);
            map.TakeHex(PlayerType.Red, 3, 3);
            map.TakeHex(PlayerType.Blue, 2, 3);
            map.TakeHex(PlayerType.Red, 3, 2);
            map.TakeHex(PlayerType.Blue, 1, 3);
            map.TakeHex(PlayerType.Red, 3, 1);

            var scout    = new Pathfinder(map, player.Me);
            var redScout = new Pathfinder(map, player2.Me);

            var path    = scout.GetPathForPlayer();
            var redPath = redScout.GetPathForPlayer();

            var inquisitor           = new Inquisitor();
            var possibleMovesForBlue = inquisitor.GetPossibleMoves(redPath, path, player.Me, map);

            TestContext.WriteLine("Blue =========");
            foreach (var move in path.Where(x => x.Owner == PlayerType.White))
            {
                TestContext.WriteLine(move);
            }
            TestContext.WriteLine("Red ========");
            foreach (var move in redPath.Where(x => x.Owner == PlayerType.White))
            {
                TestContext.WriteLine(move);
            }
            TestContext.WriteLine("Result =========");
            foreach (var move in possibleMovesForBlue)
            {
                TestContext.WriteLine(move + " " + move.Priority);
            }
        }
Example #9
0
        public void TakeHex_ShouldAttachAllMatrices_WhenAttachingToMultiples()
        {
            map = new ListMap(11);
            map.TakeHex(PlayerType.Red, 1, 1);
            map.TakeHex(PlayerType.Red, 1, 2);
            map.TakeHex(PlayerType.Red, 1, 3);
            map.TakeHex(PlayerType.Red, 1, 4);
            map.TakeHex(PlayerType.Red, 1, 5);

            map.TakeHex(PlayerType.Red, 1, 7);
            map.TakeHex(PlayerType.Red, 1, 8);
            map.TakeHex(PlayerType.Red, 1, 9);
            map.TakeHex(PlayerType.Red, 1, 10);

            Assert.AreEqual(112, map.Board.Count(x => x.Owner == PlayerType.White));

            Assert.AreSame(map.HexAt(1, 1).Attached, map.HexAt(1, 4).Attached);

            map.TakeHex(PlayerType.Red, 1, 6);
            Assert.AreSame(map.HexAt(1, 1).Attached, map.HexAt(1, 10).Attached);
            Assert.IsTrue(map.HexAt(1, 1).IsAttachedToRight);
            Assert.IsFalse(map.HexAt(1, 1).IsAttachedToLeft);
            map.TakeHex(PlayerType.Red, 1, 0);
            Assert.IsTrue(map.HexAt(1, 1).IsAttachedToLeft);
            Assert.IsTrue(map.HexAt(1, 1).IsAttachedToBothEnds());
        }