Example #1
0
 public void SetPiece( ChessPiece chessPiece )
 {
     this.gameObject = chessPiece.gameObject;
     this.playerSide = chessPiece.playerSide;
     this.pieceType = chessPiece.pieceType;
     this.piecePlayerType = chessPiece.piecePlayerType;
 }
Example #2
0
 public Piece(string id, string asset, Vector3 position, int colorT, PieceType pieceT)
     : base(id, position)
 {
     _asset = asset;
     ColorType = (Colour)colorT;
     Piece_Type = pieceT;
 }
 public Piece(int x, int y, PieceType type, bool isBlack)
 {
     _x = x;
     _y = y;
     _type = type;
     _isBlack = isBlack;
 }
Example #4
0
 public Piece(bool[,] _data, PieceType _type, TransFormation _trans, Color _color)
 {
     m_data = _data;
     m_type = _type;
     m_trans = _trans;
     m_color = _color;
 }
Example #5
0
 public Piece(PlayerColor playerColor, PieceType pieceType, byte x, byte y)
 {
     playerColorValue = playerColor;
     pieceTypeValue = pieceType;
     xValue = x;
     yValue = y;
 }
Example #6
0
 public Piece(PieceType type, Player owner)
 {
     Type = type;
     Owner = owner;
     Hex = null;
     CanMove = true;
 }
Example #7
0
        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);
        }
Example #8
0
 internal ChessPiece(bool white, PieceType type)
 {
     this.white = white;
     this.type = type;
     this.lastMove = 0;
     this.lastSquare = new SquareCoordinates(-1, -1);
 }
Example #9
0
 public ChessPiece()
 {
     gameObject = null;
     playerSide = PlayerSide.e_NoneSide;
     pieceType = PieceType.e_None;
     piecePlayerType = PiecePlayerType.eNone_Piece;
 }
Example #10
0
 private ChessPiece(bool white, PieceType type, ushort lastMove, SquareCoordinates lastSquare)
 {
     this.white = white;
     this.type = type;
     this.lastMove = lastMove;
     this.lastSquare = lastSquare;
 }
Example #11
0
 public ChessPiece(PieceType pieceType, PieceColour pieceColour, int file, int rank)
 {
     this.pieceType = pieceType;
     this.pieceColour = pieceColour;
     this.rank = rank;
     this.file = file;
 }
Example #12
0
 public Square(string nam, int num)
 {
     InitializeComponent();
     // Init Obj Rec
     InitializeDefinitions();
     // Set Square Size
     MyTagVisualizer.Height = squareSize;
     MyTagVisualizer.Width = squareSize;
     // Bring TagVisualizer to the top
     MyTagVisualizer.SetCurrentValue(Panel.ZIndexProperty, 5);
     // Set internal information
     this.name = nam;
     this.number = num;
     this.piece = PieceType.Empty;
     this.Width = squareSize;
     this.Height = squareSize;
     // Set the Square in the middle
     this.SetCurrentValue(Panel.ZIndexProperty, 3);
     // Add the Rectangle Layer
     rectangle.Width = squareSize;
     rectangle.Height = squareSize;
     rectangle.Stroke = Brushes.Black;
     rectangle.StrokeThickness = 1;
     rectangle.Opacity = 0.5;
     colourRectangle(Brushes.Transparent);
 }
Example #13
0
        /// <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>();
        }
Example #14
0
    public ChessPiece( GameObject gameObject, PlayerSide playerSide, 
		PiecePlayerType piecePlayerType )
    {
        this.gameObject = gameObject;
        this.playerSide = playerSide;
        this.pieceType = ChessUtility.GetPieceType( piecePlayerType );
        this.piecePlayerType = piecePlayerType;
    }
Example #15
0
 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;
 }
Example #16
0
 public ChessPiece()
 {
     gameObject = null;
     playerSide = PlayerSide.e_NoneSide;
     pieceType = PieceType.e_None;
     piecePlayerType = PiecePlayerType.eNone_Piece;
     bEnPassantCapture = false;
 }
        public bool IsMoveValid(int fromRow, int fromColumn, int toRow, int toColumn, PieceType fromPieceType,
            PieceType toPieceType, PlayerType playerInTurn)
        {
            if (IsJumping(fromRow, fromColumn, toRow, toColumn)) return false;
            if (!IsOriginValid(fromPieceType, playerInTurn)) return false;
            if (!IsMovingForward(fromRow, toRow, playerInTurn)) return false;

            return IsDestinationValid(fromColumn, toColumn, toPieceType, playerInTurn);
        }
Example #18
0
 public Piece( PieceType type, PieceColor color )
 {
     if (type == PieceType.None)
         throw new ArgumentException("Type must be specified");
     if (color == PieceColor.None)
         throw new ArgumentException("Color must be specified");
     _type = type;
     _color = color;
 }
 public Move(int from_x, int from_y, int to_x, int to_y, PieceType moved_type, bool promote)
 {
     this.from_rank = from_x;
     this.from_file = from_y;
     this.to_rank = to_x;
     this.to_file = to_y;
     this.promote = promote;
     this.moved_type = moved_type;
 }
Example #20
0
 /// <summary>
 /// Piece constructor
 /// </summary>
 /// <param name="position">The position on the game board</param>
 /// <param name="type">The type piece</param>
 /// <param name="side">The side (team)</param>
 /// <param name="texturePath">A relative path to an image file</param>
 /// <param name="directionVector">A list of vectors defining the movement pattern of the piece</param>
 /// <param name="moveReach">How many steps the piece can move</param>
 public Piece(Point position, PieceType type, Side side, string texturePath, List<Point> directionVector, int moveReach)
 {
     this.position = position;
     this.type = type;
     this.side = side;
     LoadTexture(texturePath);
     this.directionVector = directionVector;
     this.moveReach = moveReach;
 }
Example #21
0
    private void SpawnPiece(PlayerType p, PieceType t, Position pos, Transform parent)
    {
        GameObject go = Instantiate(piecePrefab) as GameObject;
        Piece piece = go.GetComponent<Piece>();
        go.transform.parent = parent;

        piece.Set(p, t, pos);
        GameController.Instance.board.GetField(pos).Occupy(piece);
    }
Example #22
0
        public void LoadPiece(PieceType type, Drawable piece)
        {
            Bitmap bitmap = Bitmap.CreateBitmap (piece_size, piece_size, Bitmap.Config.Argb8888);
            Canvas canvas = new Canvas (bitmap);

            piece.SetBounds (0, 0, piece_size, piece_size);
            piece.Draw (canvas);

            piece_bitmaps[(int)type] = bitmap;
        }
Example #23
0
 public Piece(PieceType type)
 {
     if (type == PieceType.Straight)
         pieces = new List<Texture>()
         {
             DrawManager.CreateTexture("Tetris - Blue Piece", "Blue Piece", Vector2.Zero, DrawManager.ImagePosition.TopLeft),
             DrawManager.CreateTexture("Tetris - Blue Piece", "Blue Piece", DrawManager.GetTexture("Tetris - Blue Piece").Width(), DrawManager.ImagePosition.TopLeft),
             DrawManager.CreateTexture("Tetris - Blue Piece", "Blue Piece", 2 * DrawManager.GetTexture("Tetris - Blue Piece").Width(), DrawManager.ImagePosition.TopLeft),
             DrawManager.CreateTexture("Tetris - Blue Piece", "Blue Piece", 3 * DrawManager.GetTexture("Tetris - Blue Piece").Width(), DrawManager.ImagePosition.TopLeft),
         };
 }
Example #24
0
        public Piece(PieceType type, int x, int y)
        {
            if (0 > x || x > 7)
                throw new ArgumentOutOfRangeException("x", "Invalid x position");
            if (0 > y || y > 7)
                throw new ArgumentOutOfRangeException("x", "Invalid y position");

            ChessType = type;
            X = x;
            Y = y;
        }
Example #25
0
        public PawnMower(PieceType userPiece, int count)
        {
            this.userPiece = userPiece;
            this.count = count;
            currentPosition.sameActiveColor = true;
            moves = new ArrayList();
            randomNumber = new Random();

            SetUpBoard();

            initialPosition = FENConverter.convertPositionToFEN(currentPosition);
        }
Example #26
0
 internal void MovePiece(PieceType type, SquareCoordinates from, SquareCoordinates to)
 {
     if (type != PieceType.KING)
     {
         pieces.Remove(from);
         pieces.Add(to);
     }
     else
     {
         kingSquare = to;
     }
 }
Example #27
0
        public Piece(Coordinate location, Player player, PieceType type)
        {
            Location = location;
            Player = player;
            HasMoved = false;
            PieceType = type;

            if (player == Player.Light)
            {
                Direction *= -1;
            }
        }
            protected ChessPiece(PieceType type, ColorType color,
					      int rank, int file,
					      ChessSide myside,
					      ChessSide oppside)
            {
                this.type = type;
                this.myside = myside;
                this.oppside = oppside;
                this.color = color;
                this.rank = rank;
                this.file = file;
            }
 private bool IsOriginValid(PieceType fromPieceType, PlayerType playerInTurn)
 {
     switch (playerInTurn)
     {
         case PlayerType.Black:
             if (fromPieceType != PieceType.Black) return false;
             break;
         case PlayerType.White:
             if (fromPieceType != PieceType.White) return false;
             break;
     }
     return true;
 }
Example #30
0
        public Piece(string stringType, PieceColour pieceColour, Vector2 pos)
        {
            //Constants
            mPieceTexture = Content.Load<Texture2D>(stringType);
            Type = Helpers.GetPieceType(stringType);
            Colour = pieceColour;

            //Updated on move
            BoardTile = Helpers.TileToBoardCoord((int)pos.X,(int)pos.Y);
            Position = Helpers.TileToPixel((int) pos.X, (int) pos.Y);
            TilePosition = new TilePosition(){ X = (int)pos.Y,Y = (int)pos.X};
            CollisionRect = new Rectangle((int)Position.X, (int)Position.Y, 64, 64);
        }
Example #31
0
        // *** CONSTRUCTION ** //

        public RelativeRoyaltyCheckmateRule(PieceType royalPieceType)
        {
            RoyalPieceType  = royalPieceType;
            StalemateResult = MoveEventResponse.GameDrawn;
        }
 public Piece(Color col, PieceType pType)
 {
     Color     = col;
     PieceType = pType;
 }
Example #33
0
 public Piece(PieceType type, PieceColor color)
 {
     Type  = type;
     Color = color;
 }
Example #34
0
        /// <summary>
        /// 将棋の駒画像のファイル名に変換。
        /// </summary>
        /// <param name="ks14"></param>
        /// <returns></returns>
        public static string ToStr_ImageName(PieceType ks14)
        {
            string name;

            switch (ks14)
            {
            case PieceType.P:
                name = "01_Fu_____";
                break;

            case PieceType.L:
                name = "02_Kyo____";
                break;

            case PieceType.N:
                name = "03_Kei____";
                break;

            case PieceType.S:
                name = "04_Gin____";
                break;

            case PieceType.G:
                name = "05_Kin____";
                break;

            case PieceType.R:
                name = "07_Hisya__";
                break;

            case PieceType.B:
                name = "08_Kaku___";
                break;

            case PieceType.K:
                name = "06_Gyoku__";
                break;

            case PieceType.PP:
                name = "11_Tokin__";
                break;

            case PieceType.PL:
                name = "12_NariKyo";
                break;

            case PieceType.PN:
                name = "13_NariKei";
                break;

            case PieceType.PS:
                name = "14_NariGin";
                break;

            case PieceType.PR:
                name = "09_Ryu____";
                break;

            case PieceType.PB:
                name = "10_Uma____";
                break;

            default:
                name = "00_Null___";
                break;
            }

            return(name);
        }
Example #35
0
        static Move ValidatePieceMove(Move move, BoardSetup board,
                                      PieceType piece, PieceType pieceType)
        {
            var   rank  = move.TargetSquare.Rank - 1;
            var   ifile = (int)move.TargetSquare.File - 1;
            Color color = board.IsWhiteMove ? Color.White : Color.Black;
            var   targetPieceNotKing = board[move.TargetSquare]?.PieceType != PieceType.King &&
                                       board[move.TargetSquare]?.Color != color;
            Func <int, int, bool> pieceCondition;

            if (pieceType == PieceType.Bishop)
            {
                pieceCondition = (f, r) => Math.Abs(ifile - f) == Math.Abs(rank - r);
            }
            else if (pieceType == PieceType.Rook)
            {
                pieceCondition = (f, r) => (ifile == f || rank == r);
            }
            else if (pieceType == PieceType.King)
            {
                pieceCondition = (f, r) => Math.Abs(ifile - f) <= 1 && Math.Abs(rank - r) <= 1;
            }
            else
            {
                throw new InvalidOperationException("Invalid piece was passed to func");
            }
            Square original = null;

            for (int f = 0; f < 8; f++)
            {
                for (int r = 0; r < 8; r++)
                {
                    if (board[f, r]?.PieceType == piece &&
                        board[f, r]?.Color == color &&
                        pieceCondition(f, r) &&
                        targetPieceNotKing &&
                        (move.OriginRank == null || move.OriginRank == (r + 1)) &&
                        (move.OriginFile == null || move.OriginFile == (File)(f + 1)))
                    {
                        int  pathLenght = Math.Abs(ifile - f);
                        int  df         = Math.Sign(ifile - f);
                        int  dr         = Math.Sign(rank - r);
                        bool freePath   = true;
                        for (int i = 1; i < pathLenght; i++)
                        {
                            if (board[f + df * i, r + dr * i] != null)
                            {
                                freePath = false;
                                break;
                            }
                        }
                        if (freePath == true)
                        {
                            if (original == null)
                            {
                                original = new Square((File)(f + 1), r + 1);
                            }
                            else
                            {
                                throw new InvalidOperationException("More than one piece can make a given move");
                            }
                        }
                    }
                }
            }
            if (original != null)
            {
                var result = move.Clone();
                result.OriginSquare = original;
                result.OriginFile   = original.File;
                result.OriginRank   = original.Rank;
                return(result);
            }
            return(null);
        }
Example #36
0
 public int GetMobilityScore(GameStage stage, PieceType pieceType)
 {
     return(mobility[(int)pieceType].Get(stage));
 }
Example #37
0
 public int GetExtendedPieceDefenseScore(PieceType pieceType)
 {
     return(pieceDefense[(int)pieceType]);
 }
Example #38
0
 public void AddTexture(PieceType type, BitmapImage blackTexture, BitmapImage whiteTexture)
 {
     blackTextures.Add(type, blackTexture);
     whiteTextures.Add(type, whiteTexture);
 }
Example #39
0
    public bool ClearAllValidPieces()
    {
        bool IsNeedReFill = false;

        for (int y = 0; y < yDim; y++)
        {
            for (int x = 0; x < xDim; x++)
            {
                if (pieces[x, y].ISClearable())
                {
                    List <GamePiece> matching = GetSameColorPiece(pieces[x, y], x, y);
                    if (matching != null)
                    {
                        PieceType specialPieceType = PieceType.COUNT;
                        GamePiece randomPiece      = matching[Random.Range(0, matching.Count)];
                        int       specialPieceX    = randomPiece.X;
                        int       specialPieceY    = randomPiece.Y;

                        if (matching.Count == 4)
                        {
                            if (pressedPiece == null || enteredPiece == null)
                            {
                                specialPieceType = (PieceType)Random.Range((int)PieceType.ROW_CLEAR, (int)PieceType.COL_CLEAR);
                            }
                            else if (pressedPiece.GridPieceType != PieceType.ROW_CLEAR &&
                                     pressedPiece.Y == enteredPiece.Y)
                            {
                                specialPieceType = PieceType.ROW_CLEAR;
                            }
                            else if (pressedPiece.GridPieceType != PieceType.COL_CLEAR &&
                                     pressedPiece.X == enteredPiece.X)
                            {
                                specialPieceType = PieceType.COL_CLEAR;
                            }
                            else
                            {
                                specialPieceType = PieceType.COUNT;
                            }
                        }

                        //匹配数大于5生成任意颜色都可以消除的特殊物件
                        else if (matching.Count >= 5)
                        {
                            specialPieceType = PieceType.ANY;
                        }

                        for (int i = 0; i < matching.Count; i++)
                        {
                            if (ClearPiece(matching[i].X, matching[i].Y))
                            {
                                IsNeedReFill = true;

                                if (matching [i] == pressedPiece || matching [i] == enteredPiece)
                                {
                                    specialPieceX = matching [i].X;
                                    specialPieceY = matching [i].Y;
                                }
                            }
                        }

                        //特殊物件不为Count时执行生成
                        if (specialPieceType != PieceType.COUNT)
                        {
                            Destroy(pieces[specialPieceX, specialPieceY]);
                            GamePiece newPiece = SpawnNewPieces(specialPieceX, specialPieceY, specialPieceType);
                            Debug.Log(newPiece.X + "" + newPiece.Y);

                            if ((specialPieceType == PieceType.ROW_CLEAR || specialPieceType == PieceType.COL_CLEAR) &&
                                newPiece.IsColorpiece() && matching[0].IsColorpiece())
                            {
                                newPiece.Colorpieces.SetColor(matching[0].Colorpieces.Color);
                            }

                            else if (specialPieceType == PieceType.ANY && newPiece.IsColorpiece())
                            {
                                newPiece.Colorpieces.SetColor(ColorPieces.ColorType.任意);
                            }
                        }
                    }
                }
            }
        }

        return(IsNeedReFill);
    }
Example #40
0
 public Rook(PieceType pieceType, bool isWhitePiece)
     : base(pieceType, isWhitePiece)
 {
 }
Example #41
0
        /// <summary>
        /// クローンを作ります。
        /// </summary>
        /// <param name="src"></param>
        private SkyConst(Sky src, bool toReversePlayerside, int update_temezumi_orMinus1, Finger[] finger1, IMoveHalf[] light1,
                         //
                         // 手得計算
                         //
                         PieceType tedokuKeisan_komasyurui, int tedokukeisan_index, SyElement tedokukeisan_sasitamasu)
        {
            Debug.Assert(src.Count == 40, $"本将棋とみなしてテスト中。sky.Starlights.Count=[{src.Count}]");//将棋の駒の数

            if (tedokuKeisan_komasyurui == PieceType.None)
            {
                //----------------------------------------
                // 手得計算のヒストリーを作らない場合
                //----------------------------------------

                // 手得ヒストリーのクローン
                this.tedokuHistory = TedokuHistoryConst.New_Clone(src.TedokuHistory);
            }
            else
            {
                //----------------------------------------
                // 手得計算のヒストリーを作る場合
                //----------------------------------------

                // 手駒ヒストリーへの追加
                this.tedokuHistory = TedokuHistoryConst.NewInstance_AppendSasitamasu(
                    src.TedokuHistory,
                    tedokuKeisan_komasyurui,
                    tedokukeisan_index,
                    tedokukeisan_sasitamasu
                    );
            }


            // 手番のクローン
            if (toReversePlayerside)
            {
                this.kaisiPside = Conv_Playerside.Reverse(src.KaisiPside);
            }
            else
            {
                this.kaisiPside = src.KaisiPside;
            }

            // 手目済み
            if (-1 == update_temezumi_orMinus1)
            {
                // そのまま
                this.temezumi = src.Temezumi;
            }
            else
            {
                // 上書き更新
                this.temezumi = update_temezumi_orMinus1;
            }

            // 星々のクローン
            this.starlights = new List <IMoveHalf>();
            src.Foreach_Starlights((Finger finger2, IMoveHalf light2, ref bool toBreak2) =>
            {
                this.starlights.Add(light2);
            });

            //
            // 追加分があれば。
            //
            for (int i = 0; i < finger1.Length; i++)
            {
                if (finger1[i] != Fingers.Error_1)
                {
                    if (this.starlights.Count == (int)finger1[i])
                    {
                        // オブジェクトを追加します。
                        this.starlights.Add(light1[i]);
                    }
                    else if (this.starlights.Count + 1 <= (int)finger1[i])
                    {
                        // エラー
                        Debug.Assert((int)finger1[i] < this.starlights.Count, $"要素の個数より2大きいインデックスを指定しました。 インデックス[{(int)finger1[i]}] 要素の個数[{this.starlights.Count}]");

                        throw new Exception($"{this.GetType().Name}#SetStarPos: リストの要素より2多いインデックスを指定されましたので、追加しません。starIndex=[{finger1[i]}] / this.stars.Count=[{this.starlights.Count}]");
                    }
                    else
                    {
                        this.starlights[(int)finger1[i]] = light1[i];
                    }
                }
            }
        }
Example #42
0
 public PieceBuilder(PieceType type)
 {
     pieceType = type;
 }
Example #43
0
        /// <summary>
        /// ************************************************************************************************************************
        /// 駒の文字を、列挙型へ変換。
        /// ************************************************************************************************************************
        /// </summary>
        /// <param name="moji"></param>
        /// <returns></returns>
        public static string ToStr_Ichimoji(PieceType ks14)
        {
            string syurui;

            switch (ks14)
            {
            case PieceType.P:
                syurui = "歩";
                break;

            case PieceType.L:
                syurui = "香";
                break;

            case PieceType.N:
                syurui = "桂";
                break;

            case PieceType.S:
                syurui = "銀";
                break;

            case PieceType.G:
                syurui = "金";
                break;

            case PieceType.R:
                syurui = "飛";
                break;

            case PieceType.B:
                syurui = "角";
                break;

            case PieceType.K:
                syurui = "玉";
                break;

            case PieceType.PP:
                syurui = "と";
                break;

            case PieceType.PL:
                syurui = "杏";
                break;

            case PieceType.PN:
                syurui = "圭";
                break;

            case PieceType.PS:
                syurui = "全";
                break;

            case PieceType.PR:
                syurui = "竜";
                break;

            case PieceType.PB:
                syurui = "馬";
                break;

            default:
                syurui = "×";
                break;
            }

            return(syurui);
        }
Example #44
0
 public int GetExtendedPieceAttackScore(PieceType pieceType)
 {
     return(pieceAttack[(int)pieceType]);
 }
Example #45
0
 public int GetPieceDefenseScore(PieceType pieceType)
 {
     return((int)(pieceDefense[(int)pieceType] * directAttackModifier));
 }
Example #46
0
 public bool CheckAttribute(PieceType type)
 {
     return((this.properties & (int)type) > 0);
 }
Example #47
0
 public int GetPieceValue(PieceType pieceType)
 {
     return(piecesValue[(int)pieceType]);
 }
Example #48
0
 private void AddPromotions(MoveGenerationWorkspace workspace, Square fromSquare, Square toSquare, PieceType capturePieceType)
 {
     if (capturePieceType != PieceType.None)
     {
         workspace.CaptureMoveBuffer.Add(MoveBuilder.Create(workspace.Colour, PieceType.Pawn, fromSquare, toSquare, capturePieceType, MoveType.PromotionQueen, workspace.NumCheckers));
         workspace.CaptureMoveBuffer.Add(MoveBuilder.Create(workspace.Colour, PieceType.Pawn, fromSquare, toSquare, capturePieceType, MoveType.PromotionRook, workspace.NumCheckers));
         workspace.CaptureMoveBuffer.Add(MoveBuilder.Create(workspace.Colour, PieceType.Pawn, fromSquare, toSquare, capturePieceType, MoveType.PromotionKnight, workspace.NumCheckers));
         workspace.CaptureMoveBuffer.Add(MoveBuilder.Create(workspace.Colour, PieceType.Pawn, fromSquare, toSquare, capturePieceType, MoveType.PromotionBishop, workspace.NumCheckers));
     }
     else
     {
         workspace.NonCaptureMoveBuffer.Add(MoveBuilder.Create(workspace.Colour, PieceType.Pawn, fromSquare, toSquare, capturePieceType, MoveType.PromotionQueen, workspace.NumCheckers));
         workspace.NonCaptureMoveBuffer.Add(MoveBuilder.Create(workspace.Colour, PieceType.Pawn, fromSquare, toSquare, capturePieceType, MoveType.PromotionRook, workspace.NumCheckers));
         workspace.NonCaptureMoveBuffer.Add(MoveBuilder.Create(workspace.Colour, PieceType.Pawn, fromSquare, toSquare, capturePieceType, MoveType.PromotionKnight, workspace.NumCheckers));
         workspace.NonCaptureMoveBuffer.Add(MoveBuilder.Create(workspace.Colour, PieceType.Pawn, fromSquare, toSquare, capturePieceType, MoveType.PromotionBishop, workspace.NumCheckers));
     }
 }
        public Chess_Piece(Texture2D texture, Color colorOverlay, int boardPositionX, int boardPositionY, PieceType pieceType) :
            base(texture, boardPositionX * texture.Width, boardPositionY * texture.Height, colorOverlay,
                 0, MoveTypes.NONE, 0f, 0f, CustomMoveOrders.NONE, PieceType.NONE)
        {
            BoardPositionX = boardPositionX;
            BoardPositionY = boardPositionY;

            switch (pieceType)
            {
            case PieceType.Tower:
                PieceType            = pieceType;
                base.pieceType       = pieceType;
                base.maxMoveAmount   = 8;
                base.allowedMoveType = MoveTypes.UDLR;
                base.customMove.X    = 0f;
                base.customMove.Y    = 0f;
                base.customMoveOrder = CustomMoveOrders.NONE;
                break;

            case PieceType.Horse:
                PieceType            = pieceType;
                base.pieceType       = pieceType;
                base.maxMoveAmount   = 3;
                base.allowedMoveType = MoveTypes.CUSTOM;
                base.customMove.X    = 2f;
                base.customMove.Y    = 1f;
                base.customMoveOrder = CustomMoveOrders.BOTH;
                break;

            case PieceType.Knight:
                PieceType            = pieceType;
                base.pieceType       = pieceType;
                base.maxMoveAmount   = 8;
                base.allowedMoveType = MoveTypes.DIAGONAL;
                base.customMove.X    = 0f;
                base.customMove.Y    = 0f;
                base.customMoveOrder = CustomMoveOrders.NONE;
                break;

            case PieceType.Queen:
                PieceType            = pieceType;
                base.pieceType       = pieceType;
                base.maxMoveAmount   = 8;
                base.allowedMoveType = MoveTypes.ALL;
                base.customMove.X    = 0f;
                base.customMove.Y    = 0f;
                base.customMoveOrder = CustomMoveOrders.NONE;
                break;

            case PieceType.King:
                PieceType            = pieceType;
                base.pieceType       = pieceType;
                base.maxMoveAmount   = 1;
                base.allowedMoveType = MoveTypes.ALL;
                base.customMove.X    = 0f;
                base.customMove.Y    = 0f;
                base.customMoveOrder = CustomMoveOrders.NONE;
                break;

            case PieceType.Pawn:
                PieceType            = pieceType;
                base.pieceType       = pieceType;
                base.maxMoveAmount   = 1;
                base.allowedMoveType = MoveTypes.UP;
                base.customMove.X    = 0f;
                base.customMove.Y    = 0f;
                base.customMoveOrder = CustomMoveOrders.NONE;
                break;

            case PieceType.NONE:
                PieceType            = pieceType;
                base.pieceType       = pieceType;
                base.maxMoveAmount   = 0;
                base.allowedMoveType = MoveTypes.NONE;
                base.customMove.X    = 0f;
                base.customMove.Y    = 0f;
                base.customMoveOrder = CustomMoveOrders.NONE;
                break;

            default:
                break;
            }
        }
Example #50
0
 public MoveGenerator(GameState gameState, PregeneratedAttacksData pregeneratedAttacks, PieceType pieceType)
 {
     this.gameState           = gameState;
     this.pregeneratedAttacks = pregeneratedAttacks;
     this.pieceType           = pieceType;
 }
Example #51
0
 public static Piece With(this PieceType pieceType, Color color)
 {
     return((Piece)pieceType | (Piece)color);
 }
Example #52
0
 public Piece(PieceType type, Color outerColor, Color innerColor)
 {
     Type       = type;
     OuterColor = outerColor;
     InnerColor = innerColor;
 }
Example #53
0
        private void AddIndividualRayMoves(MoveGenerationWorkspace workspace, Square fromSquare, PieceType rayType, PieceType pieceType, SquareFlag legalMask)
        {
            var attackableSquaresIncludingSelfCaptures = GetAttackableSquares(fromSquare, rayType, workspace.RelativeBitBoard.OccupiedSquares);
            var attackableSquares      = attackableSquaresIncludingSelfCaptures & ~workspace.RelativeBitBoard.MySquares;
            var legalAttackableSquares = attackableSquares & legalMask;

            ToOrdinaryMoves(workspace, pieceType, fromSquare, legalAttackableSquares);
        }
Example #54
0
 public void setPieceType(PieceType type)
 {
     typeOfPiece = type;
 }
Example #55
0
 public static float GetPieceValue(this PieceType p) => p switch
 {
Example #56
0
 public Piece(PieceType pType, Color pColor)
 {
     aType  = pType;
     aColor = pColor;
 }
 protected override IChessPiece CreatePiece(PieceType type, PieceColor color)
 {
     return(new Pawn(color));
 }
Example #58
0
 public void setPieceType(PieceType pPieceType)
 {
     aType = pPieceType;
 }
Example #59
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FriendlyPiece"/> class.
 /// </summary>
 /// <param name="position">The piece position.</param>
 /// <param name="type">The piece type.</param>
 /// <param name="color">The piece color.</param>
 public FriendlyPiece(Position position, PieceType type, Color color)
 {
     Position = position;
     Type     = type;
     Color    = color;
 }
Example #60
0
 private void pictureBox4_Click(object sender, EventArgs e)
 {
     this.type = PieceType.QUEEN;
     this.Close();
     this.DialogResult = DialogResult.OK;
 }