Пример #1
0
        public void GetMoves_SingleJumpAndMakeKingSequence()
        {
            var board = new SquareBoard(3);

            board.Set(Figure.CreateSimple(2, 2, Side.Black));
            board.Set(Figure.CreateSimple(1, 1, Side.Red));
            testOutput.WriteLine(board.ToString());

            var subject = GetSubject();
            var moves   = subject.GetMoves(board, Side.Black);

            var move             = moves[Figure.CreateSimple(2, 2, Side.Black)].Single();
            var expectedSequence = new MoveSequence(MoveStep.Jump(0, 0), MoveStep.King());

            Assert.Equal(expectedSequence, move);
        }
Пример #2
0
        public void GetMoves_PresetBoard_SimpleShouldStopWhenPromoted()
        {
            var board = Board6x6Preset1();

            testOutput.WriteLine(board.ToString());

            var subject = GetSubject();
            var moves   = subject.GetMoves(board, Side.Black);

            var simpleMoves             = moves[Figure.CreateSimple(4, 6, Side.Black)];
            var jumpUntilPromotedToKing = new MoveSequence(
                MoveStep.Jump(2, 4),
                MoveStep.Jump(0, 2),
                MoveStep.King());

            Assert.Contains(jumpUntilPromotedToKing, simpleMoves);
        }
Пример #3
0
        public void GetMoves_SingleSimple_PromoteToKing()
        {
            var figure = Figure.CreateSimple(1, 1, Side.Black);
            var board  = new SquareBoard(3);

            board.Set(figure);

            var subject = GetSubject();
            var moves   = subject.GetMoves(board, Side.Black);

            var figureMoves         = Assert.Contains(figure, moves);
            var expectedTopLeft     = new MoveSequence(MoveStep.Move(0, 0), MoveStep.King());
            var expectedBottomRight = new MoveSequence(MoveStep.Move(0, 2), MoveStep.King());

            Assert.Contains(expectedTopLeft, figureMoves);
            Assert.Contains(expectedBottomRight, figureMoves);
            Assert.Equal(2, figureMoves.Length);
        }
Пример #4
0
        public void FindBestMove_ChooseToStrikeKing()
        {
            /*     0 1 2 3 4
            *    0 . . . . .
            *    1 . r . R .   Simple and King
            *    2 . . . . .
            *    3 . r . . .
            *    4 b . . . .   */
            var board = new SquareBoard(5);

            board.Set(Figure.CreateSimple(1, 1, Side.Red));
            board.Set(Figure.CreateKing(1, 3, Side.Red));
            board.Set(Figure.CreateSimple(3, 1, Side.Red));
            board.Set(Figure.CreateSimple(4, 0, Side.Black));

            var subject = GetSubject();
            var move    = subject.FindBestMove(board, Side.Black, CancellationToken.None, Options(maxDepth: 2));

            Assert.Equal(Figure.CreateSimple(4, 0, Side.Black), move.Figure);
            Assert.Equal(new MoveSequence(MoveStep.Jump(2, 2), MoveStep.Jump(0, 4), MoveStep.King()), move.Sequence);
        }
Пример #5
0
        public void GetMoves_PresetBoard_SimpleHasSeveralJumpBranches()
        {
            var board = Board6x6Preset1();

            testOutput.WriteLine(board.ToString());

            var subject = GetSubject();
            var moves   = subject.GetMoves(board, Side.Black);

            var simpleMoves             = moves[Figure.CreateSimple(4, 6, Side.Black)];
            var expectedSimpleSequence1 = new MoveSequence(
                MoveStep.Jump(2, 4),
                MoveStep.Jump(0, 2),
                MoveStep.King());
            var expectedSimpleSequence2 = new MoveSequence(
                MoveStep.Jump(2, 4),
                MoveStep.Jump(0, 6),
                MoveStep.King());

            Assert.Collection(simpleMoves,
                              (x) => Assert.Equal(expectedSimpleSequence1, x),
                              (x) => Assert.Equal(expectedSimpleSequence2, x));
        }