Hide and Seek, playful puppies, and mazes. This super kid-friendly trifecta was the inspiration for Find the Puppy. Not only are they instantly appealing to children, but they also translate well into an interactive, voice-only experience. On top of that, picturing (simple) mazes in your head helps develop spatial visualization skills.

What it does

Alexa informs you that the puppy is hiding in one of the rooms in the house, and it’s up to you to find him. You start in the entryway and move from room to room by telling Alexa where to go. Alexa tells you the color and direction of each door, along with the name of the room when you enter.

As you play, you hear sounds of the puppy barking, softly at first, and more loudly as you get closer.

When you find the puppy, a new card is added to your Alexa App, showing you the full layout of the house. The picture shows where the puppy was hiding and all the doors in their proper color, open or closed depending on where you went.

Behind the scenes

Building a maze in a large house

The “house” is a simple maze, newly generated for every game. The skill starts with a grid based on the size of the house requested by the player: small, medium, or large. It then generates a random maze by making doorways in the walls between the rooms.

A few extra doors are added next. This makes the layout more realistic and creates the possibility of loops and shortcuts, which is less frustrating than having to completely backtrack along an unsuccessful path.

For medium and large houses, some rooms are enlarged by removing a wall. This makes the layout more interesting and slightly increases the challenge of mentally keeping track where you are.

Finally, the puppy’s hiding place is selected, room names are assigned, and door colors are chosen.

How I built it

The skill is written entirely in Python, which is running with Apache using mod_wsgi. I used MySQL for the small amount of record keeping that was required.

One part of the code contains the PuppyGame and Room classes and handles all the maze generation and state management. Methods PuppyGame.State() and PuppyGame.SetState() are used by the code to return the game state in each Alexa Response and reload it when receiving each Alexa Request. This way the web services are entirely stateless, and Amazon keeps track of the state associated with each player session.

The second part supplies the WSGI interface, accepts Alexa Requests, and returns Alexa Responses. It also performs all the mandatory security checks, which I wrote from scratch rather than depend on external libraries (assuming I could find any).

The WSGI application also handles web requests for the Alexa App card images. When the Python code gets a request for the image, it loads the game state and generates the corresponding PNG image on the fly. This was also done in Python, using the Pillow library.


A lot of attention was paid to the details, to make the game as natural and fun as possible. Here are some of the things I did:

  1. Almost everything said by Alexa has many variations. This makes the dialog more natural and really helps avoid players getting bored by repetition. This was helped tremendously by the Amazon Echo Utterance Expander. For example, this string

    ({}/You (/can) hear (the/your) puppy (/barking/waiting for you/in his hiding place) (very close/(/very) nearby/in the next room/just one room away). {}/{} (The/Your) (puppy sounds (/like he is)/puppy's hiding place (sounds/must be)/puppy must be hiding/is (/hiding)) very (near/nearby/close/close by).)

    expands into 137 unique ways to say the same thing.

  2. Voice responses paint a consistent description of the environment and your actions. When you’ve used a door, it is described as “an open <color> door” from that point onward. When you return to a room you’ve already visited, Alexa says so, in a variety of ways, of course.

  3. The maze generation ensures that no wall ever has more than one door, even in an elongated room. It also ensures that no room ever has more than one door of any given color.

  4. To make it easier for new players, Find the Puppy doesn’t ask what size house you want to play in until after you’ve played the game three times.

  5. Testing showed that players want to give directions before Alexa is done speaking, and the Echo isn’t listening yet. By always ending every spoken response with, “Which way?”, children quickly learn they need to give their direction then, even if they had said it before, while Alexa was speaking.

  6. All the basic built-in intents, such as AMAZON.YesIntent, AMAZON.RepeatIntent, etc., are supported. It’s much friendlier to accept a yes or no response when that’s the natural thing to say, than to require a specific phrase. Because things like “Yes” can mean many different things in different contexts, but always map to the same intent, some careful state management is required.

  7. There are some easter eggs of a sort in the game. When entering a room, Alexa might say something funny or relevant about the room. These extras are added with low probability, to occasionally give players something unexpected.

Built With

Share this project: