Don't ask to ask, just ask | |
PerlMonks |
Re^4: Hangman Assistantby Limbic~Region (Chancellor) |
on Jul 13, 2009 at 13:38 UTC ( [id://779579]=note: print w/replies, xml ) | Need Help?? |
Lawliet,
then shaving off 50% each time is more helpful than eliminating the 10% that don't have the recommended, most common letter That's not the way it works. At least not how I understand the game. So let's say you have a really common word with common letters and you pick the most common letter amongst the possible candidates. If you pick a letter that is correct, you gain new information (the position of that letter) and you don't get penalized for a wrong guess. As long as you keep guessing correct letters you can go on forever. Additionally, you still prune your candidate list because even though lots of words have the same letter - they don't all have them in the same position. If the letter is wrong, well then you purge the majority of the words in your candidate list. You haven't convinced me approach isn't superior to the binary search of blokhead's. It can easily be tested - just modify the code for each algorithm to output "win <total_guesses> <wrong_guesses>" or "lose" rather than the verbose output. Then write a wrapper script that tests both algorithms against 10_000 randomly selected words. You can then gather statistics on which algorithm produced the most wins and for the wins, the average number of guesses required and the average number of wrong guesses used. Oh, and they should both "lose" after the same number of wrong guesses - my code defaults to 7 but is configurable. Cheers - L~R
In Section
Cool Uses for Perl
|
|