示例#1
0
        public Sudoku(List<int> values)
        {
            Difficulty = 1;
            Rem1 = -1;
            Rem2 = -1;
            Rem3 = -1;
            NrSolutions = 0;

            Fields = new Field[9][];
            for (int i = 0; i < 9; i++)
            {
                Fields[i] = new Field[9];
                for (int j = 0; j < 9; j++)
                {
                    Fields[i][j] = new Field(i, j);
                }
            }

            // Llenar el sudoku con los valores dados
            int a = 0;
            int b = 0;
            for (int x = 0; x < values.Count; x++)
            {
                if (values[x] != 0)
                {
                    Fields[b][a].Value = values[x];
                    Fields[b][a].NewFound = true;
                    Fields[b][a++].Filled = true;
                }
                else
                    a++;
                if (a > 8)
                {
                    a = 0;
                    b++;
                }
            }
        }
示例#2
0
        public Sudoku(TextBox[][] values)
        {
            Difficulty = 1;
            Rem1 = -1;
            Rem2 = -1;
            Rem3 = -1;
            NrSolutions = 0;

            Fields = new Field[9][];
            for (int i = 0; i < 9; i++)
            {
                Fields[i] = new Field[9];
                for (int j = 0; j < 9; j++)
                {
                    Fields[i][j] = new Field(i, j);
                    if (values[i][j].Text != "")
                    {
                        Fields[i][j].Value = int.Parse(values[i][j].Text);
                        Fields[i][j].NewFound = true;
                        Fields[i][j].Filled = true;
                    }
                }
            }
        }
示例#3
0
 private GameController()
 {
     field = new Field();
     active = new IntPoint(-1, -1);
 }
示例#4
0
 public void clean()
 {
     active = new IntPoint(-1, -1);
     field = new Field();
 }
示例#5
0
 public bool BelongsToBox(int i, int j, Field f)
 {
     int iStart = i - i % 3;
     int jStart = j - j % 3;
     if (f.i >= iStart && f.i <= iStart + 2 && f.j >= jStart && f.j <= jStart + 2)
         return true;
     else
         return false;
 }
示例#6
0
 public Field Copy()
 {
     Field Result = new Field(i, j);
     foreach (int ii in Candidates)
         Result.Candidates.Add(ii);
     Result.Filled = Filled;
     Result.Value = Value;
     Result.NewFound = NewFound;
     return Result;
 }