Example #1
0
        /// <summary>
        /// Loads the word list for the selected level:
        /// 1. 2-5 letters
        /// 2. 6-8 letters
        /// 3. 9+ letters
        /// 4. custom length (max 27)
        /// </summary>
        /// <param name="level">Integer between 1 and 4 corresponding to the selected level</param>
        /// <param name="custom">Custom word length (will only load if level == 4)</param>
        private void LoadLevel(int level, int custom)
        {
            Random        rand = new Random();
            List <string> levelWordList;

            switch (level)
            {
            case 1:
                int lengthOfWord = rand.Next(2, 6);
                levelWordList = File.ReadAllLines("dictionaries\\" + lengthOfWord + "letterwords.txt").ToList();
                break;

            case 2:
                lengthOfWord  = rand.Next(6, 9);
                levelWordList = File.ReadAllLines("dictionaries\\" + lengthOfWord + "letterwords.txt").ToList();
                break;

            case 3:
                lengthOfWord  = rand.Next(9, 16);
                levelWordList = File.ReadAllLines("dictionaries\\" + lengthOfWord + "letterwords.txt").ToList();
                break;

            case 4:
                levelWordList = File.ReadAllLines("dictionaries\\" + custom + "letterwords.txt").ToList();
                break;

            default:
                throw new NotImplementedException();
            }
            currentWordFamily = new WordFamily(levelWordList.ToArray(), guessedLetters, true);
        }
Example #2
0
        /// <summary>
        /// Try to cheat by using the set game mode
        /// </summary>
        /// <param name="guess">The user supplied guess that is being evaluated</param>
        private void TryToCheat(char guess)
        {
            WordFamily newFamily = currentWordFamily.GetNewOptimumWordFamily(guess, guessedLetters, mode);

            Debug.DebugMessage("Trying to cheat... current top word - " + currentWordFamily.words[0] + " new top word " + newFamily.words[0], 4);
            currentWordFamily = newFamily;
        }
Example #3
0
        /// <summary>
        /// Gets the new optimum word family (choice of mode)
        /// 1 - Largest word family
        /// 2 - Letter frequency score
        /// 3 - Decision tree (not implemented)
        /// </summary>
        /// <param name="guess">Guessed letter this round</param>
        /// <param name="guessedLetters">All guessed letters so far</param>
        /// <param name="mode">Algorithm to use (see method summary)</param>
        /// <returns></returns>
        public WordFamily GetNewOptimumWordFamily(char guess, string guessedLetters, int mode)
        {
            switch (mode)
            {
            case 1:
                WordFamily newFamily = new WordFamily(this.ComputeLargestWordFamily(ComputeSubFamilies(guess)).ToArray(), guessedLetters, false);
                return(newFamily);

            case 2:
                newFamily = new WordFamily(ComputeOptimumByFrequency(ComputeSubFamilies(guess)), guessedLetters, false);
                return(newFamily);

            default:
                throw new NotImplementedException();
            }
        }
Example #4
0
        /// <summary>
        /// Uses default (largest word family) method to get the next optimum word family
        /// </summary>
        /// <param name="guess">The new guess letter</param>
        /// <param name="guessedLetters">Letters already guessed</param>
        /// <returns></returns>
        public WordFamily GetNewOptimumWordFamily(char guess, string guessedLetters)
        {
            WordFamily newFamily = new WordFamily(this.ComputeLargestWordFamily(this.ComputeSubFamilies(guess)).ToArray(), guessedLetters, false);

            return(newFamily);
        }