Esempio n. 1
0
        static void Main(string[] args)
        {
            var dictionary = Core.WordListProvider.GetWordList();
            var scorer     = new Core.Scorer(dictionary);

            if (!VerifySolvers(s_solvers, "ritqwtagsceopkyr", dictionary, scorer, 194, 335))
            {
                return;
            }
            if (!VerifySolvers(s_solvers, "gnessripetaltseb", dictionary, scorer, 1351, 4540))
            {
                return;
            }

#if !DEBUG
            Console.WriteLine("All solvers passed.  Starting Benchmarks...");

            BenchmarkRunner.Run <Program>();
#endif

            foreach (var solver in s_solvers)
            {
                (solver as IDisposable)?.Dispose();
            }
        }
Esempio n. 2
0
        private static bool VerifySolvers(List <Core.SolverBase> solvers, string board, IEnumerable <string> dictionary, Core.Scorer scorer, int expectedWords, int expectedScore)
        {
            var boardSize = (int)Math.Sqrt(board.Length);
            var success   = true;

            foreach (var solver in solvers)
            {
                solver.Init(dictionary, boardSize);
                var(words, score) = scorer.Score(solver.Solve(board));
                solver.Reset();
                if (words != expectedWords)
                {
                    Console.WriteLine($"{solver.GetType().Name} found {words} words, but we expected {expectedWords}.");
                    success = false;
                    continue;
                }
                if (score != expectedScore)
                {
                    Console.WriteLine($"{solver.GetType().Name} scored {score}, but we expected {expectedScore}.");
                    success = false;
                    continue;
                }
            }
            return(success);
        }