示例#1
0
 public IDictionary <Figure, MoveSequence[]> GetMoves(SquareBoard board, Side side)
 {
     //fake move to the same cell; always 2 cases are possible
     return(new Dictionary <Figure, MoveSequence[]>
     {
         { _figure, new MoveSequence[]
           {
               new MoveSequence(MoveStep.Move(_figure.Point)),
               new MoveSequence(MoveStep.Move(_figure.Point))
           } }
     });
 }
示例#2
0
        public void GetMoves_SingleSimpleMoveForward()
        {
            var figure = Figure.CreateSimple(2, 0, 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 move        = Assert.Single(figureMoves);
            var step        = Assert.Single(move);

            Assert.Equal(MoveStep.Move(Point.At(1, 1)), step);
        }
示例#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 GetMoves_SingleSimple_ForwardOnly()
        {
            /* . . . .
             * . . . .
             * . b . .
             * . . . . */
            var board = new SquareBoard(4);

            board.Set(Figure.CreateSimple(2, 1, Side.Black));

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

            var figureMoves      = moves.Single().Value;
            var expectedTopLeft  = new MoveSequence(MoveStep.Move(1, 0));
            var expectedTopRight = new MoveSequence(MoveStep.Move(1, 2));

            Assert.Contains(expectedTopLeft, figureMoves);
            Assert.Contains(expectedTopRight, figureMoves);
            Assert.Equal(2, figureMoves.Length);
        }
示例#5
0
        public void GetMoves_SingleKing_AllEmptySides()
        {
            /* . . . .
             * . . b .
             * . β . .
             * b . . . */
            var board = new SquareBoard(4);
            var king  = Figure.CreateKing(2, 1, Side.Black);

            board.Set(king);
            board.Set(Figure.CreateSimple(3, 0, Side.Black));
            board.Set(Figure.CreateSimple(1, 2, Side.Black));

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

            var figureMoves         = moves[king];
            var expectedTopLeft     = new MoveSequence(MoveStep.Move(1, 0));
            var expectedBottomRight = new MoveSequence(MoveStep.Move(3, 2));

            Assert.Contains(expectedTopLeft, figureMoves);
            Assert.Contains(expectedBottomRight, figureMoves);
            Assert.Equal(2, figureMoves.Length);
        }