Example #1
0
 //public static bool IsConnected(int x1, int y1, int x2, int y2)
 //{
 //    if (y1 == y2 && Math.Abs(x1 - x2) == 1) return true;
 //    if (y1 % 2 == 1 && Math.Abs(y1-y2)==1 && (x2 == x1 || x2 == x1 + 1)) return true;
 //    if (y1 % 2 == 0 && Math.Abs(y1 - y2) == 1 && (x2 == x1 || x2 == x1 - 1)) return true;
 //    return false;
 //}
 //public static IEnumerable<Point> GetAllConnectedMaybeOutsideMap(int x, int y)
 //{
 //    for (int xx = x - 1; xx <= x + 1; xx++)
 //        for (int yy = y - 1; yy <= y + 1; yy++)
 //            if (IsConnected(x, y, xx, yy))
 //                yield return new Point(xx, yy);
 //}
 private static double FindClosureIndex(Map map, int xmin, int xmax, int ymin, int ymax)
 {
     var pointsCount = 0;
     double closure = 0;
     for (var x = xmin; x <= xmax; x++)
     {
         for (var y = ymin; y <= ymax; y++)
         {
             if (!map.IsInside(new Point(x, y))) continue;
             pointsCount++;
             if (map.Filled[x, y]) continue;
             closure += FindClosureIndex(x, y, map);
         }
     }
     return closure / pointsCount;
 }
Example #2
0
 static int GetPathLength(Map map, int startX, int startY, Directions dir)
 {
     int length = 0;
     foreach (var p in GetPath(startX, startY, dir))
     {
         if (!map.IsInside(p)) break;
         if (map.Filled[p.X, p.Y]) break;
         length++;
         if (length > maxLineSlotLength) return -1;
     }
     return length;
 }
Example #3
0
 static int FindClosureIndex(int x, int y, Map map)
 {
     if (map.Filled[x, y]) return 0;
     var cap = GetCap(x, y);
     int problems = cap.Where(p => !map.IsInside(p) || map.Filled[p.X, p.Y]).Count();
     return problems;
 }