Slightly off-topic: Determining the strength of "Hangman" word.

Discussion in 'Java' started by Daniel Pitts, May 31, 2012.

  1. Daniel Pitts

    Daniel Pitts Guest

    I've been playing a bit of Zynga's "Hanging with friends". I was
    thinking about how to go about creating an "aid" for this. I don't
    cheat, but I like solving these kinds of problems, just to prove I can.

    There are two phases in Hanging with Friends. One phase is to guess the
    word that your opponent has constructed, and the other phase is to
    construct a word yourself.

    In the construction phase, you are given a "bag" of 12 letters. I'm not
    sure if its a completely random distribution. I suspect its weighted in
    some way. Anyway, that's not relevant for this question.

    So, It is relatively easy to write a program that uses a word list (such
    the "official scrabble dictionary" word lists in the Moby collection),
    to find all words in that list that can be constructed from the bag.

    The problem is determining the strength of the word, how hard it is to
    guess.

    There is probably a psychological component to this, since the "average"
    player isn't likely to use logic and will more likely just "guess"
    letters that seem likely. A program (or expert) has the advantage
    (somewhat) in that it can figure out statistically which letters are
    most likely based on the remaining possible words, and it would then
    "guess" that letter. Although I'm not certain that is actually the most
    effective strategy either.

    The algorithm for the "guess-ability" of a word is made more complicated
    by the fact that the word itself effects how many failed guesses
    opponent can have before losing the round. I'm not sure what the
    algorithm is for that, though I suspect it has to do with the number of
    distinct letters and word-length.

    Any thoughts on algorithms or data structures you might use to solve
    this kind of problem?

    I've solved parts of this already. I've created "LetterBag", "Word",
    "LetterSet", and "WordIndex" classes.

    The WordIndex makes it easy to find "All words that match a pattern, but
    don't contain letters in a specific LetterSet" and "All words that can
    be made from a specific LetterBag".

    Oh, and to tie this into a previous thread, the whole thing fits in
    memory with room to spare ;-)

    Thanks,
    Daniel.
    Daniel Pitts, May 31, 2012
    #1
    1. Advertising

  2. Daniel Pitts

    Lew Guest

    Daniel Pitts wrote:
    > I've been playing a bit of Zynga's "Hanging with friends". I was
    > thinking about how to go about creating an "aid" for this. I don't
    > cheat, but I like solving these kinds of problems, just to prove I can.
    >
    > There are two phases in Hanging with Friends. One phase is to guess the
    > word that your opponent has constructed, and the other phase is to
    > construct a word yourself.
    >
    > In the construction phase, you are given a "bag" of 12 letters. I'm not
    > sure if its a completely random distribution. I suspect its weighted in
    > some way. Anyway, that's not relevant for this question.
    >
    > So, It is relatively easy to write a program that uses a word list (such
    > the "official scrabble dictionary" word lists in the Moby collection),
    > to find all words in that list that can be constructed from the bag.
    >
    > The problem is determining the strength of the word, how hard it is to
    > guess.
    >
    > There is probably a psychological component to this, since the "average"
    > player isn't likely to use logic and will more likely just "guess"
    > letters that seem likely. A program (or expert) has the advantage
    > (somewhat) in that it can figure out statistically which letters are
    > most likely based on the remaining possible words, and it would then
    > "guess" that letter. Although I'm not certain that is actually the most
    > effective strategy either.
    >
    > The algorithm for the "guess-ability" of a word is made more complicated
    > by the fact that the word itself effects how many failed guesses
    > opponent can have before losing the round. I'm not sure what the
    > algorithm is for that, though I suspect it has to do with the number of
    > distinct letters and word-length.
    >
    > Any thoughts on algorithms or data structures you might use to solve
    > this kind of problem?
    >
    > I've solved parts of this already. I've created "LetterBag", "Word",
    > "LetterSet", and "WordIndex" classes.
    >
    > The WordIndex makes it easy to find "All words that match a pattern, but
    > don't contain letters in a specific LetterSet" and "All words that can
    > be made from a specific LetterBag".
    >
    > Oh, and to tie this into a previous thread, the whole thing fits in
    > memory with room to spare ;-)


    You could run a neural net over words opponents have constructed
    in historical games and run it as a predictor for new games.

    www.syncleus.com
    has an open-source NN (and more) implementation.

    --
    Lew
    Lew, May 31, 2012
    #2
    1. Advertising

  3. Daniel Pitts

    Roedy Green Guest

    On Thu, 31 May 2012 09:26:11 -0700, Daniel Pitts
    <> wrote, quoted or indirectly
    quoted someone who said :

    >Oh, and to tie this into a previous thread, the whole thing fits in
    >memory with room to spare ;-)


    Here are three ideas:

    What you need to do is collect a giant hunk of random text from
    various websites and compute a word frequency for each word in your
    bag. The lower the frequency, the harder it is to guess.

    Another measure would to compare your word with every other word in
    the bag. The more letters it has in common in the corresponding slot
    the harder it would be guess.

    Look for rare letter pairs. These are EASY to guess.

    --
    Roedy Green Canadian Mind Products
    http://mindprod.com
    Controlling complexity is the essence of computer programming.
    ~ Brian W. Kernighan 1942-01-01
    ..
    Roedy Green, May 31, 2012
    #3
  4. Daniel Pitts

    Daniel Pitts Guest

    On 5/31/12 10:43 AM, Roedy Green wrote:
    > On Thu, 31 May 2012 09:26:11 -0700, Daniel Pitts
    > <> wrote, quoted or indirectly
    > quoted someone who said :
    >
    >> Oh, and to tie this into a previous thread, the whole thing fits in
    >> memory with room to spare ;-)

    >
    > Here are three ideas:
    >
    > What you need to do is collect a giant hunk of random text from
    > various websites and compute a word frequency for each word in your
    > bag. The lower the frequency, the harder it is to guess.

    Perhaps, though low usage-frequency doesn't mean it isn't easy to guess.
    For example "exterminate" isn't a very common word, but a person would
    probably get to "e?ter?in?te" with very will problems, and from there,
    exterminate is the only possibility. "mixt" is probably a more difficult
    word to guess. The progression is likely to be "?i??", (guess s,e,l,n,t)
    "?i?t", (guess r,f). At this point, the game would be over. There would
    be two possibilities left, "mixt" and "dipt". People don't seem to
    think of "xt", so they might be more likely to guess "dipt".

    This is of course, assuming they guess in the "highest letter frequency"
    order.

    >
    > Another measure would to compare your word with every other word in
    > the bag. The more letters it has in common in the corresponding slot
    > the harder it would be guess.
    >
    > Look for rare letter pairs. These are EASY to guess.

    The problem is that some words are false positives. They seem ambiguous
    for the most part, but one letter absolutely gives it away.
    Daniel Pitts, May 31, 2012
    #4
  5. Daniel Pitts

    Roedy Green Guest

    On Thu, 31 May 2012 11:34:23 -0700, Daniel Pitts
    <> wrote, quoted or indirectly
    quoted someone who said :

    >The problem is that some words are false positives. They seem ambiguous
    >for the most part, but one letter absolutely gives it away.


    This is a messy problem. For every guessing strategy you need a
    different algorithm to determine difficulty. But if you have enough
    algorithms that each say produce a number 0..1 you can take the max as
    the guessability or the sum, or something in between that gives extra
    weight to high components (sum of cubes?)
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com
    Controlling complexity is the essence of computer programming.
    ~ Brian W. Kernighan 1942-01-01
    ..
    Roedy Green, Jun 1, 2012
    #5
  6. On Fri, 01 Jun 2012 02:55:52 -0700, Roedy Green
    <> wrote:

    >On Thu, 31 May 2012 11:34:23 -0700, Daniel Pitts
    ><> wrote, quoted or indirectly
    >quoted someone who said :
    >
    >>The problem is that some words are false positives. They seem ambiguous
    >>for the most part, but one letter absolutely gives it away.

    >
    >This is a messy problem. For every guessing strategy you need a
    >different algorithm to determine difficulty. But if you have enough
    >algorithms that each say produce a number 0..1 you can take the max as
    >the guessability or the sum, or something in between that gives extra
    >weight to high components (sum of cubes?)


    Suppose someone games your choice of algorithms by choosing words
    to give bad results by those algorithms.

    Sincerely,

    Gene Wirchenko
    Gene Wirchenko, Jun 1, 2012
    #6
  7. Daniel Pitts

    Roedy Green Guest

    On Fri, 01 Jun 2012 09:34:15 -0700, Gene Wirchenko <>
    wrote, quoted or indirectly quoted someone who said :

    > Suppose someone games your choice of algorithms by choosing words
    >to give bad results by those algorithms.



    I understood the game to allow me to know the list of words in the bag
    before I start play. Is that correct?
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com
    Controlling complexity is the essence of computer programming.
    ~ Brian W. Kernighan 1942-01-01
    ..
    Roedy Green, Jun 1, 2012
    #7
  8. Daniel Pitts

    Lew Guest

    Gene Wirchenko wrote:
    > Roedy Green wrote:
    >> Daniel Pitts wrote, quoted or indirectly quoted someone who said :
    >>> The problem is that some words are false positives. They seem ambiguous
    >>> for the most part, but one letter absolutely gives it away.

    > >
    >> This is a messy problem. For every guessing strategy you need a
    >> different algorithm to determine difficulty. But if you have enough
    >> algorithms that each say produce a number 0..1 you can take the max as
    >> the guessability or the sum, or something in between that gives extra
    >> weight to high components (sum of cubes?)


    Not really. A statistical approach, that is, analysis of a large number of games
    for frequency of words chosen, number of guesses by the opponent and if
    the opponent guessed the word, should account for strategies that include
    picking "easy" words and how well that works.

    You don't even need to know the guessing strategies involved.

    > Suppose someone games your choice of algorithms by choosing words
    > to give bad results by those algorithms.


    They'd have to know what the algorithms are, and there has to be such a
    thing as a "bad result". A statistical approach uses facts - what actually
    happened. This is hard to game. If a player picks a word that is easy to
    guess, then their opponent is likely to guess it quickly. This is especially true
    if the results from games are fed back into the learning system so that it
    can adapt to sneaky opponents.

    --
    Lew
    Lew, Jun 1, 2012
    #8
  9. Daniel Pitts

    Lew Guest

    Roedy Green wrote:
    > I understood the game to allow me to know the list of words in the bag
    > before I start play. Is that correct?


    Isn't that true of all word games?

    Or do I misunderstand what you mean by "in the bag"?

    --
    Lew
    Lew, Jun 1, 2012
    #9
  10. On Fri, 1 Jun 2012 12:45:21 -0700 (PDT), Lew <>
    wrote:

    >Gene Wirchenko wrote:
    >> Roedy Green wrote:
    >>> Daniel Pitts wrote, quoted or indirectly quoted someone who said :
    >>>> The problem is that some words are false positives. They seem ambiguous
    >>>> for the most part, but one letter absolutely gives it away.
    >> >
    >>> This is a messy problem. For every guessing strategy you need a
    >>> different algorithm to determine difficulty. But if you have enough
    >>> algorithms that each say produce a number 0..1 you can take the max as
    >>> the guessability or the sum, or something in between that gives extra
    >>> weight to high components (sum of cubes?)

    >
    >Not really. A statistical approach, that is, analysis of a large number of games
    >for frequency of words chosen, number of guesses by the opponent and if
    >the opponent guessed the word, should account for strategies that include
    >picking "easy" words and how well that works.
    >
    >You don't even need to know the guessing strategies involved.
    >
    >> Suppose someone games your choice of algorithms by choosing words
    >> to give bad results by those algorithms.

    >
    >They'd have to know what the algorithms are, and there has to be such a
    >thing as a "bad result". A statistical approach uses facts - what actually


    You mean like getting hanged?

    >happened. This is hard to game. If a player picks a word that is easy to
    >guess, then their opponent is likely to guess it quickly. This is especially true
    >if the results from games are fed back into the learning system so that it
    >can adapt to sneaky opponents.


    I tend to play weighting my guesses by frequency ("etoainshrdlu"
    and all that). Someone could pick words that that does not work well
    for. If someone knows your strategy, they can game it.

    Sincerely,

    Gene Wirchenko
    Gene Wirchenko, Jun 1, 2012
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Kraus
    Replies:
    1
    Views:
    992
  2. John O'Conner
    Replies:
    1
    Views:
    470
    totojepast
    Jan 30, 2004
  3. PowerSlave2112

    A Legal Question (slightly off-topic)

    PowerSlave2112, Jan 25, 2005, in forum: HTML
    Replies:
    6
    Views:
    490
    Starshine Moonbeam
    Jan 26, 2005
  4. Gaijinco

    Recursion (slightly off-topic)

    Gaijinco, Nov 20, 2005, in forum: C++
    Replies:
    2
    Views:
    283
    John C
    Nov 20, 2005
  5. Ken Fine
    Replies:
    3
    Views:
    366
    Steven Cheng [MSFT]
    Jun 23, 2008
Loading...

Share This Page