The Tech Behind Two Blocks Away
“The aim of the game will be to fill in the board’s missing components with the blocks, and when ready, trigger AWS Rekognition, in conjunction with a Raspberry Pi button. The user will receive feedback about whether or not the board was completed successfully.”
Two Blocks Away is a game that invites a user to solve an architecture puzzle by placing physical blocks on a board that interacts with AI services.
How does it work?
To make the game, the team makes use of a screen, a Raspberry Pi button, several raspberry Pis, a camera and some large blocks. The screen displays a game board, and the blocks have the names of AWS services printed on them. The board itself is an incomplete architecture puzzle that the user is challenged to solve with the services listed on the blocks. By placing two blocks on the screen and pressing the Raspberry Pi button, the user attempts to solve the puzzle
The game begins when the user submits a webform which is sent to an API. This triggers a lambda function, which then writes the form data to the database.
When the user presses the Raspberry Pi button, the Raspberry Pi takes an image capture of the board and sends the photo up to S3 for storage.
When the photo is added to S3, it triggers a lambda which executes the game logic. If the user’s try is correct, the user’s level is incremented in the database, and the user advances to the next screen. Otherwise, the user is invited to try the current level again.
The Tech: AI and Serverless
Two Blocks Away uses an AI service offered by AWS called Amazon Rekognition. Amazon Rekognition makes it easy to add image and video analysis to your applications. Amazon Rekognition offers a variety of AI services, and Two Blocks Away uses the DetectText service to locate text on the physical blocks used to complete the architecture challenge. This works by taking a photo of the board with a Raspberry Pi camera and then sending that photo to the DetectText service. Subsequently, the response from that service lets the application know if a user was correct or not.
After detecting text, the DetectText response is a representation of detected words and lines of text, including the relationship between them. This response is then parsed by a Lambda which sets the game’s state.
The Serverless element of Two Blocks Away is the use of AWS Lambda.
AWS Lambda is a serverless offering from AWS. The Two Blocks Away project makes use of several Lambda functions to execute logic without provisioning servers.
One of the main benefits of AWS Lambda is that when using AWS Lambda, you are responsible only for your code. AWS manages the rest.
Moreover, AWS Lambda was appealing to the Two Blocks team as it is an ideal computing platform for many of the use cases involved in creating the application. For a lightweight, three-tier application, serverless technology appealed to the Two Blocks Away team.