Exemple #1
0
        public Grid(string filename)
        {
            logger = new MoveLogger();

            StreamReader read = new StreamReader(filename);
            string file = read.ReadToEnd();
            string[] lines = file.Split('\n');
            this.x = Int32.Parse(lines[0]);
            grid = new string[x+2, x+2];
            List<string> list = new List<string>();

            for(int i=0; i<=x+1; i++)
            {
                for(int j=0; j<=x+1; j++)
                {
                    list.Sort();
                    if((list.BinarySearch(grid[i,j]) < 0) && grid[i,j] != null)
                        list.Insert(0, grid[i, j]);

                    if (i == 0 || j == 0 || (i == x + 1) || (j == x + 1))
                   	{
                        grid[i, j] = "E";
                   	} else
                   	{
                   		grid[j,(x+1)-i] = lines[i].Substring(j-1,1);
                   	}
                }
            }
            colors = list.Count;
        }
Exemple #2
0
        public Grid(int x)
        {
            colors = 4;
            this.x = x;
            logger = new MoveLogger();

            grid = new string[x + 2, x + 2];

            Random rangen = new Random();
            string color  = "";

            for (int i = 0; i < x + 2; i++)
            {
                for (int j = 0; j < x + 2; j++)
                {
                    if (i == 0 || j == 0 || (i == x + 1) || (j == x + 1))
                    {
                        grid[i, j] = "E";
                    }
                    else
                    {
                        switch (rangen.Next(4))
                        {
                        case 0: color = "R";
                            break;

                        case 1: color = "G";
                            break;

                        case 2: color = "Y";
                            break;

                        case 3: color = "B";
                            break;
                        }
                        grid[i, j] = color;
                    }
                }
            }
        }
Exemple #3
0
        public Grid(int x)
        {
            colors = 4;
            this.x = x;
             	logger = new MoveLogger();

            grid = new string[x+2, x+2];

             	Random rangen = new Random();
              	string color = "";

            for (int i = 0; i < x + 2; i++)
            {
                for (int j = 0; j < x + 2; j++)
                {
                    if (i == 0 || j == 0 || (i == x + 1) || (j == x + 1))
                    {
                        grid[i, j] = "E";
                    }
                    else
                    {
                        switch (rangen.Next(4))
                        {
                            case 0: color = "R";
                                break;
                            case 1: color = "G";
                                break;
                            case 2: color = "Y";
                                break;
                            case 3: color = "B";
                                break;
                        }
                        grid[i, j] = color;
                    }
                }
            }
        }
Exemple #4
0
        public Grid(string filename)
        {
            logger = new MoveLogger();

            StreamReader read = new StreamReader(filename);
            string       file = read.ReadToEnd();

            string[] lines = file.Split('\n');
            this.x = Int32.Parse(lines[0]);
            grid   = new string[x + 2, x + 2];
            List <string> list = new List <string>();

            for (int i = 0; i <= x + 1; i++)
            {
                for (int j = 0; j <= x + 1; j++)
                {
                    list.Sort();
                    if ((list.BinarySearch(grid[i, j]) < 0) && grid[i, j] != null)
                    {
                        list.Insert(0, grid[i, j]);
                    }



                    if (i == 0 || j == 0 || (i == x + 1) || (j == x + 1))
                    {
                        grid[i, j] = "E";
                    }
                    else
                    {
                        grid[j, (x + 1) - i] = lines[i].Substring(j - 1, 1);
                    }
                }
            }
            colors = list.Count;
        }