Exemplo n.º 1
0
 /// <summary>
 /// Determines if the string exists in this dictionary with the specified lexicon.
 /// </summary>
 /// <param name="word">The word to search for.</param>
 /// <param name="difficulty"></param>
 /// <returns>Returns true if the word is in the dictionary and it is less than or equal to the Difficulty</returns>
 public bool Contains(string word, Difficulty diff)
 {
     if (!initialized)
     {
         throw new Exception("Word List has not been initialized.");
     }
     return(Dawg.Contains(word, diff, lexicon));
 }
Exemplo n.º 2
0
 public bool Partial(string word)
 {
     if (!initialized)
     {
         throw new Exception("Word List has not been initialized.");
     }
     return(Dawg.Partial(word));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Decodes the inputs into a dictionary node.
 /// </summary>
 /// <param name="value">The encoded character, set size, and next index.</param>
 /// <returns></returns>
 private static DawgNode DecodeNode(uint value)
 {
     return(Dawg.NodeFactory(
                (char)(((value & letterMask) >> letterShift) + 65),
                (byte)((value & setSizeMask) >> setSizeShift),
                (int)(value & nextIdxMask)
                ));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Decodes the inputs into a dictionary node.
 /// </summary>
 /// <param name="value">The encoded character, set size, and next index.</param>
 /// <param name="value2">The encoded word difficulty and lexicon.</param>
 /// <returns></returns>
 private static DawgNode DecodeAcceptNode(uint value, uint value2)
 {
     return(Dawg.NodeFactory(
                (char)(((value & letterMask) >> letterShift) + 65),
                (byte)((value & setSizeMask) >> setSizeShift),
                (int)(value & nextIdxMask),
                ((byte)((value2 & difficultyMask) >> difficultyShift)),
                ((byte)(value2 & dictionaryMask))
                ));
 }
Exemplo n.º 5
0
        /// <summary>
        /// Specifies the selected Scrabble dictionary that this dictionary contains.
        /// This must be called to generate the wordlist that the computer player uses.
        /// </summary>
        /// <param name="book">Enumeration specifing which dictionary words to select
        /// from the WordList file.</param>
        /// <param name="diff">Filters the list for difficulty of the words.</param>
        /// <param name="generateWordList">Generate the word list used by the computer player if true.</param>
        public void Set(Book book, Difficulty diff, bool generateWordList)
        {
            if (generateWordList && (lexicon != book || difficulty != diff))
            {
                wordList = Dawg.GetAllWords(diff, book);
            }

            lexicon     = book;
            difficulty  = diff;
            initialized = true;
        }
Exemplo n.º 6
0
 /// <summary>
 /// Builds the dictionary based upon the choosen word list
 /// defined by the lexicon class member.
 /// </summary>
 private static void BuildWordList()
 {
     try
     {
         Dawg.BuildDictionary(@"C:\Users\Eric\Documents\visual studio 2015\Projects\BoggleSolver\BoggleSolver\Dictionary\Dictionary2.dawg");
     }
     catch (FileNotFoundException ex)
     {
         throw new IOException("Dictionary file not found.", ex);
     }
 }