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


C# PieceColor类代码示例

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


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

示例1: SendInitializeCommonPiece

 public void SendInitializeCommonPiece(BoardPosition position, PieceColor color)
 {
     foreach (var subscriber in this._subscribers)
     {
         subscriber.InitializeCommonPiece(position, color);
     }
 }
开发者ID:nucleuskhn,项目名称:ucs-xna-rmi-draughts-server,代码行数:7,代码来源:DraughtsManager.cs

示例2: GetAllAvailableMoves

        // returns all the available moves for a given color
        public List<MoveResult> GetAllAvailableMoves(PieceColor color)
        {
            var availables = new List<MoveResult>();
            var listToCheck = color == PieceColor.Black ? Pieces.AlivePlayerOnePieces : Pieces.AlivePlayerTwoPieces;

            bool anyJumps;
            //for every living piece of said color
            for (var i = 0; i < listToCheck.Count; i++)
            {
                var piece = listToCheck[i];
                anyJumps = false;
                for (var j = 0; j < availables.Count; j++)
                {
                    //if any current available moves are a jump, then all future moves are invalid unless they are a jump - force only jump moves
                    var m = availables[j];
                    if (m.Type == MoveType.Jump) //if the
                    {
                        anyJumps = true;
                        break;
                    }
                }

                //append the available moves onto the list
                availables.AddRange(GetAvailableMovesForPiece(piece, anyJumps));
            }

            // if there are any jumps, you must take a jump
            if(availables.Any(m => m.Type == MoveType.Jump))
               availables.RemoveAll(m => m.Type != MoveType.Jump);

            return availables;
        }
开发者ID:mohammedh123,项目名称:ProjectAlphaBeta,代码行数:33,代码来源:CheckersBoard.cs

示例3: CheckForCapture

        private void CheckForCapture(char leftX, char rightX, char y, PieceColor color)
        {
            if (this.Board.IsOccupiedSquare(leftX, y, color))
            {
                this.AddValidMove(leftX, y, true);
            }

            if (this.Board.IsOccupiedSquare(rightX, y, color))
            {
                this.AddValidMove(rightX, y, true);
            }

            // En Passant
            if (this.Board.EnPassantSquare != null)
            {
                if (this.Board.EnPassantSquare.X == leftX && this.Board.EnPassantSquare.Y == y)
                {
                    this.AddValidMove(leftX, y, true, this.Board[leftX, this.Square.Y].Piece);
                }

                if (this.Board.EnPassantSquare.X == rightX && this.Board.EnPassantSquare.Y == y)
                {
                    this.AddValidMove(rightX, y, true, this.Board[rightX, this.Square.Y].Piece);
                }
            }
        }
开发者ID:pberton,项目名称:deepAzure,代码行数:26,代码来源:PiecePawn.cs

示例4: Move

        public Move(PieceColor color, BoardPosition initialPosition, BoardPosition endingPosition, bool pieceJumped = false, bool pieceCaptured = false)
        {
            if (initialPosition.ContainsPiece())
            {
                throw new ArgumentException("Move initial posiiton must not contain a piece");
            }

            if (endingPosition.ContainsPiece())
            {
                throw new ArgumentException("Move ending posiiton must not contain a piece");
            }

            if (pieceCaptured && !pieceJumped)
            {
                throw new ArgumentException("Capture moves are required to be configured as a jump move");
            }

            if (!ValidateMove(initialPosition, endingPosition, pieceJumped, pieceCaptured))
            {
                throw new ArgumentException("Invalid move requested");
            }

            this.PieceColor = color;
            this.PieceJumped = pieceJumped;
            this.PieceCaptured = pieceCaptured;
            this.InitialPosition = initialPosition;
            this.EndingPosition = endingPosition;
        }
开发者ID:chadqueen,项目名称:QueensDuel,代码行数:28,代码来源:Move.cs

示例5: Piece

        public Piece(PieceType type, PieceColor color, int col, int row, Board board)
        {
            this.Col = col;
            this.Row = row;
            this.X = col * Game.TILESIZE;
            this.Y =  row * Game.TILESIZE;
            this.Color = color;
            this.Board = board;
            FirstMove = true;
            SetType(type);

            this.MouseDown += delegate(object s, MouseButtonEventArgs ev) {
                if (!Game.GameOver && ((!Game.IsConnected && Game.MyTurn(Color)) ||
                    (Game.IsConnected && Game.MainColor == Color && Game.MyTurn())))
                {
                    dragging = true;
                    this.Cursor = Cursors.Hand;
                    System.Windows.Controls.Canvas.SetZIndex(this, 1000);
                }
            };

            this.MouseUp += new MouseButtonEventHandler(image_MouseUp);

            this.MouseMove += new MouseEventHandler(image_MouseMove);

            this.MouseLeave += new MouseEventHandler(image_MouseMove);
        }
开发者ID:jluispcardenas,项目名称:ChessTest,代码行数:27,代码来源:Piece.cs

示例6: AssertPieceLoaded

 private void AssertPieceLoaded(IEngine engine, string coord, Type type, PieceColor color)
 {
     var piece = engine.Board[coord].Piece;
     Assert.IsNotNull(piece);
     Assert.AreEqual(color, piece.Color);
     Assert.IsInstanceOfType(piece, type);
 }
开发者ID:pberton,项目名称:deepAzure,代码行数:7,代码来源:BasicEngineTests.cs

示例7: Pawn

        /// <summary>
        /// Initializes a new instance of the Pawn class.
        /// </summary>
        /// <param name="color">Color, white or black, the piece represents.</param>
        public Pawn(PieceColor color)
        {
            m_iterator = new BoardIterator(null, Square.None, Direction.NoDirection);

              if (color == PieceColor.White)
              {
            m_color = PieceColor.White;
            m_opponentColor = PieceColor.Black;

            m_directions[0] = Direction.Up;
            m_directions[1] = Direction.UpLeft;
            m_directions[2] = Direction.UpRight;

            moveAgainRow = 2;
              }

              if (color == PieceColor.Black)
              {
            m_color = PieceColor.Black;
            m_opponentColor = PieceColor.White;

            m_directions[0] = Direction.Down;
            m_directions[1] = Direction.DownLeft;
            m_directions[2] = Direction.DownRight;

            moveAgainRow = 5;
              }
        }
开发者ID:prezz,项目名称:Firoz-Chess,代码行数:32,代码来源:Pawn.cs

示例8: GetConsecutiveLines

        private static Lines GetConsecutiveLines(Connect4Board b, PieceColor color, int col, Connect4Column move)
        {
            int horizontal = 1, vertical = 1, mainDiagonal = 1, antiDiagonal = 1;
            int nextX, nextY;

            for (nextX = col + 1, nextY = move.LastDropRow; nextX < Connect4Board.COLUMNS && b.GetPiece(nextY, nextX) == color; nextX++)
                horizontal++;
            for (nextX = col - 1; nextX >= 0 && b.GetPiece(nextY, nextX) == color; nextX--)
                horizontal++;

            for (nextX = col, nextY = move.LastDropRow + 1; nextY < Connect4Board.ROWS && b.GetPiece(nextY, nextX) == color; nextY++)
                vertical++;
            for (nextX = col, nextY = move.LastDropRow - 1; nextY >= 0 && b.GetPiece(nextY, nextX) == color; nextY--)
                vertical++;

            for (nextX = col + 1, nextY = move.LastDropRow + 1; nextX < Connect4Board.COLUMNS && nextY < Connect4Board.ROWS && b.GetPiece(nextY, nextX) == color; nextX++, nextY++)
                mainDiagonal++;
            for (nextX = col - 1, nextY = move.LastDropRow - 1; nextX >= 0 && nextY >= 0 && b.GetPiece(nextY, nextX) == color; nextX--, nextY--)
                mainDiagonal++;

            for (nextX = col + 1, nextY = move.LastDropRow - 1; nextX < Connect4Board.COLUMNS && nextY >= 0 && b.GetPiece(nextY, nextX) == color; nextX++, nextY--)
                antiDiagonal++;
            for (nextX = col - 1, nextY = move.LastDropRow + 1; nextX >= 0 && nextY < Connect4Board.ROWS && b.GetPiece(nextY, nextX) == color; nextX--, nextY++)
                antiDiagonal++;

            return new Lines(horizontal, vertical, mainDiagonal, antiDiagonal);
        }
开发者ID:Kevin-Jin,项目名称:kvj-board-games,代码行数:27,代码来源:GameLogic.cs

示例9: Eval

        public double Eval(CheckersBoard board, int level, PieceColor playerColor)
        {
            {
                double eval = 0;

                for (int x = 0; x < board.Width; x++)
                    for (int y = 0; y < board.Height; y++)
                    {
                        var piece = board.GetPieceAt(x, y) as CheckersPiece;
                        if (piece != null)
                        {
                            if (piece.Color == playerColor)
                            {
                                if (piece is Pawn) eval += _ownPawnStrength;
                                else if (piece is Queen) eval += _ownQueenStrength;
                            }
                            else
                            {
                                if (piece is Pawn) eval -= _ownPawnStrength;
                                else if (piece is Queen) eval -= _ownQueenStrength;
                            }
                        }
                    }

                return eval;
            }
        }
开发者ID:Bajena,项目名称:Checkers,代码行数:27,代码来源:PawnStrengthBoardEvaluator.cs

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

示例11: Piece

        /// <summary>
        /// Instantiate <see cref="Piece"/>
        /// </summary>
        /// <param name="type"><see cref="Type"/></param>
        /// <param name="color"><see cref="Color"/></param>
        public Piece(PieceType type, PieceColor color)
        {
            _type = type;
            _color = color;

            Moves = new List<Move>();
            Attacked = new List<Square>();
        }
开发者ID:gabehaack,项目名称:Chess,代码行数:13,代码来源:Piece.cs

示例12: Piece

        public Piece(Square position, Board board, PieceColor color)
        {
            this.position = position;
            this.board = board;
            this.color = color;

            this.board.Squares[position] = this;
        }
开发者ID:AGRocks,项目名称:chezzles,代码行数:8,代码来源:Piece.cs

示例13: Whether_Rook_CantJumpOverAnotherPiece_On_CanMoveTo

        public void Whether_Rook_CantJumpOverAnotherPiece_On_CanMoveTo(PieceColor pieceColor)
        {
            var board = new Board();
            var rook = new Rook(new Square(4, 4), board, PieceColor.White);
            var knight = new Knight(new Square(4, 5), board, pieceColor);

            Assert.That(rook.CanMoveTo(new Square(4, 6)), Is.False);
        }
开发者ID:AGRocks,项目名称:chezzles,代码行数:8,代码来源:RookTests.cs

示例14: Piece

 public Piece(bool belongsToPlayerTwo, Point position, PieceColor color, int sumoness)
 {
     BelongsToPlayerTwo = belongsToPlayerTwo;
     Position = position;
     Color = color;
     MaxMoveLength = 7 - 2 * sumoness;
     Sumoness = sumoness;
 }
开发者ID:vfarcy,项目名称:Kamisado,代码行数:8,代码来源:Piece.cs

示例15: FixedDepthPlayer

 public FixedDepthPlayer(PieceColor c, int depth)
     : base(c)
 {
     if (depth >= 0)
         maxDepth = depth;
     else
         throw new ArgumentException("Depth must be at least 0");
 }
开发者ID:latkin,项目名称:pentagoag,代码行数:8,代码来源:FixedDepthPlayer.cs


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