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


C# ChessPiece类代码示例

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


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


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