private void GetLevel(string URL1)
        {
            #region textparsing
            string httpPage = HttpHelper.GetDataFromHttp(URL1);
            string level = TextParser.FindTextBetween(httpPage, "<form action=index.php method=get><input type=", "input");
            string level2 = TextParser.FindTextBetween(level, "value", ">");
            string level3 = level2.Substring(2);
            string level4 = level3.Substring(0, level3.Length - 3);
            redoURL = "http://www.hacker.org/coil/index.php?name=Allosentient&password=XXXXX&gotolevel=" + level4 + "&go=Go+To+Level";
            string levelData = TextParser.FindTextBetween(httpPage, "<param name=\"FlashVars", "\" />");
            string levelData2 = TextParser.FindTextBetween(levelData, "\" value=\"", "...");
            int coordData = levelData2.IndexOf("&board");
            string coordData1 = levelData2.Substring(0, coordData);
            string coordX = TextParser.FindTextBetween(coordData1, "=", "&");
            string coordY = coordData1.Substring(coordData1.IndexOf('&') + 3);
            sizeX = Int32.Parse(coordX) + 2;
            sizeY = Int32.Parse(coordY) + 2;
            totalBlocks = sizeX * sizeY;
            string levelDataComplete = levelData.Substring(levelData.LastIndexOf('=') + 1);
            string s3 = levelData;
            #endregion

            levelDataArray = new int[sizeX, sizeY];
            originalLevelDataArray = new int[sizeX, sizeY];
            gridLocations = new GridLocation[sizeX, sizeY];
            testGrid = new SpriteGrid(system);

            #region gridgeneration
            int p = 0;
            for (int j = 0; j < sizeY; j++)
            {
                int y = sizeY - j - 1;
                for (int i = 0; i < sizeX; i++)
                {
                    if (i > 0 && i < sizeX - 1 && j > 0 && (j < sizeY - 1))
                    {
                        char c = levelDataComplete[p];
                        if (c == '.')
                        {
                            SetWall(i, y, false);
                        }
                        else if (c == 'X')
                        {
                            SetWall(i, y, true);
                            greenCount++;
                        }
                        else
                            throw new InvalidOperationException("Unknown character in level data");

                        p++;
                    }
                    else
                    {
                        SetWall(i, y, true);
                        greenCount++;
                    }
                 }
            }
            originalGreenCount = greenCount;
            grid = new Grid(gridLocations, sizeX, sizeY);
            CountNeighbors(grid);
            #endregion

            if (DEBUG)
            {
                gridImage = testGrid.GetImage(gridImageScale);
            }
        }
        private void CountNeighbors(Grid grid)
        {
            for (int i = 0; i < sizeX; i++)
            {
                for (int j = 0; j < sizeY; j++)
                {

                    GridLocation loc = grid.Locations[i, j];

                    if (loc.Status == GridLocationStatus.StaticWall)
                    {
                        loc.NeighborCountInit = -1;
                    }
                    else if (loc.Status == GridLocationStatus.FreeSquare)
                    {
                        loc.NeighborCount = 0;
                        if (grid.Locations[i + 1, j].Status == GridLocationStatus.FreeSquare)
                            loc.NeighborCountInit++;
                        if (grid.Locations[i - 1, j].Status == GridLocationStatus.FreeSquare)
                            loc.NeighborCountInit++;
                        if (grid.Locations[i, j - 1].Status == GridLocationStatus.FreeSquare)
                            loc.NeighborCountInit++;
                        if (grid.Locations[i, j + 1].Status == GridLocationStatus.FreeSquare)
                            loc.NeighborCountInit++;

                        if (loc.NeighborCount == 0)
                            grid.ZeroNeighborList.Add(loc);
                        else if (loc.NeighborCount == 1)
                        {
                            grid.OneNeighborList.Add(loc);
                            grid.OriginalOneNeighborList.Add(loc);
                        }
                        if (grid.OneNeighborList.Count > 1)
                        {
                            return;
                        }
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }
                }
            }
        }