当前位置: 首页>>代码示例>>C#>>正文


C# ChessGame.GetPieceAt方法代码示例

本文整理汇总了C#中ChessGame.GetPieceAt方法的典型用法代码示例。如果您正苦于以下问题:C# ChessGame.GetPieceAt方法的具体用法?C# ChessGame.GetPieceAt怎么用?C# ChessGame.GetPieceAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ChessGame的用法示例。


在下文中一共展示了ChessGame.GetPieceAt方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetValidMoves

 public override ReadOnlyCollection<Move> GetValidMoves(Position from, bool returnIfAny, ChessGame game, Func<Move, bool> gameMoveValidator)
 {
     ChessUtilities.ThrowIfNull(from, "from");
     List<Move> validMoves = new List<Move>();
     Piece piece = game.GetPieceAt(from);
     int l0 = game.BoardHeight;
     int l1 = game.BoardWidth;
     for (int i = -7; i < 8; i++)
     {
         if (i == 0)
             continue;
         if (from.Rank + i > 0 && from.Rank + i <= l0)
         {
             Move move = new Move(from, new Position(from.File, from.Rank + i), piece.Owner);
             if (gameMoveValidator(move))
             {
                 validMoves.Add(move);
                 if (returnIfAny)
                     return new ReadOnlyCollection<Move>(validMoves);
             }
         }
         if ((int)from.File + i > -1 && (int)from.File + i < l1)
         {
             Move move = new Move(from, new Position(from.File + i, from.Rank), piece.Owner);
             if (gameMoveValidator(move))
             {
                 validMoves.Add(move);
                 if (returnIfAny)
                     return new ReadOnlyCollection<Move>(validMoves);
             }
         }
     }
     return new ReadOnlyCollection<Move>(validMoves);
 }
开发者ID:ProgramFOX,项目名称:Chess.NET,代码行数:34,代码来源:Rook.cs

示例2: IsValidMove

        public override bool IsValidMove(Move move, ChessGame game)
        {
            bool validByStandardRules = base.IsValidMove(move, game);
            if (validByStandardRules) return true;
            if (move.OriginalPosition.Rank == 1 &&
                move.NewPosition.Rank == 3 &&
                move.OriginalPosition.File == move.NewPosition.File &&
                game.GetPieceAt(move.NewPosition) == null &&
                game.GetPieceAt(new Position(move.OriginalPosition.File, move.OriginalPosition.Rank + 1)) == null)
                // Horde pawns at the first rank can also move two squares on their first move. However, these can't be en-passant captured.
            {
                return true;
            }

            return false;
        }
开发者ID:ProgramFOX,项目名称:Chess.NET,代码行数:16,代码来源:HordePawn.cs

示例3: IsValidMove

        public override bool IsValidMove(Move move, ChessGame game)
        {
            ChessUtilities.ThrowIfNull(move, "move");
            ChessUtilities.ThrowIfNull(game, "game");
            Position origin = move.OriginalPosition;
            Position destination = move.NewPosition;

            PositionDistance posDelta = new PositionDistance(origin, destination);
            if (posDelta.DistanceX != 0 && posDelta.DistanceY != 0)
                return false;
            bool increasingRank = destination.Rank > origin.Rank;
            bool increasingFile = (int)destination.File > (int)origin.File;
            if (posDelta.DistanceX == 0)
            {
                int f = (int)origin.File;
                for (int r = origin.Rank + (increasingRank ? 1 : -1);
                    increasingRank ? r < destination.Rank : r > destination.Rank;
                    r += increasingRank ? 1 : -1)
                {
                    if (game.GetPieceAt((File)f, r) != null)
                    {
                        return false;
                    }
                }
            }
            else // (posDelta.DeltaY == 0)
            {
                int r = origin.Rank;
                for (int f = (int)origin.File + (increasingFile ? 1 : -1);
                    increasingFile ? f < (int)destination.File : f > (int)destination.File;
                    f += increasingFile ? 1 : -1)
                {
                    if (game.GetPieceAt((File)f, r) != null)
                    {
                        return false;
                    }
                }
            }
            return true;
        }
开发者ID:ProgramFOX,项目名称:Chess.NET,代码行数:40,代码来源:Rook.cs

示例4: CanCastle

 protected virtual bool CanCastle(Position origin, Position destination, ChessGame game)
 {
     if (!HasCastlingAbility) return false;
     if (Owner == Player.White)
     {
         if (origin.File != File.E || origin.Rank != 1)
             return false;
         if (game.IsInCheck(Player.White))
             return false;
         if (destination.File == File.C)
         {
             if (!game.CanWhiteCastleQueenSide || game.GetPieceAt(File.D, 1) != null
                 || game.GetPieceAt(File.C, 1) != null
                 || game.GetPieceAt(File.B, 1) != null
                 || game.WouldBeInCheckAfter(new Move(new Position(File.E, 1), new Position(File.D, 1), Player.White), Player.White)
                 || game.WouldBeInCheckAfter(new Move(new Position(File.E, 1), new Position(File.C, 1), Player.White), Player.White))
                 return false;
         }
         else
         {
             if (!game.CanWhiteCastleKingSide || game.GetPieceAt(File.F, 1) != null
                 || game.GetPieceAt(File.G, 1) != null
                 || game.WouldBeInCheckAfter(new Move(new Position(File.E, 1), new Position(File.F, 1), Player.White), Player.White)
                 || game.WouldBeInCheckAfter(new Move(new Position(File.E, 1), new Position(File.G, 1), Player.White), Player.White))
                 return false;
         }
     }
     else
     {
         if (origin.File != File.E || origin.Rank != 8)
             return false;
         if (game.IsInCheck(Player.Black))
             return false;
         if (destination.File == File.C)
         {
             if (!game.CanBlackCastleQueenSide || game.GetPieceAt(File.D, 8) != null
                 || game.GetPieceAt(File.C, 8) != null
                 || game.GetPieceAt(File.B, 8) != null
                 || game.WouldBeInCheckAfter(new Move(new Position(File.E, 8), new Position(File.D, 8), Player.Black), Player.Black)
                 || game.WouldBeInCheckAfter(new Move(new Position(File.E, 8), new Position(File.C, 8), Player.Black), Player.Black))
                 return false;
         }
         else
         {
             if (!game.CanBlackCastleKingSide || game.GetPieceAt(File.F, 8) != null
                 || game.GetPieceAt(File.G, 8) != null
                 || game.WouldBeInCheckAfter(new Move(new Position(File.E, 8), new Position(File.F, 8), Player.Black), Player.Black)
                 || game.WouldBeInCheckAfter(new Move(new Position(File.E, 8), new Position(File.G, 8), Player.Black), Player.Black))
                 return false;
         }
     }
     return true;
 }
开发者ID:ProgramFOX,项目名称:Chess.NET,代码行数:53,代码来源:King.cs

示例5: GetValidMoves

 public override ReadOnlyCollection<Move> GetValidMoves(Position from, bool returnIfAny, ChessGame game, Func<Move, bool> gameMoveValidator)
 {
     List<Move> validMoves = new List<Move>();
     Piece piece = game.GetPieceAt(from);
     int l0 = game.BoardHeight;
     int l1 = game.BoardWidth;
     int[][] directions = new int[][] { new int[] { 2, 1 }, new int[] { -2, -1 }, new int[] { 1, 2 }, new int[] { -1, -2 },
                 new int[] { 1, -2 }, new int[] { -1, 2 }, new int[] { 2, -1 }, new int[] { -2, 1 } };
     foreach (int[] dir in directions)
     {
         if ((int)from.File + dir[0] < 0 || (int)from.File + dir[0] >= l1
             || from.Rank + dir[1] < 1 || from.Rank + dir[1] > l0)
             continue;
         Move move = new Move(from, new Position(from.File + dir[0], from.Rank + dir[1]), piece.Owner);
         if (gameMoveValidator(move))
         {
             validMoves.Add(move);
             if (returnIfAny)
                 return new ReadOnlyCollection<Move>(validMoves);
         }
     }
     return new ReadOnlyCollection<Move>(validMoves);
 }
开发者ID:ProgramFOX,项目名称:Chess.NET,代码行数:23,代码来源:Knight.cs

示例6: IsValidMove

        public override bool IsValidMove(Move move, ChessGame game)
        {
            ChessUtilities.ThrowIfNull(move, "move");
            ChessUtilities.ThrowIfNull(game, "game");
            Position origin = move.OriginalPosition;
            Position destination = move.NewPosition;

            Piece promotion = null;
            if (move.Promotion.HasValue && ValidPromotionPieces.Contains(move.Promotion.Value))
            {
                promotion = game.MapPgnCharToPiece(char.ToUpper(move.Promotion.Value), move.Player);
            }
            PositionDistance posDelta = new PositionDistance(origin, destination);
            if ((posDelta.DistanceX != 0 || posDelta.DistanceY != 1) && (posDelta.DistanceX != 1 || posDelta.DistanceY != 1)
                        && (posDelta.DistanceX != 0 || posDelta.DistanceY != 2))
                return false;
            if (Owner == Player.White)
            {
                if (origin.Rank > destination.Rank)
                    return false;
                if (destination.Rank == 8)
                {
                    if (promotion == null)
                        return false;
                    if (promotion.Owner != Player.White)
                        return false;
                    if (!ValidPromotionPieces.Contains(promotion.GetFenCharacter()))
                        return false;
                }
            }
            if (Owner == Player.Black)
            {
                if (origin.Rank < destination.Rank)
                    return false;
                if (destination.Rank == 1)
                {
                    if (promotion == null)
                        return false;
                    if (promotion.Owner != Player.Black)
                        return false;
                    if (!ValidPromotionPieces.Contains(promotion.GetFenCharacter()))
                        return false;
                }
            }
            bool checkEnPassant = false;
            if (posDelta.DistanceY == 2)
            {
                if ((origin.Rank != 2 && Owner == Player.White)
                    || (origin.Rank != 7 && Owner == Player.Black))
                    return false;
                if (origin.Rank == 2 && game.GetPieceAt(origin.File, 3) != null)
                    return false;
                if (origin.Rank == 7 && game.GetPieceAt(origin.File, 6) != null)
                    return false;
            }
            Piece pieceAtDestination = game.GetPieceAt(destination);
            if (posDelta.DistanceX == 0 && (posDelta.DistanceY == 1 || posDelta.DistanceY == 2))
            {
                if (pieceAtDestination != null)
                    return false;
            }
            else
            {
                if (pieceAtDestination == null)
                    checkEnPassant = true;
                else if (pieceAtDestination.Owner == Owner)
                    return false;
            }
            if (checkEnPassant)
            {
                ReadOnlyCollection<DetailedMove> _moves = game.Moves;
                if (_moves.Count == 0)
                {
                    return false;
                }
                if ((origin.Rank != 5 && Owner == Player.White)
                    || (origin.Rank != 4 && Owner == Player.Black))
                    return false;
                Move latestMove = _moves[_moves.Count - 1];
                if (latestMove.Player != ChessUtilities.GetOpponentOf(Owner))
                    return false;
                if (!(game.GetPieceAt(latestMove.NewPosition) is Pawn))
                    return false;
                if (game.GetPieceAt(latestMove.NewPosition).Owner == Owner)
                    return false;
                if (Owner == Player.White)
                {
                    if (latestMove.OriginalPosition.Rank != 7 || latestMove.NewPosition.Rank != 5)
                        return false;
                }
                else // (m.Player == Players.Black)
                {
                    if (latestMove.OriginalPosition.Rank != 2 || latestMove.NewPosition.Rank != 4)
                        return false;
                }
                if (destination.File != latestMove.NewPosition.File)
                    return false;
            }
            return true;
        }
开发者ID:ProgramFOX,项目名称:Chess.NET,代码行数:100,代码来源:Pawn.cs

示例7: GetValidMoves

 public override ReadOnlyCollection<Move> GetValidMoves(Position from, bool returnIfAny, ChessGame game, Func<Move, bool> gameMoveValidator)
 {
     ChessUtilities.ThrowIfNull(from, "from");
     List<Move> validMoves = new List<Move>();
     Piece piece = game.GetPieceAt(from);
     int l0 = game.BoardHeight;
     int l1 = game.BoardWidth;
     int[][] directions;
     if (piece.Owner == Player.White)
     {
         directions = new int[][] { new int[] { 0, 1 }, new int[] { 0, 2 }, new int[] { 1, 1 }, new int[] { -1, 1 } };
     }
     else
     {
         directions = new int[][] { new int[] { 0, -1 }, new int[] { 0, -2 }, new int[] { -1, -1 }, new int[] { 1, -1 } };
     }
     foreach (int[] dir in directions)
     {
         if ((int)from.File + dir[0] < 0 || (int)from.File + dir[0] >= l1
             || from.Rank + dir[1] < 1 || from.Rank + dir[1] > l0)
             continue;
         Move move = new Move(from, new Position(from.File + dir[0], from.Rank + dir[1]), piece.Owner);
         List<Move> moves = new List<Move>();
         if ((move.NewPosition.Rank == 8 && move.Player == Player.White) || (move.NewPosition.Rank == 1 && move.Player == Player.Black))
         {
             foreach (char pieceChar in ValidPromotionPieces.Where(x => char.IsUpper(x)))
             {
                 moves.Add(new Move(move.OriginalPosition, move.NewPosition, move.Player, pieceChar));
             }
         }
         else
         {
             moves.Add(move);
         }
         foreach (Move m in moves)
         {
             if (gameMoveValidator(m))
             {
                 validMoves.Add(m);
                 if (returnIfAny)
                     return new ReadOnlyCollection<Move>(validMoves);
             }
         }
     }
     return new ReadOnlyCollection<Move>(validMoves);
 }
开发者ID:ProgramFOX,项目名称:Chess.NET,代码行数:46,代码来源:Pawn.cs

示例8: TestCustomInitialize

 public static void TestCustomInitialize()
 {
     Rank one = Rank.One;
     Rank two = Rank.Two;
     Rank three = Rank.Three;
     Rank four = Rank.Four;
     Rank five = Rank.Five;
     Rank six = Rank.Six;
     Rank seven = Rank.Seven;
     Rank eight = Rank.Eight;
     File a = File.A;
     File b = File.B;
     File c = File.C;
     File d = File.D;
     File e = File.E;
     File f = File.F;
     File g = File.G;
     File h = File.H;
     ChessPiece[][] board = new ChessPiece[8][]
     {
         new[] { rb, o, bb, qb, kb, bb, nb, rb },
         new[] { pb, pb, pb, pb, pb, pb, pb, pb },
         new[] { o, o, nb, o, o, o, o, o },
         new[] { o, o, o, o, o, o, o, o },
         new[] { o, o, o, o, pw, o, o, o },
         new[] { o, o, o, o, o, o, o, o },
         new[] { pw, pw, pw, pw, o, pw, pw, pw },
         new[] { rw, nw, bw, qw, kw, bw, nw, rw }
     };
     ChessGame cb = new ChessGame(board, Player.White);
     Assert.AreEqual(rw, cb.GetPieceAt(a, one));
     Assert.AreEqual(nw, cb.GetPieceAt(b, one));
     Assert.AreEqual(bw, cb.GetPieceAt(c, one));
     Assert.AreEqual(qw, cb.GetPieceAt(d, one));
     Assert.AreEqual(kw, cb.GetPieceAt(e, one));
     Assert.AreEqual(bw, cb.GetPieceAt(f, one));
     Assert.AreEqual(nw, cb.GetPieceAt(g, one));
     Assert.AreEqual(rw, cb.GetPieceAt(h, one));
     Assert.AreEqual(pw, cb.GetPieceAt(a, two));
     Assert.AreEqual(pw, cb.GetPieceAt(b, two));
     Assert.AreEqual(pw, cb.GetPieceAt(c, two));
     Assert.AreEqual(pw, cb.GetPieceAt(d, two));
     Assert.AreEqual(o, cb.GetPieceAt(e, two));
     Assert.AreEqual(pw, cb.GetPieceAt(f, two));
     Assert.AreEqual(pw, cb.GetPieceAt(g, two));
     Assert.AreEqual(pw, cb.GetPieceAt(h, two));
     Assert.AreEqual(o, cb.GetPieceAt(a, three));
     Assert.AreEqual(o, cb.GetPieceAt(b, three));
     Assert.AreEqual(o, cb.GetPieceAt(c, three));
     Assert.AreEqual(o, cb.GetPieceAt(d, three));
     Assert.AreEqual(o, cb.GetPieceAt(e, three));
     Assert.AreEqual(o, cb.GetPieceAt(f, three));
     Assert.AreEqual(o, cb.GetPieceAt(g, three));
     Assert.AreEqual(o, cb.GetPieceAt(h, three));
     Assert.AreEqual(o, cb.GetPieceAt(a, four));
     Assert.AreEqual(o, cb.GetPieceAt(b, four));
     Assert.AreEqual(o, cb.GetPieceAt(c, four));
     Assert.AreEqual(o, cb.GetPieceAt(d, four));
     Assert.AreEqual(pw, cb.GetPieceAt(e, four));
     Assert.AreEqual(o, cb.GetPieceAt(f, four));
     Assert.AreEqual(o, cb.GetPieceAt(g, four));
     Assert.AreEqual(o, cb.GetPieceAt(h, four));
     Assert.AreEqual(o, cb.GetPieceAt(a, five));
     Assert.AreEqual(o, cb.GetPieceAt(b, five));
     Assert.AreEqual(o, cb.GetPieceAt(c, five));
     Assert.AreEqual(o, cb.GetPieceAt(d, five));
     Assert.AreEqual(o, cb.GetPieceAt(e, five));
     Assert.AreEqual(o, cb.GetPieceAt(f, five));
     Assert.AreEqual(o, cb.GetPieceAt(g, five));
     Assert.AreEqual(o, cb.GetPieceAt(h, five));
     Assert.AreEqual(o, cb.GetPieceAt(a, six));
     Assert.AreEqual(o, cb.GetPieceAt(b, six));
     Assert.AreEqual(cb.GetPieceAt(c, six), nb);
     Assert.AreEqual(o, cb.GetPieceAt(d, six));
     Assert.AreEqual(o, cb.GetPieceAt(e, six));
     Assert.AreEqual(o, cb.GetPieceAt(f, six));
     Assert.AreEqual(o, cb.GetPieceAt(g, six));
     Assert.AreEqual(o, cb.GetPieceAt(h, six));
     Assert.AreEqual(pb, cb.GetPieceAt(a, seven));
     Assert.AreEqual(pb, cb.GetPieceAt(b, seven));
     Assert.AreEqual(pb, cb.GetPieceAt(c, seven));
     Assert.AreEqual(pb, cb.GetPieceAt(d, seven));
     Assert.AreEqual(pb, cb.GetPieceAt(e, seven));
     Assert.AreEqual(pb, cb.GetPieceAt(f, seven));
     Assert.AreEqual(pb, cb.GetPieceAt(g, seven));
     Assert.AreEqual(pb, cb.GetPieceAt(h, seven));
     Assert.AreEqual(rb, cb.GetPieceAt(a, eight));
     Assert.AreEqual(o, cb.GetPieceAt(b, eight));
     Assert.AreEqual(bb, cb.GetPieceAt(c, eight));
     Assert.AreEqual(qb, cb.GetPieceAt(d, eight));
     Assert.AreEqual(kb, cb.GetPieceAt(e, eight));
     Assert.AreEqual(bb, cb.GetPieceAt(f, eight));
     Assert.AreEqual(nb, cb.GetPieceAt(g, eight));
     Assert.AreEqual(rb, cb.GetPieceAt(h, eight));
 }
开发者ID:gunr2171,项目名称:Chess.NET,代码行数:95,代码来源:ChessGameTests.cs

示例9: TestGetPieceAt

 public static void TestGetPieceAt()
 {
     ChessGame cb = new ChessGame();
     Rank one = Rank.One;
     Rank two = Rank.Two;
     Rank three = Rank.Three;
     Rank four = Rank.Four;
     Rank five = Rank.Five;
     Rank six = Rank.Six;
     Rank seven = Rank.Seven;
     Rank eight = Rank.Eight;
     File a = File.A;
     File b = File.B;
     File c = File.C;
     File d = File.D;
     File e = File.E;
     File f = File.F;
     File g = File.G;
     File h = File.H;
     Assert.AreEqual(rw, cb.GetPieceAt(a, one));
     Assert.AreEqual(nw, cb.GetPieceAt(b, one));
     Assert.AreEqual(bw, cb.GetPieceAt(c, one));
     Assert.AreEqual(qw, cb.GetPieceAt(d, one));
     Assert.AreEqual(kw, cb.GetPieceAt(e, one));
     Assert.AreEqual(bw, cb.GetPieceAt(f, one));
     Assert.AreEqual(nw, cb.GetPieceAt(g, one));
     Assert.AreEqual(rw, cb.GetPieceAt(h, one));
     Assert.AreEqual(pw, cb.GetPieceAt(a, two));
     Assert.AreEqual(pw, cb.GetPieceAt(b, two));
     Assert.AreEqual(pw, cb.GetPieceAt(c, two));
     Assert.AreEqual(pw, cb.GetPieceAt(d, two));
     Assert.AreEqual(pw, cb.GetPieceAt(e, two));
     Assert.AreEqual(pw, cb.GetPieceAt(f, two));
     Assert.AreEqual(pw, cb.GetPieceAt(g, two));
     Assert.AreEqual(pw, cb.GetPieceAt(h, two));
     Assert.AreEqual(o, cb.GetPieceAt(a, three));
     Assert.AreEqual(o, cb.GetPieceAt(b, three));
     Assert.AreEqual(o, cb.GetPieceAt(c, three));
     Assert.AreEqual(o, cb.GetPieceAt(d, three));
     Assert.AreEqual(o, cb.GetPieceAt(e, three));
     Assert.AreEqual(o, cb.GetPieceAt(f, three));
     Assert.AreEqual(o, cb.GetPieceAt(g, three));
     Assert.AreEqual(o, cb.GetPieceAt(h, three));
     Assert.AreEqual(o, cb.GetPieceAt(a, four));
     Assert.AreEqual(o, cb.GetPieceAt(b, four));
     Assert.AreEqual(o, cb.GetPieceAt(c, four));
     Assert.AreEqual(o, cb.GetPieceAt(d, four));
     Assert.AreEqual(o, cb.GetPieceAt(e, four));
     Assert.AreEqual(o, cb.GetPieceAt(f, four));
     Assert.AreEqual(o, cb.GetPieceAt(g, four));
     Assert.AreEqual(o, cb.GetPieceAt(h, four));
     Assert.AreEqual(o, cb.GetPieceAt(a, five));
     Assert.AreEqual(o, cb.GetPieceAt(b, five));
     Assert.AreEqual(o, cb.GetPieceAt(c, five));
     Assert.AreEqual(o, cb.GetPieceAt(d, five));
     Assert.AreEqual(o, cb.GetPieceAt(e, five));
     Assert.AreEqual(o, cb.GetPieceAt(f, five));
     Assert.AreEqual(o, cb.GetPieceAt(g, five));
     Assert.AreEqual(o, cb.GetPieceAt(h, five));
     Assert.AreEqual(o, cb.GetPieceAt(a, six));
     Assert.AreEqual(o, cb.GetPieceAt(b, six));
     Assert.AreEqual(o, cb.GetPieceAt(c, six));
     Assert.AreEqual(o, cb.GetPieceAt(d, six));
     Assert.AreEqual(o, cb.GetPieceAt(e, six));
     Assert.AreEqual(o, cb.GetPieceAt(f, six));
     Assert.AreEqual(o, cb.GetPieceAt(g, six));
     Assert.AreEqual(o, cb.GetPieceAt(h, six));
     Assert.AreEqual(pb, cb.GetPieceAt(a, seven));
     Assert.AreEqual(pb, cb.GetPieceAt(b, seven));
     Assert.AreEqual(pb, cb.GetPieceAt(c, seven));
     Assert.AreEqual(pb, cb.GetPieceAt(d, seven));
     Assert.AreEqual(pb, cb.GetPieceAt(e, seven));
     Assert.AreEqual(pb, cb.GetPieceAt(f, seven));
     Assert.AreEqual(pb, cb.GetPieceAt(g, seven));
     Assert.AreEqual(pb, cb.GetPieceAt(h, seven));
     Assert.AreEqual(rb, cb.GetPieceAt(a, eight));
     Assert.AreEqual(nb, cb.GetPieceAt(b, eight));
     Assert.AreEqual(bb, cb.GetPieceAt(c, eight));
     Assert.AreEqual(qb, cb.GetPieceAt(d, eight));
     Assert.AreEqual(kb, cb.GetPieceAt(e, eight));
     Assert.AreEqual(bb, cb.GetPieceAt(f, eight));
     Assert.AreEqual(nb, cb.GetPieceAt(g, eight));
     Assert.AreEqual(rb, cb.GetPieceAt(h, eight));
 }
开发者ID:gunr2171,项目名称:Chess.NET,代码行数:84,代码来源:ChessGameTests.cs

示例10: TestCustomInitialize

 public static void TestCustomInitialize()
 {
     File a = File.A;
     File b = File.B;
     File c = File.C;
     File d = File.D;
     File e = File.E;
     File f = File.F;
     File g = File.G;
     File h = File.H;
     Piece[][] board = new Piece[8][]
     {
         new[] { rb, o, bb, qb, kb, bb, nb, rb },
         new[] { pb, pb, pb, pb, pb, pb, pb, pb },
         new[] { o, o, nb, o, o, o, o, o },
         new[] { o, o, o, o, o, o, o, o },
         new[] { o, o, o, o, pw, o, o, o },
         new[] { o, o, o, o, o, o, o, o },
         new[] { pw, pw, pw, pw, o, pw, pw, pw },
         new[] { rw, nw, bw, qw, kw, bw, nw, rw }
     };
     ChessGame cb = new ChessGame(board, Player.White);
     Assert.AreEqual(rw, cb.GetPieceAt(a, 1));
     Assert.AreEqual(nw, cb.GetPieceAt(b, 1));
     Assert.AreEqual(bw, cb.GetPieceAt(c, 1));
     Assert.AreEqual(qw, cb.GetPieceAt(d, 1));
     Assert.AreEqual(kw, cb.GetPieceAt(e, 1));
     Assert.AreEqual(bw, cb.GetPieceAt(f, 1));
     Assert.AreEqual(nw, cb.GetPieceAt(g, 1));
     Assert.AreEqual(rw, cb.GetPieceAt(h, 1));
     Assert.AreEqual(pw, cb.GetPieceAt(a, 2));
     Assert.AreEqual(pw, cb.GetPieceAt(b, 2));
     Assert.AreEqual(pw, cb.GetPieceAt(c, 2));
     Assert.AreEqual(pw, cb.GetPieceAt(d, 2));
     Assert.AreEqual(o, cb.GetPieceAt(e, 2));
     Assert.AreEqual(pw, cb.GetPieceAt(f, 2));
     Assert.AreEqual(pw, cb.GetPieceAt(g, 2));
     Assert.AreEqual(pw, cb.GetPieceAt(h, 2));
     Assert.AreEqual(o, cb.GetPieceAt(a, 3));
     Assert.AreEqual(o, cb.GetPieceAt(b, 3));
     Assert.AreEqual(o, cb.GetPieceAt(c, 3));
     Assert.AreEqual(o, cb.GetPieceAt(d, 3));
     Assert.AreEqual(o, cb.GetPieceAt(e, 3));
     Assert.AreEqual(o, cb.GetPieceAt(f, 3));
     Assert.AreEqual(o, cb.GetPieceAt(g, 3));
     Assert.AreEqual(o, cb.GetPieceAt(h, 3));
     Assert.AreEqual(o, cb.GetPieceAt(a, 4));
     Assert.AreEqual(o, cb.GetPieceAt(b, 4));
     Assert.AreEqual(o, cb.GetPieceAt(c, 4));
     Assert.AreEqual(o, cb.GetPieceAt(d, 4));
     Assert.AreEqual(pw, cb.GetPieceAt(e, 4));
     Assert.AreEqual(o, cb.GetPieceAt(f, 4));
     Assert.AreEqual(o, cb.GetPieceAt(g, 4));
     Assert.AreEqual(o, cb.GetPieceAt(h, 4));
     Assert.AreEqual(o, cb.GetPieceAt(a, 5));
     Assert.AreEqual(o, cb.GetPieceAt(b, 5));
     Assert.AreEqual(o, cb.GetPieceAt(c, 5));
     Assert.AreEqual(o, cb.GetPieceAt(d, 5));
     Assert.AreEqual(o, cb.GetPieceAt(e, 5));
     Assert.AreEqual(o, cb.GetPieceAt(f, 5));
     Assert.AreEqual(o, cb.GetPieceAt(g, 5));
     Assert.AreEqual(o, cb.GetPieceAt(h, 5));
     Assert.AreEqual(o, cb.GetPieceAt(a, 6));
     Assert.AreEqual(o, cb.GetPieceAt(b, 6));
     Assert.AreEqual(cb.GetPieceAt(c, 6), nb);
     Assert.AreEqual(o, cb.GetPieceAt(d, 6));
     Assert.AreEqual(o, cb.GetPieceAt(e, 6));
     Assert.AreEqual(o, cb.GetPieceAt(f, 6));
     Assert.AreEqual(o, cb.GetPieceAt(g, 6));
     Assert.AreEqual(o, cb.GetPieceAt(h, 6));
     Assert.AreEqual(pb, cb.GetPieceAt(a, 7));
     Assert.AreEqual(pb, cb.GetPieceAt(b, 7));
     Assert.AreEqual(pb, cb.GetPieceAt(c, 7));
     Assert.AreEqual(pb, cb.GetPieceAt(d, 7));
     Assert.AreEqual(pb, cb.GetPieceAt(e, 7));
     Assert.AreEqual(pb, cb.GetPieceAt(f, 7));
     Assert.AreEqual(pb, cb.GetPieceAt(g, 7));
     Assert.AreEqual(pb, cb.GetPieceAt(h, 7));
     Assert.AreEqual(rb, cb.GetPieceAt(a, 8));
     Assert.AreEqual(o, cb.GetPieceAt(b, 8));
     Assert.AreEqual(bb, cb.GetPieceAt(c, 8));
     Assert.AreEqual(qb, cb.GetPieceAt(d, 8));
     Assert.AreEqual(kb, cb.GetPieceAt(e, 8));
     Assert.AreEqual(bb, cb.GetPieceAt(f, 8));
     Assert.AreEqual(nb, cb.GetPieceAt(g, 8));
     Assert.AreEqual(rb, cb.GetPieceAt(h, 8));
 }
开发者ID:ProgramFOX,项目名称:Chess.NET,代码行数:87,代码来源:ChessGameTests.cs

示例11: TestGetPieceAt

 public static void TestGetPieceAt()
 {
     ChessGame cb = new ChessGame();
     File a = File.A;
     File b = File.B;
     File c = File.C;
     File d = File.D;
     File e = File.E;
     File f = File.F;
     File g = File.G;
     File h = File.H;
     Assert.AreEqual(rw, cb.GetPieceAt(a, 1));
     Assert.AreEqual(nw, cb.GetPieceAt(b, 1));
     Assert.AreEqual(bw, cb.GetPieceAt(c, 1));
     Assert.AreEqual(qw, cb.GetPieceAt(d, 1));
     Assert.AreEqual(kw, cb.GetPieceAt(e, 1));
     Assert.AreEqual(bw, cb.GetPieceAt(f, 1));
     Assert.AreEqual(nw, cb.GetPieceAt(g, 1));
     Assert.AreEqual(rw, cb.GetPieceAt(h, 1));
     Assert.AreEqual(pw, cb.GetPieceAt(a, 2));
     Assert.AreEqual(pw, cb.GetPieceAt(b, 2));
     Assert.AreEqual(pw, cb.GetPieceAt(c, 2));
     Assert.AreEqual(pw, cb.GetPieceAt(d, 2));
     Assert.AreEqual(pw, cb.GetPieceAt(e, 2));
     Assert.AreEqual(pw, cb.GetPieceAt(f, 2));
     Assert.AreEqual(pw, cb.GetPieceAt(g, 2));
     Assert.AreEqual(pw, cb.GetPieceAt(h, 2));
     Assert.AreEqual(o, cb.GetPieceAt(a, 3));
     Assert.AreEqual(o, cb.GetPieceAt(b, 3));
     Assert.AreEqual(o, cb.GetPieceAt(c, 3));
     Assert.AreEqual(o, cb.GetPieceAt(d, 3));
     Assert.AreEqual(o, cb.GetPieceAt(e, 3));
     Assert.AreEqual(o, cb.GetPieceAt(f, 3));
     Assert.AreEqual(o, cb.GetPieceAt(g, 3));
     Assert.AreEqual(o, cb.GetPieceAt(h, 3));
     Assert.AreEqual(o, cb.GetPieceAt(a, 4));
     Assert.AreEqual(o, cb.GetPieceAt(b, 4));
     Assert.AreEqual(o, cb.GetPieceAt(c, 4));
     Assert.AreEqual(o, cb.GetPieceAt(d, 4));
     Assert.AreEqual(o, cb.GetPieceAt(e, 4));
     Assert.AreEqual(o, cb.GetPieceAt(f, 4));
     Assert.AreEqual(o, cb.GetPieceAt(g, 4));
     Assert.AreEqual(o, cb.GetPieceAt(h, 4));
     Assert.AreEqual(o, cb.GetPieceAt(a, 5));
     Assert.AreEqual(o, cb.GetPieceAt(b, 5));
     Assert.AreEqual(o, cb.GetPieceAt(c, 5));
     Assert.AreEqual(o, cb.GetPieceAt(d, 5));
     Assert.AreEqual(o, cb.GetPieceAt(e, 5));
     Assert.AreEqual(o, cb.GetPieceAt(f, 5));
     Assert.AreEqual(o, cb.GetPieceAt(g, 5));
     Assert.AreEqual(o, cb.GetPieceAt(h, 5));
     Assert.AreEqual(o, cb.GetPieceAt(a, 6));
     Assert.AreEqual(o, cb.GetPieceAt(b, 6));
     Assert.AreEqual(o, cb.GetPieceAt(c, 6));
     Assert.AreEqual(o, cb.GetPieceAt(d, 6));
     Assert.AreEqual(o, cb.GetPieceAt(e, 6));
     Assert.AreEqual(o, cb.GetPieceAt(f, 6));
     Assert.AreEqual(o, cb.GetPieceAt(g, 6));
     Assert.AreEqual(o, cb.GetPieceAt(h, 6));
     Assert.AreEqual(pb, cb.GetPieceAt(a, 7));
     Assert.AreEqual(pb, cb.GetPieceAt(b, 7));
     Assert.AreEqual(pb, cb.GetPieceAt(c, 7));
     Assert.AreEqual(pb, cb.GetPieceAt(d, 7));
     Assert.AreEqual(pb, cb.GetPieceAt(e, 7));
     Assert.AreEqual(pb, cb.GetPieceAt(f, 7));
     Assert.AreEqual(pb, cb.GetPieceAt(g, 7));
     Assert.AreEqual(pb, cb.GetPieceAt(h, 7));
     Assert.AreEqual(rb, cb.GetPieceAt(a, 8));
     Assert.AreEqual(nb, cb.GetPieceAt(b, 8));
     Assert.AreEqual(bb, cb.GetPieceAt(c, 8));
     Assert.AreEqual(qb, cb.GetPieceAt(d, 8));
     Assert.AreEqual(kb, cb.GetPieceAt(e, 8));
     Assert.AreEqual(bb, cb.GetPieceAt(f, 8));
     Assert.AreEqual(nb, cb.GetPieceAt(g, 8));
     Assert.AreEqual(rb, cb.GetPieceAt(h, 8));
 }
开发者ID:ProgramFOX,项目名称:Chess.NET,代码行数:76,代码来源:ChessGameTests.cs


注:本文中的ChessGame.GetPieceAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。