/// <summary> /// This method aims to discover the value of a tile by a process of elimination. /// The idea is to look at the plot, and see, if there is only a single tile, where /// a given value can be placed. /// </summary> /// <param name="plotIndex">index of the plot.</param> /// <returns></returns> private bool PlotEliminationCheck(int plotIndex) { TilePlot currentPlot = this.grid.Plots[plotIndex]; if (currentPlot.IsFull()) { return(false); } bool returnable = false; for (int i = 1; i <= StandardSize; i++) { if (currentPlot.IsDigitConfirmed(i)) { continue; } Tile correctNumberTile = null; int possibilities = 0; for (int j = 0; j < StandardSize; j++) { Tile currentTile = currentPlot.Tiles[j]; if (currentTile.IsValueSet()) { continue; } if (currentTile.IsDigitPossible(i)) { correctNumberTile = currentTile; possibilities++; } } if (possibilities == 1) { correctNumberTile.Value = i; returnable = true; } } return(returnable); }
/// <summary> /// This method checks off all the known values in a plot for a given tile. /// </summary> /// <param name="plotIndex">Index of the plot.</param> /// <param name="tileIndex">index of the tile.</param> private void PlotCheck(int plotIndex, int tileIndex) { TilePlot currentPlot = this.grid.Plots[plotIndex]; Tile currentTile = currentPlot.Tiles[tileIndex]; if (currentTile.IsValueSet()) { return; } for (int i = 0; i < StandardSize; i++) { Tile tileOfinterest = currentPlot.Tiles[i]; if (tileOfinterest.IsValueSet()) { currentTile.CrossOffDigit(tileOfinterest.Value); } } }