Example #1
0
        /// <summary>
        /// Provides a hint to the player, will show all available anagrams for the letters
        /// in their rack.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnHint_Click(object sender, EventArgs e)
        {
            var anagrams = WordSolver.Anagrams(PlayerManager.CurrentPlayer.Tiles, null);
            var hintText = "With the tiles in your rack you can make the following words:";

            anagrams.ForEach(a => hintText += $"\n{a.Text} ({a.Score})");

            MessageBox.Show(hintText, "Word Hint", MessageBoxButtons.OK);
        }
Example #2
0
        private static WordSolver CreateWordSolver(string[] args)
        {
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.WriteLine("SCRABBLE HELPER");
            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("\nReading word list and building tree...");

            // Create the solver.
            DateTime startIndex = DateTime.Now;
            string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string defaultFilePath = Path.Combine(path, "dsso-1.46.txt");
            FileInfo file = new FileInfo(args.Length == 1 ? args[0] : defaultFilePath);
            WordSolver solver = new WordSolver(new SwedishWordList(file));
            TimeSpan indexTime = DateTime.Now - startIndex;

            Console.WriteLine("\n # Indexed {0} words in {1:f} seconds.", solver.IndexedWordCount, indexTime.TotalSeconds);
            Console.WriteLine(" # Limiting results to the 5 best matches.");
            Console.WriteLine(" # Exit the program by pressing ENTER.\n");
            return solver;
        }