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

C# PieceColor类代码示例

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

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



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


示例16: FixedTimePlayer

 public FixedTimePlayer(PieceColor c, int thinkTimeSeconds)
     : base(c)
 {
     if (thinkTimeSeconds > 0)
         this.thinkTimeSeconds = thinkTimeSeconds;
     else
         throw new ArgumentException("Think time must be greater than 0");
 }
开发者ID:latkin,项目名称:pentagoag,代码行数:8,代码来源:FixedTimePlayer.cs


示例17: Whether_Queen_CantJumpOverAnotherPiece_On_CanMoveTo

        public void Whether_Queen_CantJumpOverAnotherPiece_On_CanMoveTo(PieceColor pieceColor)
        {
            var board = new Board();
            var queen = new Queen(new Square(4, 4), board, PieceColor.White);
            var knight = new Knight(new Square(5, 5), board, pieceColor);

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


示例18: PgnMove

        public PgnMove(string pgnString)
        {
            Match m = r.Match(pgnString);

              if (m.Groups["Move"].Value == "")
              {
            ColorToPlay = PieceColor.Black;
              }
              else
              {
            ColorToPlay = PieceColor.White;
              }

              if (m.Groups["Castling"].Value == "")
              {
            PieceToPlay = StringToPiece(m.Groups["Piece"].Value, ColorToPlay);
            FromFile = StringToFile(m.Groups["File"].Value);
            FromRank = StringToRank(m.Groups["Rank"].Value);
            DestinationSquare = StringToSquare(m.Groups["Destination"].Value);
            PromotionPiece = StringToPromotion(m.Groups["Promotion"].Value);
              }
              else if (m.Groups["Castling"].Value == "O-O")
              {
            if (ColorToPlay == PieceColor.White)
            {
              DestinationSquare = Square.G1;
              PieceToPlay = Piece.WhiteKing;
              FromFile = 4;
              FromRank = 0;
            }

            if (ColorToPlay == PieceColor.Black)
            {
              DestinationSquare = Square.G8;
              PieceToPlay = Piece.BlackKing;
              FromFile = 4;
              FromRank = 7;
            }
              }
              else if (m.Groups["Castling"].Value == "O-O-O")
              {
            if (ColorToPlay == PieceColor.White)
            {
              DestinationSquare = Square.C1;
              PieceToPlay = Piece.WhiteKing;
              FromFile = 4;
              FromRank = 0;
            }

            if (ColorToPlay == PieceColor.Black)
            {
              DestinationSquare = Square.C8;
              PieceToPlay = Piece.BlackKing;
              FromFile = 4;
              FromRank = 7;
            }
              }
        }
开发者ID:prezz,项目名称:Firoz-Chess,代码行数:58,代码来源:PgnMove.cs


示例19: Eval

        public double Eval(CheckersBoard board, int level, PieceColor playerColor)
        {
            {
                double myval = 0;
                double enemyval = 0;
                for (int x = 0; x < board.Width; x++)
                    for (int y = 0; y < board.Height; y++)
                    {
                        CheckersPiece piece = board.GetPieceAt(x, y) as CheckersPiece;
                        if (piece != null)
                        {
                            int factor = (piece.Color == PieceColor.White) ? (7 - y) : (y);
                            if (piece.Color == playerColor)
                            {
                                if (piece is Pawn) myval += 100 + (factor * factor);
                                else
                                {

                                    myval += 200;
                                    if (y == 0)
                                    {
                                        if (x == 0) myval -= 40;
                                        else myval -= 20;
                                    }
                                    else if (y == 7)
                                    {
                                        if (x == 7) myval -= 40;
                                        else myval -= 20;
                                    }
                                }
                            }
                            else
                            {
                                if (piece is Pawn) enemyval += 100 + (factor * factor);
                                else
                                {
                                    enemyval += 200;
                                    if (y == 0)
                                    {
                                        if (x == 0) enemyval -= 40;
                                        else enemyval -= 20;
                                    }
                                    else if (y == 7)
                                    {
                                        if (x == 7) enemyval -= 40;
                                        else enemyval -= 20;
                                    }
                                }
                            }
                        }
                    }

                if (enemyval == 0) return 100000 + level * level;
                else if (myval == 0) return -100000 - level * level;
                return (myval - enemyval);
            }
        }
开发者ID:Bajena,项目名称:Checkers,代码行数:57,代码来源:SimpleHeuristicBoardEvaluator.cs


示例20: CalculateValidMoves

 public void CalculateValidMoves(PieceColor playerColor)
 {
     // TODO: Parallel.ForEach<PieceBase>(this.Pieces, p => p.CalculateValidMoves());
     foreach (PieceBase piece in this.Pieces)
     {
         if (piece.Color == playerColor)
             piece.CalculateValidMoves();
     }
 }
开发者ID:pberton,项目名称:deepAzure,代码行数:9,代码来源:Board.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# PieceType类代码示例发布时间:2022-05-24
下一篇:
C# Piece类代码示例发布时间: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