There are plenty of word guessing games in the Alexa skill store, but after a quick review, I noticed a lot of complains on their difficulty. There are several reasons but the most prominent ones are:
- Issues with the difficulty of the game: The choice of words seem to be a problem as there are complaining about either it being too easy or too difficult.
- Issues with speech recognition: Recognizing single letters is counterintuitively difficult.
- Issues with timing: Alexa has a rather short timeout when it comes to accepting responses. It will offer a reprompt after 8 seconds and will wait an additional 8 seconds to close the session if there is no response. Several people complains this is not enough time for thinking. I decided to implement a new word guessing game to address the previous issues and learn something while doing it.
What it does
Alexa will think of a word and will tell you its first letter and how many letters are in it. Then you will take turns trying to guess it. In each turn, you will guess a letter and Alexa will tell you whether the letter is in the word or not. If the letter is not in the word you will lose a life. If you lose all your lives before you guess all he letters of the word it's game over.
In order to make the game more accessible to a wider audience, in the beginning, Alexa will choose short nouns and verbs but it will select increasingly difficult words as you progress. But the features that I was really interested in implementing that were lacking in existing word guessing games were:
- You can ask for a clue or a hint any time you need one.
- After each guess, Alexa will send a card to your Alexa app with and image to help you track your progress and remaining lives.
The skill uses several workarounds to improve response recognition. It will prompt users to use words from the phonetic alphabets (alpha, bravo, Charlie, delta, echo, Frank...) or words starting with the letter they are trying to guess. It supports four ways to providing responses:
- Guess E.
- Check for the letter E.
- E as in Elephant. In order to provide sample utterances for all the possible combinations, I used a script to generate them automatically. It's available on my Github: https://github.com/josepvalls/ask.py/blob/master/utterance-generator.py
Finally, in order to deal with the 8 second timeout, my skills supports both single-turn and multi-turn interactions seamlessly. Even if there is a timeout, the session information is handled so the user can continue their game either opening the skill again or just requesting a guess using single turn interactions. In order to support both and minimize costs when persisting session information, the session data is serialized into a dictionary that can be kept in the Alexa's session JSON and persisted to DynamoDB when the sessions is closed. Again, there is example code in my Github https://github.com/josepvalls/ask.py
How I built it
Some time ago I realized most tutorials on Alexa's skills were based on Node.js. I personally prefer Python so I developed my own framework to build voice interfaces. The framework is available on my Github and you can find more information in a recent project I published.
What I learned
In this project I experimented with two features of the Alexa API I was not familiar beforehand:
- Card images
What's next for Easy Hangman
I am planning on connecting the skill to a knowledge API (such as ConceptNet) in order to provide clues based on descriptions and similar words.