Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Hangman Assistant

by Lawliet (Curate)
on Jul 12, 2009 at 05:21 UTC ( #779310=note: print w/ replies, xml ) Need Help??


in reply to Re: Hangman Assistant
in thread Hangman Assistant

You make a good point, and I made the following change to the my program:

# Find how close each letter is to half of the total word possibilitie +s to ensure maximum gain every guess after being sorted foreach my $occur (keys %alphabet) { $alphabet{$occur} = abs($#narrowed/2 - abs($alphabet{$occur} - $#n +arrowed + 1)); } say $_ foreach @narrowed; # Word list say $#narrowed + 1; say sort { $alphabet{$a} <=> $alphabet{$b} } keys %alphabet; # Sort as +cendingly; whichever letter is closest to 0, i.e., and therefore whic +hever letter will eliminate the most words.

However, as I play, I notice that although it does eliminate a lot of words very quickly, when it gets to a low amount of words, it becomes useless, telling me to guess letters that are not in any of the words, and telling me to guess letters that are in all of the words last.

Surely, when it comes to this point, the user can easily guess on his own but that is not really the point. I want the program to be able to find the individual word in a small amount of guesses. Perhaps I should use your method when there are more than, say, 10 possibilities, and mine from there on out.

Example illustrating my point:

$ perl hangman.pl "_ _ _ _ _ _ _ _" "" _ _ _ _ _ _ _ _ 0 10588 rantislodecgupmhbyfkwvxzqj $ perl hangman.pl "_ _ _ _ _ _ _ _" "r" _ _ _ _ _ _ _ _ r 5252 atlnsieodcgumhpbyfkwvxzqjr $ perl hangman.pl "_ _ _ _ _ _ _ _" "ra" _ _ _ _ _ _ _ _ r|a 2761 tolnsdgueichpmbfykwvxzqjra $ perl hangman.pl "_ _ _ _ _ t _ _" "ra" _ _ _ _ _ t _ _ r|a 165 isncdolupmghbfykvxejqwtraz $ perl hangman.pl "_ _ _ _ _ t i _" "ra" _ _ _ _ _ t i _ r|a bulletin cosmetic despotic dietetic domestic eclectic ecliptic egoistic elliptic esthetic eutectic holistic hypnotic logistic phonetic quixotic theistic 17 slhpodungmxytieqbwrajkfvcz $ perl hangman.pl "_ _ _ _ _ t i _" "ras" _ _ _ _ _ t i _ r|a|s bulletin dietetic eclectic ecliptic elliptic eutectic hypnotic phonetic quixotic 9 unohlpxdytiqbwrajkgfvmscze $ perl hangman.pl "_ _ _ _ _ t i _" "rasu" _ _ _ _ _ t i _ r|a|s|u dietetic eclectic ecliptic elliptic hypnotic phonetic 6 dyhtincowraxjukgfevmslqbzp $ perl hangman.pl "_ _ _ _ _ t i _" "rasud" _ _ _ _ _ t i _ r|a|s|u|d eclectic ecliptic elliptic hypnotic phonetic 5 yticwraxdjukhgfenvmspqbzol $ perl hangman.pl "_ _ _ _ _ t i _" "rasudy" _ _ _ _ _ t i _ r|a|s|u|d|y eclectic ecliptic elliptic phonetic 4 wraxdjyukhgftienvmslcpqbzo $ perl hangman.pl "_ _ _ _ _ t i _" "rasudyw" _ _ _ _ _ t i _ r|a|s|u|d|y|w eclectic ecliptic elliptic phonetic 4 wraxdjyukhgftienvmslcpqbzo

I am kind of speaking to myself here, so this node is just publishing my own mental thoughts. Feel free to comment or object them.

I don't mind occasionally having to reinvent a wheel; I don't even mind using someone's reinvented wheel occasionally. But it helps a lot if it is symmetric, contains no fewer than ten sides, and has the axle centered. I do tire of trapezoidal wheels with offset axles. --Joseph Newcomer


Comment on Re^2: Hangman Assistant
Select or Download Code
Re^3: Hangman Assistant
by ikegami (Pope) on Jul 14, 2009 at 05:24 UTC

    it becomes useless, telling me to guess letters that are not in any of the words

    That would indicate a bug in the implementation, not a problem in the approach as you claim.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://779310]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2014-12-29 00:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (183 votes), past polls