Ejemplo n.º 1
0
 public FourCube(SudokuGrid sudokuGrid)
 {
     this.originalSudokuGrid = sudokuGrid;
     cubeCells = new CubeCell[4, 9, 9, 9];
     for (int row = 0; row < 9; row++)
     {
         for (int col = 0; col < 9; col++)
         {
             for (int azimuth = 0; azimuth < 9; azimuth++)
             {
                 for (int cube = 0; cube < 4; cube++)
                 {
                     cubeCells[cube, row, col, azimuth] = new CubeCell();
                 }
             }
         }
     }
     for (int row = 0; row < 9; row++)
     {
         for (int col = 0; col < 9; col++)
         {
             if (originalSudokuGrid.GetCells()[row, col] != 0)
             {
                 int azimuthalIndex = originalSudokuGrid.GetCells()[row, col] - 1;
                 for (int cube = 0; cube < 4; cube++)
                 {
                     cubeCells[cube, row, col, azimuthalIndex] = new CubeCell(1, true);
                     for (int i = 0; i < 9; i++)
                     {
                         int baseRowIndex = (row / 3) * 3;
                         int offsetRow    = i / 3;
                         int baseColIndex = (col / 3) * 3;
                         int offsetCol    = i % 3;
                         //block
                         if (baseRowIndex + offsetRow != row && baseColIndex + offsetCol != col)
                         {
                             cubeCells[cube, baseRowIndex + offsetRow, baseColIndex + offsetCol, azimuthalIndex] = new CubeCell(0, true);
                         }
                         //row
                         if (i != row)
                         {
                             cubeCells[cube, i, col, azimuthalIndex] = new CubeCell(0, true);
                         }
                         //col
                         if (i != col)
                         {
                             cubeCells[cube, row, i, azimuthalIndex] = new CubeCell(0, true);
                         }
                         //azimuth
                         if (i != azimuthalIndex)
                         {
                             cubeCells[cube, row, col, i] = new CubeCell(0, true);
                         }
                     }
                 }
             }
             else
             {
                 for (int cube = 0; cube < 4; cube++)
                 {
                     for (int azimuthalIndex = 0; azimuthalIndex < 9; azimuthalIndex++)
                     {
                         //cubeCells[cube, row, col, azimuthalIndex].GetIsClue() != true
                         if (cubeCells[cube, row, col, azimuthalIndex].GetIsClue() != true)
                         {
                             cubeCells[cube, row, col, azimuthalIndex] = new CubeCell();
                         }
                     }
                 }
             }
         }
     }
 }