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


C# ChessGame.IsValidMove方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: TestValidMoveWhiteKing_QueensideCastling_WouldNotPassThroughCheck

        public static void TestValidMoveWhiteKing_QueensideCastling_WouldNotPassThroughCheck()
        {
            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, rb, 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.C, Rank.One), Player.White);

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

示例6: 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

示例7: TestInvalidMoveWhitePawn_TwoStepsNotOnRankTwo

        public static void TestInvalidMoveWhitePawn_TwoStepsNotOnRankTwo()
        {
            ChessGame cb = new ChessGame();
            Move move1 = new Move(new Position(File.E, Rank.Two), new Position(File.E, Rank.Three), Player.White);
            Move move2 = new Move(new Position(File.E, Rank.Three), new Position(File.E, Rank.Five), Player.White);

            cb.ApplyMove(move1, true);

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

示例8: TestValidMoveBlackKing_QueensideCastling

        public static void TestValidMoveBlackKing_QueensideCastling()
        {
            ChessPiece[][] board  = new ChessPiece[8][]
            {
                new[] { rb, o, o, o, kb, 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, o }
            };
            ChessGame cb = new ChessGame(board, Player.Black);
            Move move1 = new Move(new Position(File.E, Rank.Eight), new Position(File.C, Rank.Eight), Player.Black);

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

示例9: TestValidMoveBlackKing_KingsideCastling_WouldNotPassThroughCheck

        public static void TestValidMoveBlackKing_KingsideCastling_WouldNotPassThroughCheck()
        {
            ChessPiece[][] board  = new ChessPiece[8][]
            {
                new[] { o, o, o, o, kb, o, o, rb },
                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.Black);
            Move move1 = new Move(new Position(File.E, Rank.Eight), new Position(File.G, Rank.Eight), Player.Black);

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

示例10: TestValidMoveBlackQueenDiagonal

        public static void TestValidMoveBlackQueenDiagonal()
        {
            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.D, Rank.Eight), new Position(File.H, Rank.Four), Player.Black);

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

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

示例11: TestValidMoveBlackKingHorizontal

        public static void TestValidMoveBlackKingHorizontal()
        {
            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.D, Rank.Seven), new Position(File.D, 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.D, Rank.Eight), new Position(File.D, Rank.Seven), Player.Black);
            Move move5 = new Move(new Position(File.B, Rank.Two), new Position(File.B, Rank.Three), Player.White);
            Move move6 = new Move(new Position(File.E, Rank.Eight), new Position(File.D, Rank.Eight), 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), "move6 should be valid");
        }
开发者ID:gunr2171,项目名称:Chess.NET,代码行数:18,代码来源:ChessGameTests.cs

示例12: TestValidMoveBlackKnight

        public static void TestValidMoveBlackKnight()
        {
            ChessGame cb = new ChessGame();
            cb.ApplyMove(new Move(new Position(File.A, Rank.Two), new Position(File.A, Rank.Three), Player.White), true);

            Move move1 = new Move(new Position(File.B, Rank.Eight), new Position(File.C, Rank.Six), Player.Black);

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

示例13: 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

示例14: 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

示例15: TestValidMoveWhitePawn_TwoSteps

        public static void TestValidMoveWhitePawn_TwoSteps()
        {
            ChessGame cb = new ChessGame();

            Move move1 = new Move(new Position(File.D, Rank.Two), new Position(File.D, Rank.Four), Player.White);

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


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