• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ChessPiece类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ChessPiece的典型用法代码示例。如果您正苦于以下问题:C# ChessPiece类的具体用法?C# ChessPiece怎么用?C# ChessPiece使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ChessPiece类属于命名空间,在下文中一共展示了ChessPiece类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: getNotation

            public override string getNotation(ChessSide side,
							    ChessPiece[,]
							    positions, int sr,
							    int sf, int dr,
							    int df,
							    PromotionType
							    promotion_type)
            {
                string str;
                if (sf == df)
                  {
                      str = "" + (char) ('a' + df) + (dr +
                                      1);
                  }
                else
                  {
                      str = "" + (char) ('a' + sf);
                      if (positions[dr, df] != null)
                          str += 'x';
                      str += "" + (char) ('a' + df) +
                          (dr + 1);
                  }
                if (dr == 7 || dr == 0)
                  {
                      /* No need to verify for specific colors
                       * only whites can reach 7 and blacks can reach 0
                       */
                      str += ChessPiece.
                          getPromotionString
                          (promotion_type);
                  }
                return str;
            }
开发者ID:BackupTheBerlios,项目名称:csboard-svn,代码行数:33,代码来源:Pawn.cs


示例2: IsReady

    ///////////////////////////////////////////////////////////////////////////
    public override bool IsReady()
    {
        potentialTargets = new ArrayList ();

        foreach (ChessPiece player1Piece in scenario.GetAllChessPiecesForPlayer(1)) {
                    foreach (ChessPiece player2Piece in scenario.GetAllChessPiecesForPlayer(2)) {
                            if (player1Piece.CanCaptureXY (player2Piece.x, player2Piece.y))
                                    potentialTargets.Add (player1Piece);
                    }
            }

            int targetValue = 0;

            foreach (ChessPiece piece in potentialTargets) {
                    if (piece.GetValue () > targetValue) {
                            targetValue = piece.GetValue ();
                            targetChessPiece = piece;
                    }
            }

            if (targetChessPiece == null)
        {
            return false;
        }
        else
        {

             potentialPlacesToMoveTarget = new ArrayList ();

            foreach (PotentialMove move in targetChessPiece.GetMoveList())
            {
                //Debug.Log (player2Piece.gameObject.name + ": Has " + player2Piece.GetMoveList().Count + " potential moves");
                //int goodmoves = 0;

                foreach (ChessPiece player2Piece in scenario.GetAllChessPiecesForPlayer(2)) 				{
                    //Debug.Log ("checked" + counter + "moves");

                    if (player2Piece.CanCaptureChessPieceIfItMovedToXY (targetChessPiece, move.x, move.y))
                    {
                        if (GameObject.FindGameObjectWithTag ("Scenario").GetComponent<Scenario> ().GetPieceAtXY (move.x, move.y) == null)
                        {
                            //goodmoves++;
                            potentialPlacesToMoveTarget.Add (move);
                            Debug.Log(potentialPlacesToMoveTarget.Count);

                        }
                    }

                }

                //	Debug.Log (player2Piece.gameObject.name + ": Potential Places to Move Target: " + goodmoves);
            }
        }
                    if(potentialPlacesToMoveTarget.Count > 0){
                return true;
            }
             else {
                    return false;
            }
    }
开发者ID:porfa,项目名称:Cole_Warren_Scripting_Examples,代码行数:61,代码来源:BA_Dominate.cs


示例3: ChessPieceViewModel

 public ChessPieceViewModel(ChessPiece i_ChessPiece, PieceColor i_PieceColor, PieceSide i_PieceSide, int i_File, int i_Rank)
 {
     ChessCoord tempChessCoord = new ChessCoord();
     tempChessCoord.File = i_File;
     tempChessCoord.Rank = i_Rank;
     m_ChessPieceModel = new ChessPieceModel(i_ChessPiece, i_PieceColor, i_PieceSide, tempChessCoord);
 }
开发者ID:SpectralCoding,项目名称:chess-ai,代码行数:7,代码来源:ChessPieceViewModel.cs


示例4: IsReady

    ///////////////////////////////////////////////////////////////////////////
    public override bool IsReady()
    {
        potentialTargets = new ArrayList ();

        foreach (ChessPiece player1Piece in scenario.GetAllChessPiecesForPlayer(1)) {
            foreach (ChessPiece player2Piece in scenario.GetAllChessPiecesForPlayer(2)) {
                if (player1Piece.CanCaptureXY (player2Piece.x, player2Piece.y) && !player1Piece.IsDepressed())
                {
                    potentialTargets.Add (player1Piece);
                }
            }
        }

        int targetValue = 0;

        foreach (ChessPiece piece in potentialTargets) {
            if (piece.GetValue () > targetValue) {
                targetValue = piece.GetValue ();
                targetChessPiece = piece;
            }
        }

        if (targetChessPiece == null)
        {
            return false;
        }
        else
        {
            return true;

        }
    }
开发者ID:porfa,项目名称:Cole_Warren_Scripting_Examples,代码行数:33,代码来源:BA_Gloom.cs


示例5: isValidMove

            public override bool isValidMove(int i, int j,
							  ChessPiece[,]
							  positions,
							  int flags)
            {
                if (!base.
                    isValidMove (i, j, positions, flags))
                    return false;
                int r_diff = i - rank;
                int f_diff = j - file;

                if (r_diff < 0)
                    r_diff = -r_diff;
                if (f_diff < 0)
                    f_diff = -f_diff;

                if (r_diff < 2 && f_diff < 2)
                    return true;

                //                if( castling ) {
                //                        if( file == ChessBoardConstants.e && j == ChessBoardConstants.g )
                //                                return true;
                //                        if( file == ChessBoardConstants.e && j == ChessBoardConstants.c )
                //                                return true;
                //                }

                return false;
            }
开发者ID:BackupTheBerlios,项目名称:csboard-svn,代码行数:28,代码来源:King.cs


示例6: SetPiece

 public void SetPiece( ChessPiece chessPiece )
 {
     this.gameObject = chessPiece.gameObject;
     this.playerSide = chessPiece.playerSide;
     this.pieceType = chessPiece.pieceType;
     this.piecePlayerType = chessPiece.piecePlayerType;
 }
开发者ID:chichikov,项目名称:chichikov76,代码行数:7,代码来源:ChessPiece.cs


示例7: ChessBoard

        /// <summary>
        /// Helper constructor that creates a new chess board based off of a Fen string.
        /// </summary>
        /// <param name="fenBoard">The Fen string that represents the board.</param>
        public ChessBoard(string fenBoard)
        {
            Profiler.AddToMainProfile((int)ProfilerMethodKey.ChessBoard_ctor_string);
            Board = new ChessPiece[NumberOfRows, NumberOfColumns];

            FromFenBoard(fenBoard);
        }
开发者ID:rafalima87,项目名称:Chess,代码行数:11,代码来源:ChessBoard.cs


示例8: CopyFrom

 public void CopyFrom( ChessPiece chessPiece )
 {
     this.gameObject = chessPiece.gameObject;
     this.playerSide = chessPiece.playerSide;
     this.pieceType = chessPiece.pieceType;
     this.piecePlayerType = chessPiece.piecePlayerType;
     this.bEnPassantCapture = chessPiece.bEnPassantCapture;
 }
开发者ID:chichikov,项目名称:chichikov,代码行数:8,代码来源:ChessPiece.cs


示例9: Evaluate

        protected override Int32 Evaluate(ChessBoard myBoard, ChessPiece turn, Int16 depth)
        {
            IncrementSearchCount();
            var materialValue = (turn == ChessPiece.White ? 1 : -1) * myBoard.GetMaterialValue(this.ChessPieceRelativeValues, depth);
            var positionalValue = (turn == ChessPiece.White ? 1 : -1) * myBoard.GetPositionalValue();

            return MaterialFactor * materialValue + PositionalFactor * positionalValue;
        }
开发者ID:ThorMutoAsmund,项目名称:BasicChess,代码行数:8,代码来源:BreadthFirst.cs


示例10: ChessBoardSquare

    public ChessBoardSquare( ChessPiece piece, ParticleSystem moveablePSystem, int nPile, int nRank )
    {
        this.position = new ChessPosition( nRank, nPile );
        this.piece = piece;
        if( this.piece != null )
            this.piece.SetPosition( this.position.Get3DPosition() );

        SetMovableEffect( moveablePSystem );
    }
开发者ID:chichikov,项目名称:chichikov76,代码行数:9,代码来源:ChessBoardSquare.cs


示例11: getNotation

            public override string getNotation(ChessSide side,
							    ChessPiece[,]
							    positions, int sr,
							    int sf, int dr,
							    int df,
							    PromotionType
							    promotion)
            {
                return "K" + (char) ('a' + df) + (dr + 1);
            }
开发者ID:BackupTheBerlios,项目名称:csboard-svn,代码行数:10,代码来源:King.cs


示例12: GetRelativePaths

        public List<Tuple<int, int>[]> GetRelativePaths(ChessPiece p)
        {
            int direction = p.Direction;

            return new List<Tuple<int, int>[]>()
            {
                new[] { new Tuple<int, int>(direction, -1), },
                new[] { new Tuple<int, int>(direction, 0), },
                new[] { new Tuple<int, int>(direction * 2, 0), },
                new[] { new Tuple<int, int>(direction, 1) },
            };
        }
开发者ID:nannanbatman,项目名称:chess,代码行数:12,代码来源:PawnRelativePathProvider.cs


示例13: GetRelativePaths

        public List<Tuple<int, int>[]> GetRelativePaths(ChessPiece p)
        {
            var l = new List<Tuple<int, int>[]>();

            foreach (var subPath in new RookRelativePathProvider().GetRelativePaths(p))
                l.Add(subPath);

            foreach (var subPath in new BishopRelativePathProvider().GetRelativePaths(p))
                l.Add(subPath);

            return l;
        }
开发者ID:nannanbatman,项目名称:chess,代码行数:12,代码来源:QueenRelativePathProvider.cs


示例14: TestEquality

 public static void TestEquality()
 {
     ChessPiece piece1 = new ChessPiece(Piece.King, Player.White);
     ChessPiece piece2 = new ChessPiece(Piece.King, Player.White);
     Assert.AreEqual(piece1, piece2, "piece1 and piece2 are not equal");
     Assert.True(piece1.Equals(piece2), "piece1.Equals(piece2) should be True");
     Assert.True(piece2.Equals(piece1), "piece2.Equals(piece1) should be True");
     Assert.True(piece1 == piece2, "piece1 == piece2 should be True");
     Assert.True(piece2 == piece1, "piece2 == piece1 should be True");
     Assert.False(piece1 != piece2, "piece1 != piece2 should be false");
     Assert.False(piece2 != piece1, "piece2 != piece1 should be false");
     Assert.AreEqual(piece1.GetHashCode(), piece2.GetHashCode(), "Hash codes are different");
 }
开发者ID:gunr2171,项目名称:Chess.NET,代码行数:13,代码来源:ChessPieceTests.cs


示例15: TestInequality_DifferentPieceAndPlayer

 public static void TestInequality_DifferentPieceAndPlayer()
 {
     ChessPiece piece1 = new ChessPiece(Piece.King, Player.White);
     ChessPiece piece2 = new ChessPiece(Piece.Queen, Player.Black);
     Assert.AreNotEqual(piece1, piece2, "piece1 and piece2 are equal");
     Assert.False(piece1.Equals(piece2), "piece1.Equals(piece2) should be false");
     Assert.False(piece2.Equals(piece1), "piece2.Equals(piece1) should be false");
     Assert.False(piece1 == piece2, "piece1 == piece2 should be false");
     Assert.False(piece2 == piece1, "piece2 == piece1 should be false");
     Assert.True(piece1 != piece2, "piece1 != piece2 should be True");
     Assert.True(piece2 != piece1, "piece2 != piece1 should be True");
     Assert.AreNotEqual(piece1.GetHashCode(), piece2.GetHashCode(), "Hash codes are equal");
 }
开发者ID:gunr2171,项目名称:Chess.NET,代码行数:13,代码来源:ChessPieceTests.cs


示例16: TestThrowIfNull

        public static void TestThrowIfNull()
        {
            Assert.Throws<ArgumentNullException>(delegate ()
            {
                object value = null;
                Utilities.ThrowIfNull(value, "value");
            });

            Assert.DoesNotThrow(delegate ()
            {
                ChessPiece piece = new ChessPiece(Piece.Bishop, Player.White);
                Utilities.ThrowIfNull(piece, "piece");
            });
        }
开发者ID:gunr2171,项目名称:Chess.NET,代码行数:14,代码来源:UtilitiesTests.cs


示例17: GetRelativePaths

 public List<Tuple<int, int>[]> GetRelativePaths(ChessPiece p)
 {
     return new List<Tuple<int, int>[]>()
     {
         new[] { new Tuple<int, int>(-2, -1), },
         new[] { new Tuple<int, int>(-2, 1), },
         new[] { new Tuple<int, int>(-1, 2), },
         new[] { new Tuple<int, int>(1, 2) },
         new[] { new Tuple<int, int>(2, 1) },
         new[] { new Tuple<int, int>(2, -1) },
         new[] { new Tuple<int, int>(1, -2) },
         new[] { new Tuple<int, int>(-1, -2) },
     };
 }
开发者ID:nannanbatman,项目名称:chess,代码行数:14,代码来源:KnightRelativePathProvider.cs


示例18: isValidMove

            public override bool isValidMove(int i, int j,
							  ChessPiece[,]
							  positions,
							  int flags)
            {
                if (!base.
                    isValidMove (i, j, positions, flags))
                    return false;

                int tmp_r = rank, tmp_f = file;
                int rinc, finc, rdiff, fdiff;
                if (rank < i)
                  {
                      rinc = 1;
                      rdiff = i - rank;
                  }
                else
                  {
                      rinc = -1;
                      rdiff = rank - i;
                  }

                if (file < j)
                  {
                      finc = 1;
                      fdiff = j - file;
                  }
                else
                  {
                      finc = -1;
                      fdiff = file - j;
                  }

                if (rdiff != fdiff)
                    return false;

                for (int dist = rdiff - 1; dist > 0; dist--)
                  {
                      tmp_r += rinc;
                      tmp_f += finc;
                      if (positions[tmp_r, tmp_f] != null)
                        {
                            return false;
                        }
                  }

                return true;
            }
开发者ID:BackupTheBerlios,项目名称:csboard-svn,代码行数:48,代码来源:Bishop.cs


示例19: isPawnPromotion

            public static bool isPawnPromotion(ChessPiece piece,
							    int file)
            {
                if (piece.Type != PieceType.PAWN)
                    return false;

                if (piece.Color == ColorType.WHITE
                    && file == 7)
                    return true;

                if (piece.Color == ColorType.BLACK
                    && file == 0)
                    return true;

                return false;
            }
开发者ID:BackupTheBerlios,项目名称:csboard-svn,代码行数:16,代码来源:Utils.cs


示例20: ChessPieceModel

 public ChessPieceModel(ChessPiece i_ChessPiece, PieceColor i_PieceColor, PieceSide i_PieceSide, ChessCoord i_ChessCoord)
 {
     ChessPiece = i_ChessPiece;
     PieceColor = i_PieceColor;
     PieceSide = i_PieceSide;
     ChessCoord = i_ChessCoord;
     string PieceColorStr;
     if (i_PieceColor == PieceColor.White) { PieceColorStr = "White"; } else { PieceColorStr = "Black"; }
     switch (i_ChessPiece) {
         case ChessPiece.King: ResourceURI = @"/ChessAI;component/Resources/Pieces/" + PieceColorStr + "_King.png"; break;
         case ChessPiece.Queen: ResourceURI = @"/ChessAI;component/Resources/Pieces/" + PieceColorStr + "_Queen.png"; break;
         case ChessPiece.Bishop: ResourceURI = @"/ChessAI;component/Resources/Pieces/" + PieceColorStr + "_Bishop.png"; break;
         case ChessPiece.Knight: ResourceURI = @"/ChessAI;component/Resources/Pieces/" + PieceColorStr + "_Knight.png"; break;
         case ChessPiece.Rook: ResourceURI = @"/ChessAI;component/Resources/Pieces/" + PieceColorStr + "_Rook.png"; break;
         case ChessPiece.Pawn: ResourceURI = @"/ChessAI;component/Resources/Pieces/" + PieceColorStr + "_Pawn.png"; break;
     }
 }
开发者ID:SpectralCoding,项目名称:chess-ai,代码行数:17,代码来源:ChessPieceModel.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Child类代码示例发布时间:2022-05-24
下一篇:
C# ChessGame类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap