private void testHypothesis(string Hypothesis, List <CellsGrid> testList, Cell cell) { testList.Add(new CellsGrid(testList.Last())); Console.Out.WriteLine(testList.Last()); Cell realCell = testList.Last()[cell.PosX, cell.PosY]; testList.Last().cantResolve = false; lastTextLogLevel = ModeText.Verbose; TextLog = String.Format("test value {0} at ({1},{2})", Hypothesis, realCell.PosX, realCell.PosY); if (realCell == null) { Log(ModeText.Error, "cell is null"); } realCell.Value = Hypothesis; realCell.diffuseInItsEnsemble(); //Console.Out.WriteLine(testList.Last()); testList.Add(testList.Last().resolveGrid()); profondeur++; if (testList.Last().cantResolve == true) { testList.Remove(testList.Last()); testList.Remove(testList.Last()); testList.Last().cantResolve = true; Log(ModeText.Verbose, "RollBack"); } }
private void testHypothesis(string Hypothesis, List <CellsGrid> testList, Cell cell) { testList.Add(new CellsGrid(this)); Console.Out.WriteLine(testList.Last()); Cell realCell = this[cell.PosX, cell.PosY]; this.cantResolve = false; Log(ModeText.Verbose, String.Format("test value {0} at ({1},{2})", Hypothesis, realCell.PosX, realCell.PosY)); realCell.Value = Hypothesis; realCell.diffuseInItsEnsemble(); //Console.Out.WriteLine(testList.Last()); this.resolveGrid(); if (this.cantResolve == true) { CellsGrid saveGrid = testList.Last(); testList.Remove(testList.Last()); foreach (Cell saveCell in saveGrid.grid) { this.grid[saveCell.PosX, saveCell.PosY].Value = saveCell.Value; this.grid[saveCell.PosX, saveCell.PosY].hypothesis.Clear(); this.grid[saveCell.PosX, saveCell.PosY].hypothesis.AddRange(saveCell.hypothesis); } testList.Last().cantResolve = true; Log(ModeText.Verbose, "RollBack"); } }