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


C# ChessGame.ApplyMove方法代码示例

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


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

示例1: TestAfter1c5

 public static void TestAfter1c5()
 {
     ChessGame game = new ChessGame();
     game.ApplyMove(new Move("E2", "E4", Player.White), true);
     game.ApplyMove(new Move("C7", "C5", Player.Black), true);
     string fen = game.GetFen();
     Assert.AreEqual("rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 2", fen);
 }
开发者ID:ProgramFOX,项目名称:Chess.NET,代码行数:8,代码来源:FenConvertTests.cs

示例2: TestMovingWhiteKingLosingCastlingRights

 public static void TestMovingWhiteKingLosingCastlingRights()
 {
     ChessGame game = new ChessGame();
     game.ApplyMove(new Move("E2", "E4", Player.White), true);
     game.ApplyMove(new Move("C7", "C5", Player.Black), true);
     game.ApplyMove(new Move("E1", "E2", Player.White), true);
     string fen = game.GetFen();
     Assert.AreEqual("rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPPKPPP/RNBQ1BNR b kq - 1 2", fen);
 }
开发者ID:ProgramFOX,项目名称:Chess.NET,代码行数:9,代码来源:FenConvertTests.cs

示例3: TestMovingBlackKingLosingCastlingRights

 public static void TestMovingBlackKingLosingCastlingRights()
 {
     ChessGame game = new ChessGame();
     game.ApplyMove(new Move("E2", "E4", Player.White), true);
     game.ApplyMove(new Move("E7", "E5", Player.Black), true);
     game.ApplyMove(new Move("G1", "F3", Player.White), true);
     game.ApplyMove(new Move("E8", "E7", Player.Black), true);
     string fen = game.GetFen();
     Assert.AreEqual("rnbq1bnr/ppppkppp/8/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R w KQ - 2 3", fen);
 }
开发者ID:ProgramFOX,项目名称:Chess.NET,代码行数:10,代码来源:FenConvertTests.cs

示例4: TestAfter1e4

 public static void TestAfter1e4()
 {
     ChessGame game = new ChessGame();
     game.ApplyMove(new Move("E2", "E4", Player.White), true);
     string fen = game.GetFen();
     Assert.AreEqual("rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1", fen);
 }
开发者ID:ProgramFOX,项目名称:Chess.NET,代码行数:7,代码来源:FenConvertTests.cs

示例5: TestValidMoveBlackPawn_Capture

        public static void TestValidMoveBlackPawn_Capture()
        {
            ChessGame cb = new ChessGame();
            Move move1 = new Move(new Position(File.A, Rank.Two), new Position(File.A, Rank.Three), Player.White);
            Move move2 = new Move(new Position(File.E, Rank.Seven), new Position(File.E, Rank.Five), Player.Black);
            Move move3 = new Move(new Position(File.D, Rank.Two), new Position(File.D, Rank.Four), Player.White);
            Move move4 = new Move(new Position(File.E, Rank.Five), new Position(File.D, Rank.Four), Player.Black);

            cb.ApplyMove(move1, true);
            cb.ApplyMove(move2, true);
            cb.ApplyMove(move3, true);

            Assert.True(cb.IsValidMove(move4));
        }
开发者ID:gunr2171,项目名称:Chess.NET,代码行数:14,代码来源:ChessGameTests.cs

示例6: TestInvalidMoveWhiteKing_QueensideCastling_KingMoved

        public static void TestInvalidMoveWhiteKing_QueensideCastling_KingMoved()
        {
            ChessPiece[][] board  = new ChessPiece[8][]
            {
                new[] { o, kb, o, o, o, o, o, o },
                new[] { o, o, o, o, o, o, o, o },
                new[] { o, o, o, o, o, o, o, o },
                new[] { o, o, o, o, o, o, o, o },
                new[] { o, o, o, o, o, o, o, o },
                new[] { o, o, o, o, o, o, o, o },
                new[] { o, o, o, o, o, o, o, o },
                new[] { rw, o, o, o, kw, o, o, o }
            };
            ChessGame cb = new ChessGame(board, Player.White);
            Move move1 = new Move(new Position(File.E, Rank.One), new Position(File.D, Rank.One), Player.White);
            Move move2 = new Move(new Position(File.B, Rank.Eight), new Position(File.B, Rank.Seven), Player.Black);
            Move move3 = new Move(new Position(File.D, Rank.One), new Position(File.B, Rank.One), Player.White);

            cb.ApplyMove(move1, true);
            cb.ApplyMove(move2, true);

            Assert.False(cb.IsValidMove(move3), "move3 should be invalid");
        }
开发者ID:gunr2171,项目名称:Chess.NET,代码行数:23,代码来源:ChessGameTests.cs

示例7: TestValidMoveWhiteQueenHorizontal

        public static void TestValidMoveWhiteQueenHorizontal()
        {
            ChessGame cb = new ChessGame();
            Move move1 = new Move(new Position(File.B, Rank.One), new Position(File.C, Rank.Three), Player.White);
            Move move2 = new Move(new Position(File.A, Rank.Seven), new Position(File.A, Rank.Six), Player.Black);
            Move move3 = new Move(new Position(File.D, Rank.Two), new Position(File.D, Rank.Three), Player.White);
            Move move4 = new Move(new Position(File.B, Rank.Seven), new Position(File.B, Rank.Six), Player.Black);
            Move move5 = new Move(new Position(File.C, Rank.One), new Position(File.D, Rank.Two), Player.White);
            Move move6 = new Move(new Position(File.C, Rank.Seven), new Position(File.C, Rank.Six), Player.Black);
            Move move7 = new Move(new Position(File.D, Rank.One), new Position(File.C, Rank.One), Player.White);
            Move move8 = new Move(new Position(File.D, Rank.One), new Position(File.B, Rank.One), Player.White);

            cb.ApplyMove(move1, true);
            cb.ApplyMove(move2, true);
            cb.ApplyMove(move3, true);
            cb.ApplyMove(move4, true);
            cb.ApplyMove(move5, true);
            cb.ApplyMove(move6, true);

            Assert.True(cb.IsValidMove(move7), "move7 should be valid");
            Assert.True(cb.IsValidMove(move8), "move8 should be valid");
        }
开发者ID:gunr2171,项目名称:Chess.NET,代码行数:22,代码来源:ChessGameTests.cs

示例8: TestInvalidMoveWhitePawn_NoCapture

        public static void TestInvalidMoveWhitePawn_NoCapture()
        {
            ChessGame cb = new ChessGame();
            Move move1 = new Move(new Position(File.E, Rank.Two), new Position(File.E, Rank.Four), Player.White);
            Move move2 = new Move(new Position(File.D, Rank.Seven), new Position(File.D, Rank.Six), Player.Black);
            Move move3 = new Move(new Position(File.E, Rank.Four), new Position(File.D, Rank.Five), Player.White);

            cb.ApplyMove(move1, true);
            cb.ApplyMove(move2, true);

            Assert.False(cb.IsValidMove(move3));
        }
开发者ID:gunr2171,项目名称:Chess.NET,代码行数:12,代码来源:ChessGameTests.cs

示例9: TestBlackNotStalematedAfterApplyMove

        public static void TestBlackNotStalematedAfterApplyMove()
        {
            ChessPiece[][] board  = new ChessPiece[8][]
            {
                new[] { o, o, kw, o, o, o, o, o },
                new[] { kb, o, qw, o, o, o, o, o },
                new[] { o, o, o, o, o, o, o, o },
                new[] { o, o, o, o, o, o, o, o },
                new[] { o, o, o, o, o, o, o, o },
                new[] { o, o, o, o, o, o, o, o },
                new[] { o, o, o, o, o, o, o, o },
                new[] { o, o, o, o, o, o, o, o }
            };
            ChessGame cb = new ChessGame(board, Player.Black);

            Assert.True(cb.ApplyMove(new Move("A7", "A8", Player.Black), false));

            Assert.AreEqual(GameEvent.None, cb.Status.Event);
            Assert.AreEqual(Player.None, cb.Status.PlayerWhoCausedEvent);
            Assert.AreEqual("No special event", cb.Status.EventExplanation);
        }
开发者ID:gunr2171,项目名称:Chess.NET,代码行数:21,代码来源:ChessGameTests.cs

示例10: TestGetValidMovesBlackStartingPosition

        public static void TestGetValidMovesBlackStartingPosition()
        {
            ChessGame cb = new ChessGame();
            cb.ApplyMove(new Move(new Position(File.A, Rank.Two), new Position(File.A, Rank.Three), Player.White), true);
            ReadOnlyCollection<Move> actual = cb.GetValidMoves(Player.Black);
            List<Move> expected = new List<Move>()
            {
                new Move("A7", "A6", Player.Black),
                new Move("A7", "A5", Player.Black),
                new Move("B7", "B6", Player.Black),
                new Move("B7", "B5", Player.Black),
                new Move("C7", "C6", Player.Black),
                new Move("C7", "C5", Player.Black),
                new Move("D7", "D6", Player.Black),
                new Move("D7", "D5", Player.Black),
                new Move("E7", "E6", Player.Black),
                new Move("E7", "E5", Player.Black),
                new Move("F7", "F6", Player.Black),
                new Move("F7", "F5", Player.Black),
                new Move("G7", "G6", Player.Black),
                new Move("G7", "G5", Player.Black),
                new Move("H7", "H6", Player.Black),
                new Move("H7", "H5", Player.Black),
                new Move("B8", "A6", Player.Black),
                new Move("B8", "C6", Player.Black),
                new Move("G8", "F6", Player.Black),
                new Move("G8", "H6", Player.Black)
            };

            Assert.AreEqual(expected.Count, actual.Count);
            foreach (Move move in expected)
            {
                Assert.True(actual.Contains(move), "Actual does not contain " + move.ToString());
            }
        }
开发者ID:gunr2171,项目名称:Chess.NET,代码行数:35,代码来源:ChessGameTests.cs

示例11: TestInvalidMoveBlackPawn_TwoStepsNotOnRankSeven

        public static void TestInvalidMoveBlackPawn_TwoStepsNotOnRankSeven()
        {
            ChessGame cb = new ChessGame();
            Move move1 = new Move(new Position(File.A, Rank.Two), new Position(File.A, Rank.Three), Player.White);
            Move move2 = new Move(new Position(File.E, Rank.Seven), new Position(File.E, Rank.Six), Player.Black);
            Move move3 = new Move(new Position(File.H, Rank.Two), new Position(File.H, Rank.Three), Player.White);
            Move move4 = new Move(new Position(File.E, Rank.Six), new Position(File.E, Rank.Four), Player.Black);

            cb.ApplyMove(move1, true);
            cb.ApplyMove(move2, true);
            cb.ApplyMove(move3, true);

            Assert.False(cb.IsValidMove(move4), "move4 should be invalid");
        }
开发者ID:gunr2171,项目名称:Chess.NET,代码行数:14,代码来源:ChessGameTests.cs

示例12: TestValidMoveBlackPawn_EnPassant

        public static void TestValidMoveBlackPawn_EnPassant()
        {
            ChessGame cb = new ChessGame();
            Move move1 = new Move(new Position(File.B, 1), new Position(File.A, 3), Player.White);
            Move move2 = new Move(new Position(File.E, 7), new Position(File.E, 5), Player.Black);
            Move move3 = new Move(new Position(File.E, 2), new Position(File.E, 3), Player.White);
            Move move4 = new Move(new Position(File.E, 5), new Position(File.E, 4), Player.Black);
            Move move5 = new Move(new Position(File.D, 2), new Position(File.D, 4), Player.White);
            Move move6 = new Move(new Position(File.E, 4), new Position(File.D, 3), Player.Black);

            cb.ApplyMove(move1, true);
            cb.ApplyMove(move2, true);
            cb.ApplyMove(move3, true);
            cb.ApplyMove(move4, true);
            cb.ApplyMove(move5, true);

            Assert.True(cb.IsValidMove(move6));
        }
开发者ID:ProgramFOX,项目名称:Chess.NET,代码行数:18,代码来源:ChessGameTests.cs

示例13: TestValidMoveBlackPawn_2Steps

        public static void TestValidMoveBlackPawn_2Steps()
        {
            ChessGame cb = new ChessGame();
            cb.ApplyMove(new Move(new Position(File.A, 2), new Position(File.A, 3), Player.White), true);

            Move move1 = new Move(new Position(File.D, 7), new Position(File.D, 5), Player.Black);

            Assert.True(cb.IsValidMove(move1), "move1 should be valid");
        }
开发者ID:ProgramFOX,项目名称:Chess.NET,代码行数:9,代码来源:ChessGameTests.cs

示例14: TestInvalidMoveWhiteKing_KingsideCastling_KingMoved

        public static void TestInvalidMoveWhiteKing_KingsideCastling_KingMoved()
        {
            Piece[][] board = new Piece[8][]
            {
                new[] { o, kb, o, o, o, o, o, o },
                new[] { o, o, o, o, o, o, o, o },
                new[] { o, o, o, o, o, o, o, o },
                new[] { o, o, o, o, o, o, o, o },
                new[] { o, o, o, o, o, o, o, o },
                new[] { o, o, o, o, o, o, o, o },
                new[] { o, o, o, o, o, o, o, o },
                new[] { o, o, o, o, kw, o, o, rw }
            };
            ChessGame cb = new ChessGame(board, Player.White);
            Move move1 = new Move(new Position(File.E, 1), new Position(File.D, 1), Player.White);
            Move move2 = new Move(new Position(File.B, 8), new Position(File.B, 7), Player.Black);
            Move move3 = new Move(new Position(File.D, 1), new Position(File.F, 1), Player.White);

            cb.ApplyMove(move1, true);
            cb.ApplyMove(move2, true);

            Assert.False(cb.IsValidMove(move3), "move3 should be invalid");
        }
开发者ID:ProgramFOX,项目名称:Chess.NET,代码行数:23,代码来源:ChessGameTests.cs

示例15: TestValidMoveWhiteKingVertical

        public static void TestValidMoveWhiteKingVertical()
        {
            ChessGame cb = new ChessGame();
            Move move1 = new Move(new Position(File.E, 2), new Position(File.E, 3), Player.White);
            Move move2 = new Move(new Position(File.A, 7), new Position(File.A, 6), Player.Black);
            Move move3 = new Move(new Position(File.E, 1), new Position(File.E, 2), Player.White);

            cb.ApplyMove(move1, true);
            cb.ApplyMove(move2, true);

            Assert.True(cb.IsValidMove(move3), "move3 should be valid");
        }
开发者ID:ProgramFOX,项目名称:Chess.NET,代码行数:12,代码来源:ChessGameTests.cs


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