Ejemplo n.º 1
0
 public override void SetEnablePositions(ISituation situation, out Positions enableMovein, out Positions enableCapture)
 {
     enableMovein  = new Positions();
     enableCapture = new Positions();
     PieceBishop.BishopShift(this.GameSide, situation, this.Position, enableMovein, enableCapture);
 }
Ejemplo n.º 2
0
        public override void SetEnablePositions(ISituation situation, out Positions enableMovein, out Positions enableCapture)
        {
            enableMovein  = new Positions();
            enableCapture = new Positions();

            Position.Shift(this.GameSide, situation, this.Position.ShiftEast(), enableMovein, enableCapture);
            Position.Shift(this.GameSide, situation, this.Position.ShiftSouth(), enableMovein, enableCapture);
            Position.Shift(this.GameSide, situation, this.Position.ShiftWest(), enableMovein, enableCapture);
            Position.Shift(this.GameSide, situation, this.Position.ShiftNorth(), enableMovein, enableCapture);
            Position.Shift(this.GameSide, situation, this.Position.ShiftEastNorth(), enableMovein, enableCapture);
            Position.Shift(this.GameSide, situation, this.Position.ShiftEastSouth(), enableMovein, enableCapture);
            Position.Shift(this.GameSide, situation, this.Position.ShiftWestNorth(), enableMovein, enableCapture);
            Position.Shift(this.GameSide, situation, this.Position.ShiftWestSouth(), enableMovein, enableCapture);
        }
Ejemplo n.º 3
0
 public static bool Shift(
     Enums.GameSide side, ISituation situation,
     Position tgtPos, Positions moveInPs, Positions capturePs)
 {
     return(Shift(side, situation, tgtPos, moveInPs, capturePs, true));
 }
Ejemplo n.º 4
0
        public override void SetEnablePositions(ISituation situation, out Positions enableMovein, out Positions enableCapture)
        {
            enableMovein  = new Positions();
            enableCapture = new Positions();

            if (this.GameSide == Enums.GameSide.White)
            {
                #region 白兵
                if (this.Position.Y < 1)
                {
                    return;                     //白兵怎么也不可能在第一行上
                }
                Position tmpPos = Position.Empty;
                //向北
                tmpPos = this.Position.ShiftNorth();
                if (tmpPos == Position.Empty)
                {
                    return;
                }
                if (!situation.ContainsPiece(tmpPos.Dot))
                {
                    enableMovein.Add(tmpPos);
                }
                //再向北(仅当在兵从未动过时)
                if (this.Position.Y == 1)
                {
                    tmpPos = tmpPos.ShiftNorth();
                    if (!situation.ContainsPiece(tmpPos.Dot))
                    {
                        enableMovein.Add(tmpPos);
                    }
                }
                //吃过路兵的判断
                if (this.Position.Y == 4)
                {
                    #region 过路兵
                    //西北
                    tmpPos = this.Position.ShiftWest();
                    if (tmpPos != null)
                    {
                        Piece pawn;
                        Game  game = (Game)situation;
                        if (game.TryGetPiece(tmpPos.Dot, out pawn))
                        {
                            if (pawn is PiecePawn)
                            {
                                if (((PiecePawn)pawn).EnableEnPassanted)
                                {
                                    enableMovein.Add(this.Position.ShiftWestNorth());
                                    enableCapture.Add(tmpPos);
                                }
                            }
                        }
                    }
                    //东北
                    tmpPos = this.Position.ShiftEast();
                    if (tmpPos != null)
                    {
                        Piece pawn;
                        Game  game = (Game)situation;
                        if (game.TryGetPiece(tmpPos.Dot, out pawn))
                        {
                            if (pawn is PiecePawn)
                            {
                                if (((PiecePawn)pawn).EnableEnPassanted)
                                {
                                    enableMovein.Add(this.Position.ShiftEastNorth());
                                    enableCapture.Add(tmpPos);
                                }
                            }
                        }
                    }
                    #endregion
                }
                //剑指西北
                Position.Shift(this.GameSide, situation, this.Position.ShiftWestNorth(), enableMovein, enableCapture, false);
                //剑指东北
                Position.Shift(this.GameSide, situation, this.Position.ShiftEastNorth(), enableMovein, enableCapture, false);
                #endregion
            }
            else
            {
                #region 黑兵
                if (this.Position.Y > 6)
                {
                    return;
                }
                Position tmpPos = Position.Empty;
                //向南
                tmpPos = this.Position.ShiftSouth();
                if (tmpPos == Position.Empty)
                {
                    return;
                }
                if (!situation.ContainsPiece(tmpPos.Dot))
                {
                    enableMovein.Add(tmpPos);
                }
                //再向南(仅当在兵从未动过时)
                if (this.Position.Y == 6)
                {
                    tmpPos = tmpPos.ShiftSouth();
                    if (!situation.ContainsPiece(tmpPos.Dot))
                    {
                        enableMovein.Add(tmpPos);
                    }
                }
                //吃过路兵的判断
                if (this.Position.Y == 3)
                {
                    #region 过路兵
                    //西南
                    tmpPos = this.Position.ShiftWest();
                    if (tmpPos != null)
                    {
                        Piece pawn;
                        Game  game = (Game)situation;
                        if (game.TryGetPiece(tmpPos.Dot, out pawn))
                        {
                            if (pawn is PiecePawn)
                            {
                                if (((PiecePawn)pawn).EnableEnPassanted)
                                {
                                    enableMovein.Add(this.Position.ShiftWestSouth());
                                    enableCapture.Add(tmpPos);
                                }
                            }
                        }
                    }
                    //东南
                    tmpPos = this.Position.ShiftEast();
                    if (tmpPos != null)
                    {
                        Piece pawn;
                        Game  game = (Game)situation;
                        if (game.TryGetPiece(tmpPos.Dot, out pawn))
                        {
                            if (pawn is PiecePawn)
                            {
                                if (((PiecePawn)pawn).EnableEnPassanted)
                                {
                                    enableMovein.Add(this.Position.ShiftEastSouth());
                                    enableCapture.Add(tmpPos);
                                }
                            }
                        }
                    }
                    #endregion
                }
                //剑指西南
                Position.Shift(this.GameSide, situation, this.Position.ShiftWestSouth(), enableMovein, enableCapture, false);
                //剑指东南
                Position.Shift(this.GameSide, situation, this.Position.ShiftEastSouth(), enableMovein, enableCapture, false);
                #endregion
            }
        }
Ejemplo n.º 5
0
 public abstract void SetEnablePositions(ISituation situation, out Positions enableMovein, out Positions enableCapture);