Ejemplo n.º 1
0
        /// <summary>
        /// 添加多点
        /// </summary>
        /// <param name="LTCrossPoint">原点列</param>
        /// <param name="player">对方棋色</param>
        /// <param name="board"></param>
        /// <returns>多点防守点列</returns>
        private static List <PieceInfo> Defend(List <PieceInfo> LTCrossPoint, int player, BoardInfo board)
        {
            List <PieceInfo> NewLTCrossPoint = new List <PieceInfo>();

            foreach (PieceInfo d in LTCrossPoint)
            {
                int i = d.X;
                int j = d.Y;
                int mini = i - 4, maxi = i + 4;
                int minj = j - 4, maxj = j + 4;
                // line 0
                for (int x = mini; x < maxi; x++)
                {
                    if (x < 1 || x > 15 || x == i)
                    {
                        continue;
                    }
                    PieceInfo info = board.GetPieceInfo(x, j);
                    Boolean   isd  = IsDefendCrossPoint(info, player, 0);

                    if (isd)
                    {
                        NewLTCrossPoint.Add(info);
                    }
                }

                // line 1
                for (int y = minj; y < maxj; y++)
                {
                    if (y < 1 || y > 15 || y == j)
                    {
                        continue;
                    }
                    PieceInfo info = board.GetPieceInfo(i, y);
                    Boolean   isd  = IsDefendCrossPoint(info, player, 1);

                    if (isd)
                    {
                        NewLTCrossPoint.Add(info);
                    }
                }

                // line 2
                int ly = minj;
                for (int x = mini; x < maxi; x++)
                {
                    if (x < 1 || x > 15 || x == i)
                    {
                        ly++;
                        continue;
                    }
                    if (ly < 1 || ly > 15 || ly == j)
                    {
                        ly++;
                        continue;
                    }
                    PieceInfo info = board.GetPieceInfo(x, ly);
                    Boolean   isd  = IsDefendCrossPoint(info, player, 2);

                    if (isd)
                    {
                        NewLTCrossPoint.Add(info);
                    }
                }
                ly++;

                // line 3
                int rx = maxi;
                for (int y = minj; y < maxj; y++)
                {
                    if (y < 1 || y > 15 || y == j)
                    {
                        rx--;
                        continue;
                    }
                    if (rx < 1 || rx > 15 || rx == i)
                    {
                        rx--;
                        continue;
                    }
                    PieceInfo info = board.GetPieceInfo(rx, y);
                    Boolean   isd  = IsDefendCrossPoint(info, player, 3);

                    if (isd)
                    {
                        NewLTCrossPoint.Add(info);
                    }
                }
                rx--;
            }
            return(NewLTCrossPoint);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 多点防守(无禁手)
        /// </summary>
        /// <param name="board"></param>
        /// <param name="List"></param>
        /// <returns></returns>
        private static PieceInfo MoreDefend(BoardInfo boardInfo, Board board)
        {
            List <PieceInfo> maxLT            = boardInfo.MaxLt;
            PieceInfo        ReturnCrossPoint = new PieceInfo();

            // 活三11时
            if (boardInfo.MaxLev == LevelEnum.LF_2)// 活三11时
            {
                ReturnCrossPoint = TryVCF(maxLT, board);
                return(ReturnCrossPoint);
            }

            // 杀棋Lev < 7
            if ((int)boardInfo.MaxLev <= (int)LevelEnum.TrTr_6)
            {
                // 多个杀点时
                if (maxLT.Count > 1)
                {
                    return(maxLT[0]);
                }

                // 1子3杀时
                ReturnCrossPoint = maxLT[0];
                var      info     = boardInfo.GetPieceInfo(ReturnCrossPoint.X, ReturnCrossPoint.Y);
                string[] strNameD = new string[4];// 对方4个方向的棋形
                if (board.Step % 2 == 1)
                {
                    strNameD = info.Names[ColourEnum.White];
                }
                else
                {
                    strNameD = info.Names[ColourEnum.White];
                }
                List <int> ltstr = new List <int>();
                for (int i = 0; i < 4; i++)
                {
                    if (strNameD[i].Equals("h3") ||
                        strNameD[i].Equals("t3") ||
                        strNameD[i].Equals("m4"))
                    {
                        ltstr.Add(i);
                    }
                }
                if (ltstr.Count > 2)// 杀棋线路多于2个(三杀)
                {
                    return(ReturnCrossPoint);
                }
            }

            // 添加多防守点各个测试
            int DColour = (board.Step) % 2;// 被守方棋色
            List <PieceInfo> MdArrayList = new List <PieceInfo>();

            MdArrayList = Defend(maxLT, DColour, boardInfo);// 获得多点防守点列
            foreach (PieceInfo d in MdArrayList)
            {
                maxLT.Add(d);
            }
            ReturnCrossPoint = TryVCF(maxLT, board);

            return(ReturnCrossPoint);
        }