Ejemplo n.º 1
0
        public void Test_MovePenguins()
        {
            GameClass game = new GameClass();

            game.AddPlayer("player1", PlayerType.AIEasy);
            game.AddPlayer("player2", PlayerType.AIEasy);
            game.ChoosePlayerColor();
            game.StartGame();

            Assert.IsTrue(game.AI_easy.MovePenguins((BoardClass)game.Board, (PlayerClass)game.CurrentPlayer));

            game.AI_easy.PlacePenguins((BoardClass)game.Board, (PlayerClass)game.CurrentPlayer);

            Assert.IsFalse(game.AI_easy.MovePenguins((BoardClass)game.Board, (PlayerClass)game.CurrentPlayer));

            List <Cell> listCellPenguins = game.AI_easy.GetMyPenguinsCell((BoardClass)game.Board, (PlayerClass)game.CurrentPlayer);
            List <Cell> listNeighbor     = game.AI_easy.FindAvailableCellNeighbor(listCellPenguins[0], (BoardClass)game.Board);
            int         compteur         = listNeighbor.Count - 1;

            for (int i = 0; i < compteur; i++)
            {
                listNeighbor[i].CellType  = CellType.Water;
                listNeighbor[i].FishCount = 0;
            }

            int[] indexToCompare = game.AI_easy.SearchIndexOfCell(listNeighbor[listNeighbor.Count - 1], (BoardClass)game.Board);
            game.AI_easy.MovePenguins((BoardClass)game.Board, (PlayerClass)game.CurrentPlayer);
            listCellPenguins = game.AI_easy.GetMyPenguinsCell((BoardClass)game.Board, (PlayerClass)game.CurrentPlayer);
            int[] indexPenguin = game.AI_easy.SearchIndexOfCell(listCellPenguins[listCellPenguins.Count - 1], (BoardClass)game.Board);

            Assert.AreEqual(indexPenguin[0], indexToCompare[0]);
            Assert.AreEqual(indexPenguin[1], indexToCompare[1]);
        }
Ejemplo n.º 2
0
        public void Test_PlacePenguins()
        {
            GameClass game = new GameClass();

            game.AddPlayer("player1", PlayerType.AIEasy);
            game.AddPlayer("player2", PlayerType.AIEasy);
            game.ChoosePlayerColor();
            game.StartGame();

            int Initcompteur    = 0;
            int CompareCompteur = 0;

            foreach (Cell cell in game.Board.Board)
            {
                if (cell.CellType == CellType.FishWithPenguin && cell.CurrentPenguin.Player == game.CurrentPlayer)
                {
                    Initcompteur++;
                }
            }

            game.AI_easy.PlacePenguins((BoardClass)game.Board, (PlayerClass)game.CurrentPlayer);

            foreach (Cell cell in game.Board.Board)
            {
                if (cell.CellType == CellType.FishWithPenguin && cell.CurrentPenguin.Player == game.CurrentPlayer)
                {
                    CompareCompteur++;
                }
            }

            Assert.IsTrue(CompareCompteur == Initcompteur + 1);
        }
Ejemplo n.º 3
0
        public void Test_PlacePenguin()
        {
            GameClass game = new GameClass();

            game.AddPlayer("player1", PlayerType.AIMedium);
            game.AddPlayer("player2", PlayerType.AIMedium);
            game.ChoosePlayerColor();
            game.StartGame();

            game.AI_medium.PlacePenguin(game.Board, game.CurrentPlayer, game.AIPenguins);
            game.AI_medium.PlacePenguin(game.Board, game.CurrentPlayer, game.AIPenguins);

            foreach (Cell cell in game.Board.Board)
            {
            }
        }
Ejemplo n.º 4
0
        public void Test_GetMyPenguinsCell()
        {
            GameClass game = new GameClass();

            game.AddPlayer("player1", PlayerType.AIEasy);
            game.AddPlayer("player2", PlayerType.AIEasy);
            game.ChoosePlayerColor();
            game.StartGame();

            List <Cell> cellList = game.AI_easy.GetMyPenguinsCell((BoardClass)game.Board, (PlayerClass)game.CurrentPlayer);

            foreach (Cell cell in cellList)
            {
                Assert.IsTrue(cell.CellType == CellType.FishWithPenguin);
                Assert.IsTrue(cell.CurrentPenguin.Player == game.CurrentPlayer);
            }
        }
Ejemplo n.º 5
0
        public void Test_GetAvailablePlacementCell()
        {
            GameClass game = new GameClass();

            game.AddPlayer("player1", PlayerType.AIEasy);
            game.AddPlayer("player2", PlayerType.AIEasy);
            game.ChoosePlayerColor();
            game.StartGame();

            List <Cell> cellList = game.AI_easy.GetAvailablePlacementCell((BoardClass)game.Board);

            foreach (Cell cell in cellList)
            {
                Assert.IsTrue(cell.CellType == CellType.Fish);
                Assert.IsTrue(cell.FishCount == 1);
            }
        }