// //统计行、列、宫有效数信息 protected void Statics_Cell_Buffer(int row, int col, int type) { int nNums = this.Statics_Cell(row, col, type); Statics_buff pStatics = new Statics_buff(row, col, nNums, type); if (nNums == 9) { pStatics.setLock(true); } _statics[pStatics.Tag] = pStatics; }
//修正统计各格子可用数据数 protected bool Statics(int row, int col, int delta = 1) { //行、列、宫 _statics[Statics_buff.getTag(row, 0, 0)].setNums(delta); _statics[Statics_buff.getTag(0, col, 1)].setNums(delta); int rowCell = getCellInd_Row(row); int colCell = getCellInd_Col(col); _statics[Statics_buff.getTag(rowCell, colCell, 2)].setNums(delta); return(true); }
//统计获取第一个种子 protected (int, int) getSolve_Next() { _statics = _statics.OrderByDescending(p => p.Value.Nums).ToDictionary(p => p.Key, o => o.Value); Statics_buff pStatics_buff = _statics.Values.First(); if (pStatics_buff.Type == 0) { for (int j = 0; j < this._cols; j++) { int value = _values[pStatics_buff.X, j]; if (!checkValue(value)) { return(pStatics_buff.X, j); } } } else if (pStatics_buff.Type == 1) { for (int i = 0; i < this._rows; i++) { int value = _values[i, pStatics_buff.Y]; if (!checkValue(value)) { return(i, pStatics_buff.Y); } } } else if (pStatics_buff.Type == 2) { //计算9宫格的数据区间 int rowMin = pStatics_buff.X * _rowsCell; int rowMax = rowMin + _rowsCell; int colMin = pStatics_buff.Y * _colsCell; int colMax = colMin + _colsCell; for (int i = rowMin; i < rowMax; i++) { for (int j = colMin; j < colMax; j++) { int value = _values[i, j]; if (!checkValue(value)) { return(i, j); } } } } return(-1, -1); }