Пример #1
0
        public void GetScoreForTeam_AfterMovementWhite_BottomLeftPawnTwoFieldUp_WhiteTeam_ShouldBe_Minus1()
        {
            // arrange
            var       board             = new OrdinaryChessBoard();
            TeamColor team              = TeamColor.White;
            int       expectedScore     = -1;
            var       startPawnPosition = new Models.Position.Position(1, 0);
            var       endPawnPosition   = new Models.Position.Position(3, 0);

            // act
            var pawn = board.RemoveFigure(startPawnPosition);

            var x = new OrdinaryChessBoardFigurePositionWeight();

            x.GetPositionWeight(pawn);

            board.SetFigure(pawn, endPawnPosition);
            pawn.Move(endPawnPosition);

            x.GetPositionWeight(pawn);

            var result = board.GetScoreForTeam(team);

            // assert
            Assert.AreEqual(expectedScore, result);
        }
Пример #2
0
        public void GetScoreForTeam_InitialConfiguration_ShouldBe0()
        {
            // arrange
            var       board         = new OrdinaryChessBoard();
            TeamColor team          = TeamColor.Black;
            int       expectedScore = 0;

            // act
            var result = board.GetScoreForTeam(team);

            // assert
            Assert.AreEqual(expectedScore, result);
        }
Пример #3
0
        public void GetScoreForTeam_AfterDeleteWhite_BottomLeftPawn_BlackTeam_ShouldBe_21()
        {
            // arrange
            var       board         = new OrdinaryChessBoard();
            TeamColor team          = TeamColor.Black;
            int       expectedScore = 21;
            var       pawnPosition  = new Models.Position.Position(1, 0);

            // act
            board.RemoveFigure(pawnPosition);
            var result = board.GetScoreForTeam(team);

            // assert
            Assert.AreEqual(expectedScore, result);
        }
        public void StartGame_Black_Depth1_Breadth5()
        {
            // arrange
            var computer = new ComputerPlayer(TeamColor.Black, 1, 5);
            var board    = new OrdinaryChessBoard();
            var boardVm  = new BoardViewModel(board);

            // act
            var move = computer.NextMove(boardVm);

            // assert
            Assert.NotNull(move);
            Assert.Greater(move.Score, 9);

            var figure = board.RemoveFigure(move.From);

            figure.Move(move.Destination);
            board.SetFigure(figure, move.Destination);

            Assert.AreEqual(move.Score, board.GetScoreForTeam(TeamColor.Black));
        }