Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Hangman Assistant

by Limbic~Region (Chancellor)
on Jul 13, 2009 at 00:41 UTC ( #779426=note: print w/replies, xml ) Need Help??


in reply to Re: Hangman Assistant
in thread Hangman Assistant

blokhead,
I disagree with your strategy based on my limited knowledge of the game hangman. It is my understanding that the game continues until you have either revealed the word or made too many incorrect guesses. I think the best strategy then would be to guess the letter that appears in the most of the candidate words. I too haven't looked at the OP's code but my strategy doesn't necessarily pick the most popular letter but the one that appears in the most words. If you are correct you get new information (position of that letter) and are no closer to losing the game. If you are wrong, you eliminate the most possible wrong answers. I will code this strategy up to see how it does in a follow on post.

Cheers - L~R

Replies are listed 'Best First'.
Re^3: Hangman Assistant
by Lawliet (Curate) on Jul 13, 2009 at 05:03 UTC

    Those were my thoughts too. However, if the user picked an extremely common word, with common letters (which makes it a common word), then shaving off 50% each time is more helpful than eliminating the 10% that don't have the recommended, most common letter.

    Of course this is all theoretical and should be tested before changes are made (which I failed to do initially).

    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

      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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://779426]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2017-10-21 16:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (270 votes). Check out past polls.

    Notices?