コード例 #1
0
        private void Resolve(Grille sudoku, bool thenDisplay = false)
        {
            var worker = new BackgroundWorker();

            worker.DoWork += (s, ev) =>
            {
                var watch = Stopwatch.StartNew();
                watch.Start();
                sudoku.Resolve();
                watch.Stop();
                sudoku.SolvingTime = watch.ElapsedMilliseconds;
            };
            if (thenDisplay)
            {
                worker.RunWorkerCompleted += (s, ev) =>
                {
                    updateView();
                };
            }
            worker.RunWorkerAsync();
        }
コード例 #2
0
        public void ForceBrute()
        {
            var cellsByHypotesisNumber = from c in Cells
                                         where !c.Resolved
                                         orderby c.Hypotheses.Count()
                                         select c;

            foreach (var cell in cellsByHypotesisNumber)
            {
                foreach (var choice in cell.Hypotheses)
                {
                    var trial   = new Grille(this);
                    var changed = trial.Cells.Single(c => c.X == cell.X && c.Y == cell.Y);
                    changed.Value = choice;
                    trial.Resolve();
                    if (trial.IsValid && trial.Resolved)
                    {
                        copy(trial);
                    }
                }
            }
        }
コード例 #3
0
 private void Resolve(Grille sudoku,bool thenDisplay = false)
 {
     var worker = new BackgroundWorker();
     worker.DoWork += (s, ev) =>
     {
         var watch = Stopwatch.StartNew();
         watch.Start();
         sudoku.Resolve();
         watch.Stop();
         sudoku.SolvingTime = watch.ElapsedMilliseconds;
     };
     if (thenDisplay)
     {
         worker.RunWorkerCompleted += (s, ev) =>
         {
             updateView();
         };
     }
     worker.RunWorkerAsync();
 }
コード例 #4
0
ファイル: Grille.cs プロジェクト: arjuna-goutier/ProjetCsAL2
 public void ForceBrute()
 {
     var cellsByHypotesisNumber = from c in Cells
                                  where !c.Resolved
                                  orderby c.Hypotheses.Count()
                                  select c;
     foreach (var cell in cellsByHypotesisNumber)
     {
         foreach (var choice in cell.Hypotheses)
         {
             var trial = new Grille(this);
             var changed = trial.Cells.Single(c => c.X == cell.X && c.Y == cell.Y);
             changed.Value = choice;
             trial.Resolve();
             if (trial.IsValid && trial.Resolved)
                 copy(trial);
         }
     }
 }