static void Main(string[] args) { ConsoleHelper.SetCurrentFont("Consolas", 40); Console.OutputEncoding = Encoding.UTF8; Console.CursorVisible = false; const int N = 8; const int displayDelay = 0; var nQueen = new NQueen(N, displayDelay); var sw = new Stopwatch(); sw.Start(); var result = nQueen.Go(slow: false); sw.Stop(); nQueen.DisplayBoard(0); Console.WriteLine($"N={N} {(result ? "has a solution" : "does not have a solution")}"); Console.WriteLine($"Time taken: {sw.ElapsedTicks / 10000}ms"); }
private static void Main(string[] args) { var watch = System.Diagnostics.Stopwatch.StartNew(); var problem = new NQueen(15); //var problem = new Equation2(); AlgoParam.ChromosomeLength = problem.VariableCount; AlgoParam.GeneMin = problem.VariableMin; AlgoParam.GeneMax = problem.VariableMax; var algo = new Algorithm(problem.CalculateFitness); var bestSolution = algo.FindBestSolution(); Console.WriteLine($"Chromosome: {bestSolution}, Fitness:{bestSolution.Fitness}"); watch.Stop(); Console.WriteLine($"Elapsed time in Milliseconds: {watch.ElapsedMilliseconds}"); Console.ReadLine(); }
public void TestQueenSolver() { var r = NQueen.NqueenSolver(8); Assert.AreEqual(r.Count, 92); }
public void TestNqueenResultNumber() { var r = NQueen.NqueenResultNumber(8); Assert.AreEqual(r, 92); }