Exemplo n.º 1
0
        public List <DiamondGroup> createClickList()
        {
            List <DiamondGroup> ret   = new List <DiamondGroup>();
            List <int>          cache = new List <int>();

            for (int j = 0; j < 9; j++)
            {
                for (int i = 0; i < 10; i++)
                {
                    if (board[i, j].grey)
                    {
                        greyCount++;
                    }
                    if (board[i, j].count >= 3)
                    {
                        // check in cache
                        if (!cache.Exists(g => g == board[i, j].group))
                        {
                            ret.Add(createGroup(board[i, j].group));
                            cache.Add(board[i, j].group);
                            continue;
                        }
                    }
                }
            }
            if (ret.Count < 3)
            {
                for (int j = 0; j < 9; j++)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        if (board[i, j].spacial != 0)
                        {
                            DiamondGroup d = new DiamondGroup();
                            d.add(board[i, j]);
                            ret.Add(d);
                        }
                    }
                }
            }

//            txtDebug.AppendText("createClickList " + ret.Count + "\n");
//            foreach (DiamondGroup d in ret)
//            {
//                txtDebug.AppendText(d.ToString() + "\n");
//            }
            ret = optimizeClickList(ret);
            //txtDebug.AppendText("optimizeClickList " + ret.Count + " grey=" + greyCount + "\n");
//            foreach (DiamondGroup d in ret)
//            {
//                txtDebug.AppendText(d.ToString() + "\n");
//            }

            return(ret);
        }
Exemplo n.º 2
0
        public DiamondGroup createGroup(int group)
        {
            DiamondGroup ret = new DiamondGroup();

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    if (board[i, j].group == group)
                    {
                        ret.add(board[i, j]);
                    }
                }
            }
            return(ret);
        }
Exemplo n.º 3
0
 public bool isOverLap(DiamondGroup g)
 {
     if (right >= g.left)
     {
         if (left < g.left)
         {
             if (top <= g.top)
             {
                 if (buttom > g.top)
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Exemplo n.º 4
0
        public List <DiamondGroup> optimizeClickList(List <DiamondGroup> lst)
        {
            List <DiamondGroup> ret = new List <DiamondGroup>();

            for (int i = 0; i < lst.Count; i++)
            {
                bool         flgRemove = false;
                DiamondGroup item1     = lst.ElementAt(i);
                for (int j = 1 + 1; j < lst.Count; j++)
                {
                    DiamondGroup item2 = lst.ElementAt(j);
                    if (item1.isOverLap(item2))
                    {
                        // make sure that over lap valid

//                        txtDebug.AppendText(item1.ToString() + " overlap " + item2.ToString() + "\n");
                        //Remove less count item
                        if (item1.lstDimond.Count >= item2.lstDimond.Count)
                        {
//                            txtDebug.AppendText("Remove2 " + item2.ToString()+ "\n");
                            lst.RemoveAt(j);
                        }
                        else
                        {
//                            txtDebug.AppendText("Remove1 " + item1.ToString() + "\n");
                            flgRemove = true;
                            break;
                        }
                    }
                }
                if (!flgRemove)
                {
                    ret.Add(item1);
                    // click special item one at a time
                    if (item1.lstDimond.Count == 1)
                    {
                        break;
                    }
                }
            }
            return(ret);
        }