Пример #1
0
        public static Array2D<int> GetNoBoxMap(Level level, Array2D<bool> simpleDeadlockMap)
        {
            // Initially set all floor squares as no-box squares, but not yet assigned to a region.
            Array2D<int> noBoxMap = new Array2D<int>(level.Height, level.Width);
            foreach (Coordinate2D coord in level.InsideCoordinates)
            {
                noBoxMap[coord] = -1;
            }

            // For each box in the original level, visit as many squares as possible.
            foreach (Coordinate2D coord in level.BoxCoordinates)
            {
                CheckBox(level, noBoxMap, simpleDeadlockMap, coord);
            }

            // The map now has a value of -1 for all no-box squares.
            // Next assign a unique value to each disconnected region of no-box squares.
            int region = 1;
            foreach (Coordinate2D coord in level.InsideCoordinates)
            {
                // Process all no-box squares that haven't been assigned to a region yet.
                if (noBoxMap[coord] == -1)
                {
                    noBoxMap.FloodFill(coord, -1, region);
                    region++;
                }
            }

            return noBoxMap;
        }
Пример #2
0
 public static Array2D<bool> GetIslandMap(Level level)
 {
     Array2D<bool> islandMap = new Array2D<bool>(level.Height, level.Width);
     foreach (Coordinate2D coord in islandMap.Coordinates)
     {
         islandMap[coord] = level.IsWall(coord);
     }
     islandMap.FloodFill(FindFirstWall(level), true, false);
     return islandMap;
 }