Beispiel #1
0
        static void PrintCorridorMap(Map map, XY initial, int blueThreshold)
        {
            BinaryMatrix discovered = new BinaryMatrix(map.Width, map.Height);
            BinaryMatrix corridors  = new BinaryMatrix(map.Width, map.Height);
            BinaryMatrix obstacles  = map.ScanObstacles(blueThreshold);
            Queue <XY>   queue      = new Queue <XY>();

            queue.Enqueue(initial);
            discovered[initial.X, initial.Y] = true;

            while (queue.Count > 0)
            {
                XY point = queue.Dequeue();
                corridors[point] = true;

                foreach (XY neighbor in point.GetNeighbors())
                {
                    if (
                        neighbor.IsInsideBox(map.Box) &&
                        !discovered[neighbor] &&
                        !obstacles[neighbor]
                        )
                    {
                        discovered[neighbor] = true;
                        queue.Enqueue(neighbor);
                    }
                }
            }

            corridors.ToBitmap(Color.Black, Color.Green).Save(FILE_BASE + "background-corridors.jpg");
        }