One Card Poker is a fast-paced card game for Alexa. Can you predict if your unknown card can beat Alexa's revealed card? Play for fun or use it to train your card-counting abilities to increase your odds of winning!
Installing & Using One Card Poker- Enable the "
One Card Poker"
Skill
- Start using it! For example, say "
Alexa, start One Card Poker
".
The game, also known as "Blind Man's Bluff", is traditionally based off of "bluffing" other players, that is, tricking them into thinking they have a bad card. Each player is dealt one card, face down. Players then take their card - without looking at it - and place it on their forehead for their opponents to see. After this, a round of betting would ensue as players attempt to intimidate their opponents into folding. After the round of betting is complete, the remaining players look at their cards and the player with the highest card wins!
Building an Alexa VersionTo keep the game simple and fast-paced for an ideal voice experience, I removed the multi-player and betting aspects of the game. Using an API capable of generating, shuffling, and distributing a deck of cards - appropriately named "Deck of Cards API" - I was able to utilize the session storage properties of the Alexa Skills Kit to keep track of a user's gameplay without having to worry about building an entire card deck utility.
Here is a basic breakdown of the Skill's programming logic, in the general order of which they occur during gameplay:
- User starts the Skill, causing the Skill to generate a shuffled deck of cards using the Deck of Cards API.
- User begins gameplay by saying "
play
", causing the Skill to distribute a card from the deck to Alexa and to the player. The cards are stored in session storage.
- Alexa reveals her card to the player and asks the player if they think they can beat it.
- The player responds with a "
yes
" intent (yes/stay) or a "no
" intent (no/fold), causing Alexa to reveal the outcome, track the win or loss and the number of cards remaining in the deck, and distribute another round of cards, effectively repeating the previous step.
- The player will continue this process until they exit the Skill via the "
stop"
intent or play through the entire deck of cards (26 rounds).
To better understand how people are using the Skill and how long they typically play for at a time, I integrated Voice Insights analytics into the Skill. Here's a small preview of the insights gathered from the analytics integration:
More on how to integrate Voice Insights into your own copy of One Card Poker in a moment.
Create a Copy of One Card Poker with Analytics!- Clone/download the code from the repository
- Create a Lambda function with an Alexa Skills Kit event source (tutorial here).
- Create a new Alexa Skill with the Lambda ARN (Amazon Resource Name) generated from the step prior (tutorial here) using the Amazon Developer Portal.
- Modify the APP_ID variable on line 9 of src/index.js to be your Skill's Application ID. Save the file.
- Register for a VoiceLabs account and create an Alexa Voice Insights application so we can track detailed analytics about the Skill's usage.
- Modify the VI_APP_TOKEN variable on line 13 of src/index.js to be your Voice Insights Analytics API Key. Save the file.
- Create a ZIP file containing all the files and directories within the src directory of the cloned repository.
- Upload the ZIP file as your Lambda Function Package in the Code tab. Save the Lambda function.
- Complete the Alexa Skill Configuration checklist until all tasks before Test have a green checkmark. You may use the contents of the files in the speechAssets directory to complete the corresponding Interaction Model settings, or you may create your own to customize the experience.
You are now able to test your Skill on your Alexa device using the Invocation Name you provided in the Skill Information settings! After taking your new Skill for a spin, take a look at your Voice Insights dashboard to see the awesome metrics being captured (unique users, time spent per session, user retention, etc)!
Comments