示例#1
0
        public DebugSudoku2()
        {
            int i, j;

            _cells = new Cell[9][];
            _numberOfItemsPossibleToSetRow    = new int[9][];
            _numberOfItemsPossibleToSetColumn = new int[9][];
            _numberOfItemsPossibleToSetSquare = new int[9][];
            _squareIndex = new TwoTupleOfIntegers[9][];

            for (i = 0; i < 9; i++)
            {
                _squareIndex[i] = new TwoTupleOfIntegers[9];
                _cells[i]       = new Cell[9];
                _numberOfItemsPossibleToSetRow[i]    = new int[9];
                _numberOfItemsPossibleToSetColumn[i] = new int[9];
                _numberOfItemsPossibleToSetSquare[i] = new int[9];
            }

            for (i = 0; i < 9; i++)
            {
                for (j = 0; j < 9; j++)
                {
                    _squareIndex[i][j] = new TwoTupleOfIntegers((3 * (i / 3)) + (j / 3), (3 * (i % 3)) + (j % 3));
                }
            }

            for (i = 0; i < 9; i++)
            {
                for (j = 0; j < 9; j++)
                {
                    _cells[i][j] = new Cell(new TwoTupleOfIntegers(i, j), 0, false);
                }
            }
        }
示例#2
0
文件: Sudoku2.cs 项目: cjonasl/Sudoku
 public Cell(TwoTupleOfIntegers position, int itemValue, bool originalData)
 {
     this.position           = position;
     this.itemValue          = itemValue;
     this.originalData       = originalData;
     possibleItemValuesToSet = new ArrayList();
 }
示例#3
0
文件: Sudoku2.cs 项目: cjonasl/Sudoku
        public SudokuBoard()
        {
            int i, j;

            _cells = new Cell[9][];
            _numberOfItemsPossibleToSetRow    = new int[9][];
            _numberOfItemsPossibleToSetColumn = new int[9][];
            _numberOfItemsPossibleToSetSquare = new int[9][];
            _squareIndex = new TwoTupleOfIntegers[9][];

            for (i = 0; i < 9; i++)
            {
                _squareIndex[i] = new TwoTupleOfIntegers[9];
                _cells[i]       = new Cell[9];
                _numberOfItemsPossibleToSetRow[i]    = new int[9];
                _numberOfItemsPossibleToSetColumn[i] = new int[9];
                _numberOfItemsPossibleToSetSquare[i] = new int[9];
            }

            for (i = 0; i < 9; i++)
            {
                for (j = 0; j < 9; j++)
                {
                    _squareIndex[i][j] = new TwoTupleOfIntegers((3 * (i / 3)) + (j / 3), (3 * (i % 3)) + (j % 3));
                }
            }

            for (i = 0; i < 9; i++)
            {
                for (j = 0; j < 9; j++)
                {
                    _cells[i][j] = new Cell(new TwoTupleOfIntegers(i, j), 0, false);
                }
            }

            _cellsRemainToSet = new ArrayList();
            _dataSetBeforeSimulationHasBeenDone = new ArrayList();
            _simulationHasBeenDone = false;

            _random = new Random((int)(DateTime.Now.Ticks % (long)int.MaxValue));

            _debugLopNr = 0;

            _debugSudoku2 = new DebugSudoku2();
        }
示例#4
0
文件: Sudoku2.cs 项目: cjonasl/Sudoku
        private ArrayList ReturnData(ArrayList originalData)
        {
            ArrayList data = new ArrayList();

            Sudoku.ThreeTupleOfIntegers threeTupleOfIntegers;
            TwoTupleOfIntegers          position;
            int itemValue;

            for (int i = 0; i < originalData.Count; i++)
            {
                threeTupleOfIntegers = (Sudoku.ThreeTupleOfIntegers)originalData[i];
                position             = new TwoTupleOfIntegers(threeTupleOfIntegers.rowIndex, threeTupleOfIntegers.columnIndex);
                itemValue            = threeTupleOfIntegers.item;
                data.Add(new Cell(position, itemValue, true));
            }

            return(data);
        }