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

D

Daniel Pitts

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.
 
L

Lew

Daniel said:
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.
 
R

Roedy Green

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
..
 
D

Daniel Pitts

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.
 
R

Roedy Green

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
..
 
G

Gene Wirchenko

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
 
R

Roedy Green

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
..
 
L

Lew

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.
 
L

Lew

Roedy said:
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"?
 
G

Gene Wirchenko

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.


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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top