static void Main(string[] args) { sudoku = new Sudoku(); refreshSolver(); bool Quitter = false; do { Console.WriteLine("\n\n\n Résolution de Sudoku\n"); for (int i = 0; i < solvers.Count; i++) { Console.WriteLine(" " + i + ". " + solvers[i].Name); } Console.WriteLine(" " + (solvers.Count) + ". Benchmark Easy"); Console.WriteLine(" " + (solvers.Count + 1) + ". Benchmark Hardest"); Console.WriteLine(" " + (solvers.Count + 2) + ". Benchmark Top 95"); Console.WriteLine(" " + (solvers.Count + 3) + ". Benchmark Custom"); Console.WriteLine(" " + (solvers.Count + 4) + ". Quitter"); Console.WriteLine("\n Que voulez vous faire ?"); int choix = int.Parse(Console.ReadLine()); var watch = Stopwatch.StartNew(); watch.Stop(); float elapsedMs; if (choix >= 0 && choix < solvers.Count) { Console.WriteLine("\n /*--------------------" + solvers[choix].Name + "--------------------*/\n"); watch = Stopwatch.StartNew(); solvers[choix].Solve(); watch.Stop(); elapsedMs = watch.ElapsedMilliseconds; Console.WriteLine("\n\n SOLVED IN : " + elapsedMs + " ms\n\n"); if (solvers[choix].Sudoku.validationSudoku()) { Console.WriteLine(" !!! FELICITATION !!! : Ce sudoku est validé"); } solvers[choix].Sudoku.showTwoSudoku(); Console.WriteLine("\n /*--------------------FIN " + solvers[choix].Name + "--------------------*/\n"); } else if (choix == solvers.Count) { showScore(benchmark(sudoku.getFile("Sudoku_Easy50.txt")), 50, "Easy"); } else if (choix == solvers.Count + 1) { showScore(benchmark(sudoku.getFile("Sudoku_hardest.txt")), 11, "Hardest"); } else if (choix == solvers.Count + 2) { showScore(benchmark(sudoku.getFile("Sudoku_Top95.txt")), 95, "Top 95"); } else if (choix == solvers.Count + 3) { List <Dictionary <String, float> > scores = new List <Dictionary <string, float> >(); for (int i = 30; i >= 17; i--) { scores.Add(benchmark(customSudoku(i))); foreach (KeyValuePair <String, float> score in scores[-i + 30]) { if (score.Value > 5000 || score.Value < 0) { for (int j = 0; j < solvers.Count; j++) { if (solvers[j].Name == score.Key) { solvers.RemoveAt(j); break; } } } } } refreshSolver(); for (int i = 30; i >= 17; i--) { showScore(scores[-i + 30], 10, "" + i); } } else if (choix == solvers.Count + 4) { Quitter = true; } } while (!Quitter); Console.WriteLine("\n\n\n FIIIIIN"); Console.ForegroundColor = ConsoleColor.Yellow; }
static void Main(string[] args) { sudoku = new Sudoku(); solvers = new List <ISudokuSolver>(); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { foreach (var objType in assembly.GetTypes()) { if (typeof(ISudokuSolver).IsAssignableFrom(objType) && !(typeof(ISudokuSolver) == objType)) { solvers.Add((ISudokuSolver)Activator.CreateInstance(objType)); } } } bool Quitter = false; do { Console.WriteLine("\n\n\n Résolution de Sudoku\n"); for (int i = 0; i < solvers.Count; i++) { Console.WriteLine(" " + i + ". " + solvers[i].Name); } Console.WriteLine(" " + (solvers.Count) + ". Benchmark Easy"); Console.WriteLine(" " + (solvers.Count + 1) + ". Benchmark Hardest"); Console.WriteLine(" " + (solvers.Count + 2) + ". Benchmark Top 95"); Console.WriteLine(" " + (solvers.Count + 3) + ". Benchmark Custom"); Console.WriteLine(" " + (solvers.Count + 4) + ". Quitter"); Console.WriteLine("\n Que voulez vous faire ?"); int choix = int.Parse(Console.ReadLine()); var watch = Stopwatch.StartNew(); watch.Stop(); float elapsedMs; if (choix >= 0 && choix < solvers.Count) { Console.WriteLine("\n /*--------------------" + solvers[choix].Name + "--------------------*/\n"); watch = Stopwatch.StartNew(); solvers[choix].Solve(); watch.Stop(); elapsedMs = watch.ElapsedMilliseconds; Console.WriteLine("\n\n SOLVED IN : " + elapsedMs + " ms\n\n"); if (solvers[choix].Sudoku.validationSudoku()) { Console.WriteLine(" !!! FELICITATION !!! : Ce sudoku est validé"); } solvers[choix].Sudoku.showTwoSudoku(); Console.WriteLine("\n /*--------------------FIN " + solvers[choix].Name + "--------------------*/\n"); } else if (choix == solvers.Count) { benchmark(sudoku.getFile("Sudoku_Easy50.txt")); } else if (choix == solvers.Count + 1) { benchmark(sudoku.getFile("Sudoku_hardest.txt")); } else if (choix == solvers.Count + 2) { benchmark(sudoku.getFile("Sudoku_Top95.txt")); } else if (choix == solvers.Count + 3) { int nb = 10; String[] lines = new String[nb]; for (int i = 0; i < nb; i++) { lines[i] = sudoku.create(25); } benchmark(lines); } else if (choix == solvers.Count + 4) { Quitter = true; } } while (!Quitter); Console.WriteLine("\n\n\n FIIIIIN"); Console.ForegroundColor = ConsoleColor.Yellow; }