public Region(int[,] map, int ID, int count, Pos pos)
        {
            this.ID       = ID;
            this.count    = count;
            this.startpos = pos;
            this.closest  = new List <Connection>();
            LoopTurtle turtle = new LoopTurtle(map, pos, EMPTY, true);

            this.cmds = turtle.cmdlist;
            this.connected_to_main = false;
            this.connections       = new List <Region>();
        }
        // the purpose of extracting inner regions is purely cosmetic, so no actual regions are returned, just the wall geometry
        // this step should be performed before normal region extraction
        public static List <List <Cmd> > extract_inner_regions(int[,] map, int threshold)
        {
            int width  = map.GetLength(0);
            int height = map.GetLength(1);
            List <List <Cmd> > wall_geometry = new List <List <Cmd> >();

            for (int x = 1; x < width - 1; x++)
            {
                for (int y = 1; y < height - 1; y++)
                {
                    if (map[x, y] == EMPTY)
                    {
                        int count = flood_fill(map, x, y, INNER_REGION, EMPTY);
                        if (count > threshold)
                        {
                            LoopTurtle turtle = new LoopTurtle(map, new Pos(x, y), FILLED, false);
                            turtle.cmdlist.Reverse();
                            wall_geometry.Add(turtle.cmdlist);
                        }
                        else if (count != 0)
                        {
                            flood_fill(map, x, y, FILLED, INNER_REGION);
                        }
                    }
                }
            }
            // clear the inner region markers
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    map[x, y] = map[x, y] == INNER_REGION ? EMPTY : map[x, y];
                }
            }
            return(wall_geometry);
        }