Can you beat the Sumerian host at GoFish?
Using Amazon Sumerian, Amazon Lex, AWS Lambda, and Amazon DynamoDB, we’ll create a Sumerian scene as a visual interface for the game.
2 players, 26 cards total. 7 cards for each player to start. Take turns asking for a drink card. Try to match two of the same drink card to get two points. Each player can only ask for one card per turn.
Drink cards:
- Amaretto Sour
- Bloody Mary
- Cosmopolitan
- Long Island Ice Tea
- Mai Tai
- Margarita
- Martini
- Mojito
- Moscow Mule
- Old Fashioned
- Pina Colada
- Whiskey Sour
- White Russian
- Must use AWS region
us-east-1
- Amazon DynamoDB - database for saving game state
- AWS Lambda - runs business logic invoked by Lex
- AWS CloudFormation - to create and manage most of these resources
- Amazon Lex - process our natural language from the game Sumerian scene
- Amazon Sumerian - UI; displays a host and the cards
- Amazon Cognito - allows Sumerian access to AWS Services
Setup Instructions
-
Must use AWS region
us-east-1
-
Setup - LambdaSharp Tool (aka lash)
-
Upgrade lash
dotnet tool uninstall -g LambdaSharp.Tool dotnet tool install -g LambdaSharp.Tool --version 0.7.0-rc7 lash --version
OR
-
Install lash
dotnet tool install -g LambdaSharp.Tool --version 0.7.0-rc7 lash --version
-
-
Initialize a LambdaSharp environment
lash init --quick-start
Level 0 Instructions
-
Clone GoFish repository
git clone git@github.com:LambdaSharp/SumerianGoFish.git cd SumerianGoFish
-
Create resources for the game
lash deploy Game
This will create:
- Lambda Function with Game Logic
- DynamoDB table to store game state
- S3 Bucket to store card images
- Cognito Identity Pool to connect Sumerian with AWS Services
Copy values for use later in this challenge.
In the AWS Console, navigate to CloudFormation
:
(1) Cognito Pool Id
- Search
Sumerian-GoFish
, click on the result, then click on theResources
section. - Search for
SumerianCognitoIdentityPool
- Find and copy the Physical Id for
SumerianCognitoIdentityPool
(2) GoFishGame Database
- While still in the
Resources
, searchGoFishSessions
- Find and copy the Physical Id for
GoFishSessions
(3) GoFish Lambda Arn
- Click on the
Outputs
section - Copy the Lambda function ARN for the Key
GoFish
Level 1 Instructions
Create a service role for the lex bot:
aws iam create-service-linked-role --aws-service-name lex.amazonaws.com
NOTE: If you get a message that the role already exists or has been taken, skip this step
Alternative Version: This step can also be performed via the AWS Console:
- Navigate to Amazon IAM service:
- From the left navigation, click the Roles section
- Find role AWSServiceRoleForLexBots -- if it exists, skip the next step of creating the role
- Click the Create Role button
- Choose Lex; then Lex Bots at the bottom of the page
- Continue Next: Tags
- Continue Next: Review
- Create Role
In a text editor:
- open
Lex/GoFishBot.json
. - Find/replace
PASTE_LAMBDA_ARN_HERE
with the (3) GoFish Lambda Arn copied earlier. - Zip the
GoFishBot.json
, name itGoFishBot.zip
IMPORTANT: IT MUST BE THE ONLY FILE AND NOT IN A DIRECTORY
In your terminal run the following command from the root of the project:
aws lex-models start-import --resource-type BOT --merge-strategy FAIL_ON_CONFLICT --payload fileb://Lex/GoFishBot.zip
In the AWS Console, navigate to Amazon Lex service:
- Edit the
GoFishBot
Build
andPublish
. For the alias, enter anything you'd like (i.e. Prod, Latest, etc).- Copy values for later:
- (4) LexBot Name Name of the LexBot (
GoFishBot
) - (5) LexBot Alias Alias entered when publishing the Lex Bot
- (4) LexBot Name Name of the LexBot (
- Try
Test Chatbot
by speaking or typingnew game
.
You could try playing GoFish with the Lex Bot but we have no idea what the game state is.
Level 2 Instructions
In the AWS Console, navigate to Sumerian -- make sure you are in the us-east-1
region.
- Under the heading
Create scene from template
choose theempty
scene, name itGoFish Challenge
- On the left side, Entities, there should only be
GoFish Challenge
and under it,Default Camera
; if there's something else, delete it. - Click the
Import Assets
link in the top center of the page - On the right there's a window that says
Import from Disk
, choose theSumerian/GoFishSumerian.zip
file
Delete the default camera:
- On the left side, Entities, click
Fixed Camera
- On right side, click
Camera
, make it theMain Camera
- On the left side, Entities, delete the
Default Camera
Add the Cogitno Pool Id to the Sumerian scene:
- On the left side Entities, click on
GoFish Challenge
- On the right side, click on
Aws Configuration
- Paste the (1) Cognito Pool Id copied from earlier into the
Cognito Pool Id
field
Level 3 Instructions
Add a host to the scene
- Use the
Import Assets
and search forhost
. Choose a host. - In the bottom left in the Assets section, find the name of the host with a hexagon next to it; click and drag it onto the scene
NOTE: If you don't see your host, it's just very small. We'll fix it in the next steps.
Configure the host.
- On the left side Entities, click on the host name
- On the right side, click
Transform
and change theXYZ
for the scale to 10, 10, 10
-
On the right side, click the host name
-
Add a Custom Attributes value for
databaseName
with (2) GoFishGame DatabaseNOTE: Be sure to use the NAME of the database and not the ARN
- On the right side, click
Speech
- Add the speech file
GameIntro
from the Assets
- On the right side, click
Host
- Change the point of interest to be the
Fixed Camera
entity
- Add a component
Script
- Add the script file
GameScripts
from the Assets
- Add a component
Dialogue
- Paste the (4) LexBot Name and (5) LexBot Alias of your Lex Bot in the fields
- Add a component
State Machine
- Add the behavior
GoFishChatBot
from the Assets
Play the scene. To start, press the space bar and say new game
.
NOTE: Don't forget to click the scene after starting. Also, it may take a few seconds for the host to respond the first time as the lambda function has a cold start.
Level 4 Instructions
In the AWS Console, navigate to Sumerian and open this project.
- On the top left side Entities, click the host
Grace Polo
- On the right side click
Scripts
, then click theGameScripts
edit pencil icon - Add the card name with the image
Level 5 Instructions
In the AWS Console, navigate to Sumerian and open this project.
- On the top left side Entities, click the host
Grace Polo
- On the right side click
State Machine
, then click theGoFishChatBot
edit pencil icon - In the state machine, Add a state between the
Start
andWait for Input
that will tell the user what to do when they enter the scene.- Add state; name it
Introduction
- Add an action in the
Introduction
state forStart Speech
; use theGameIntro
speech text
- Add state; name it
NOTE: You can change the
GameIntro
speech. Use Amazon Polly to test your SSML!
Boss Instructions
In a text editor:
- Edit the
WhichCardToAskFor
method in fileGame/GoFish/AskForCard.cs
It currently asks only for a martini.
Maybe it could ask for cards in it's hand?
But then the player will know which cards the host has.
What can you do?
To re-deploy the function run lash deploy Game
Want More?
We barely touched the tip of the iceberg of what's possible in Amazon Sumerian.
Try adding something else to the scene!
- Add some flair to the
Game Over
messaging. - Add Captions to the Game using the Turning Amazon Lex Responses into Text tutorial as a guide.
- You already have an assets bucket from this challenge... try to Stream video from S3.
- For the
Introduction
state, gestures are pretty easy to implement. Use the Using a Host and Speech Components tutorial. - Add an easter egg, Flying a Drone around the screen with your keyboard.
Or try a different Amazon Sumerian tutorial or Amazon Sumerian Article. Some are quick and definitely fun to implement!