What is a smart algorithm for generating letters in a Letterpress iOS game?

I have played Letterpress many times lately.

The goal of the game is to a large extent to score as many blue plates as possible by pronouncing the words from the letters on the board. When you play a word, the letters that make up the word will turn blue unless the letter is surrounded by red plates.

The regular Presspress panel looks like this:

pjPwZ.png

I realized that the letters on the board should be generated using some kind of rules, otherwise it will be very difficult to play games with some boards. I could only think of a rule where there should be several vowels. I wonder if there are other rules.

Also, I am wondering if this will be something similar to making Boggle dices.

+6
source share
2 answers

I decided to crack the solution based on user166390 suggestion. The frequencies you see relate to English taken from Wikipedia. By executing the program several times and just looking at the results, they look pretty gaming for me. As a rule, I can find a few four- or five-letter words, and I'm not even very good at playing! Anyway, here is the code:

#!/usr/bin/env python from random import random from bisect import bisect_left letters = [c for c in "abcdefghijklmnopqrstuvwxyz"] frequencies = [8.167, 1.492, 2.782, 4.253, 12.702, 2.228, 2.015, 6.094, 6.966, 0.153, 0.772, 4.025, 2.406, 6.749, 7.507, 1.929, 0.095, 5.987, 6.327, 9.056, 2.758, 0.978, 2.360, 0.150, 1.974, 0.074] cumulative_frequencies = [sum(frequencies[0:i+1]) for i in xrange(len(frequencies))] for i in xrange(5): line = "" for j in xrange(5): line += letters[bisect_left(cumulative_frequencies, random() * cumulative_frequencies[-1])] + " " print line 

The idea is for each letter generated to use the roulette wheel algorithm to select it randomly with a probability proportional to the given frequencies.

+4
source

I heard that Lauren Brichter, the developer, talks about it, but I can’t forget where. I think it was a Guy Ritchie Debug podcast, but I'm not sure. I remember a few things.

It guarantees at least a certain number of vowels.

Consonants are generated separately from vowels. This implies separate distribution of letters.

He did his own vocabulary analysis after game to come up with a distribution of letters.

If Q is chosen, then I am guaranteed, so the word Q is always possible with Q.

I play a lot. For some reason, I never had the end of the game, but all the letters were used. I do not know if this guaranteed that every letter could always be possible, but it seems to be practically true, even if it is not respected.

+1
source

All Articles