Example #1
0
        public void AllowPlayerToCaptureOpponentPiece()
        {
            var boardState = new BoardState();

            boardState.Add(new Pawn(Player.White, "1f"));
            boardState.Add(new Pawn(Player.Black, "1g"));
            var board = new Board(boardState, Player.Black);

            var result = board.Move(Player.Black, "1g", "1f");

            Assert.Equal(BoardResult.ValidOperation, result);
        }
Example #2
0
        public void FavourExposedMoveToRiskOfCaptureMove()
        {
            var boardState = new BoardState();

            boardState.Add(new Pawn(PlayerType.Black, "3g"));
            boardState.Add(new Pawn(PlayerType.Black, "2g", false));
            boardState.Add(new Bishop(PlayerType.White, "5c"));

            var board       = new Board(boardState, PlayerType.Black);
            var moveAdvisor = NoviceComputerPlayer.CreateFor(PlayerType.Black, board);
            var bestMove    = moveAdvisor.AskForNextMove();

            Assert.Equal("3g3f", bestMove);
        }
Example #3
0
        public void MoveToCheckMateIfPossible()
        {
            var boardState = new BoardState();

            boardState.Add(new King(PlayerType.White, "1c"));
            boardState.Add(new Lance(PlayerType.White, "1b"));
            boardState.Add(new Pawn(PlayerType.White, "1d"));
            boardState.Add(new Bishop(PlayerType.Black, "5c"));
            boardState.Add(new Lance(PlayerType.Black, "2e"));

            var board = new Board(boardState, PlayerType.Black);

            var moveAdvisor = NoviceComputerPlayer.CreateFor(PlayerType.Black, board);
            var bestMove    = moveAdvisor.AskForNextMove();

            Assert.Equal("5c3a", bestMove);
        }
Example #4
0
        public void BeAbleToHandlePieceNotFound()
        {
            var boardState = new BoardState();

            boardState.Add(new King(Player.Black, "b2"));

            var actual = boardState.GetPiece("a1");

            Assert.Null(actual);
        }
Example #5
0
        public void BeAbleToGetExistingPiece()
        {
            var expected   = new King(Player.Black, "a1");
            var boardState = new BoardState();

            boardState.Add(expected);

            var actual = boardState.GetPiece("a1");

            Assert.Equal(expected, actual);
        }