Exemple #1
0
 private void RecursiveAddPoint(Group group, int x, int y)
 {
     if (GetContentAt(x, y) == group.Content)
     {
         if (group.ContainsPoint(x, y))
         {
             return;
         }
         group.AddPoint(x, y);
         groupCache2[x, y] = group;
         if (x > 0)
         {
             RecursiveAddPoint(group, x - 1, y);
         }
         if (x < SizeX - 1)
         {
             RecursiveAddPoint(group, x + 1, y);
         }
         if (y > 0)
         {
             RecursiveAddPoint(group, x, y - 1);
         }
         if (y < SizeY - 1)
         {
             RecursiveAddPoint(group, x, y + 1);
         }
     }
     else
     {
         group.AddNeighbour(x, y);
     }
 }
Exemple #2
0
        internal List <Group> GetCapturedGroups(int x, int y)
        {
            Group        group           = GetGroupAt(x, y);
            List <Group> captures        = new List <Group>();
            var          stoneNeighbours = GetStoneNeighbours(x, y);

            foreach (var n in stoneNeighbours)
            {
                if (GetContentAt(n) != Content.Empty)
                {
                    Group ngroup = GetGroupAt(n);
                    if (ngroup.ContainsPoint(x, y))
                    {
                        continue;                             // Don't consider self group
                    }
                    if (GetLiberties(ngroup) == 0)
                    {
                        if (!captures.Any(g => g.Points.Intersect(ngroup.Points).Any()))
                        {
                            captures.Add(ngroup);
                        }
                    }
                }
            }
            return(captures);
        }
Exemple #3
0
 private void RecursiveAddPoint(Group group, int x, int y)
 {
     if (GetContentAt(x, y) == group.Content)
     {
         if (group.ContainsPoint(x, y)) return;
         group.AddPoint(x, y);
         groupCache2[x, y] = group;
         if (x > 0) RecursiveAddPoint(group, x - 1, y);
         if (x < SizeX - 1) RecursiveAddPoint(group, x + 1, y);
         if (y > 0) RecursiveAddPoint(group, x, y - 1);
         if (y < SizeY - 1) RecursiveAddPoint(group, x, y + 1);
     }
     else
     {
         group.AddNeighbour(x, y);
     }
 }