### Archive

Archive for the ‘Uncategorized’ Category

## Migration

Although I will be keeping this blog for a (long) while up, I will not be adding any other posts or pages in the future.

After much deliberation, I decided to do the migration to a new platform, hosted for free in my github. It involves a great deal of hacking, but in spite of all the extra work, the move is totally worthwhile.

Categories: Uncategorized

## Jotto (5-letter Mastermind) in the NAO robot

I would like to show how to code the NAO robot to beat us at Jotto (5-letter Mastermind) with python in Choregraphe. I will employ a brute force technique that does not require any knowledge of the English language, the frequency of its letters, or smart combinations of vowels and consonants to try to minimize the number of attempts. It goes like this:

1. Gather all 5-letter words with no repeated letters in a list.
2. Choose a random word from that list—your guess—, and ask it to be scored ala Mastermind.
3. Filter through the list all words that share the same score with your guess; discard the rest.
4. Go back to step 2 and repeat until the target word is found.

Coding this strategy in python requires only four variables:

• whole_dict: the list with all the words
• step = [x for x in whole_dict]: A copy of whole_dict, which is going to be shortened on each step (hence the name). Note that stating step = whole_dict will change the contents of whole_dict when we change the contents of step — not a good idea.
• guess = random.choice(step): A random choice from the list step.
• score: A string containing the two digits we obtain after scoring the guess. The first digit indicates the number of correct letters in the same position as the target word; the second digit indicates the number of correct letters in the wrong position.
• attempts: optional. The number of attempts at guessing words. For quality control purposes.

At this point, I urge the reader to stop reading the post and try to implement this strategy as a simple script. When done, come back to see how it can be coded in the NAO robot.