예제 #1
0
 public static bool IsAdjoinTerritory(this GameField field, Point point, int player)
 {
     foreach (Point temp in field.Adjoin(point))
     {
         if (field[temp].Terrain == Terrain.Hole) continue;
         if (field[temp].Terrain == Terrain.Outside) continue;
         if (field[temp].Player == player) return true;
     }
     return false;
 }
예제 #2
0
 public static IEnumerable<Point> NearIterator(this GameField field, Point center, int player)
 {
     bool[,] searched = new bool[field.Width, field.Height];
     Queue<Point> queue = new Queue<Point>();
     queue.Enqueue(center);
     while (queue.Count > 0)
     {
         Point current = queue.Dequeue();
         foreach (Point point in field.Adjoin(current))
         {
             if (searched[point.X, point.Y]) continue;
             if (field.IsInMove(point, field[point].Player == player) && field.IsOutMove(point))
             {
                 queue.Enqueue(point);
                 searched[point.X, point.Y] = true;
             }
         }
         yield return current;
     }
 }
예제 #3
0
 public static bool IsLiberate(this GameField field, Point point)
 {
     int count = 0;
     foreach (Point temp in field.Adjoin(point, true))
     {
         if (field[temp].Terrain != Terrain.Wasteland) return false;
         count++;
     }
     return count >= 7;
 }