Zum Inhalt springen

How I Create a Hanged Man Python game with AWS Q CLI : for AWS Services as a guide for certification exam in minutes

This blog entry will demonstrate on how to build a command line game with Python programming language, but we will use AWS Q CLI to develop the game for us.

Screenshot of the game

Disclaimer: This blog entry is part of the AWS Game challenge in the community to create a game with the help of AWS Q CLI

To start with if you have not installed the Q CLI yet, please consult with this page for instruction. https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-installing.html

If you wish to get the source code of the game (in python), you can find it in https://github.com/guxkung/hangman-aws-services

As I frequently take Certification exam and sometimes switching the domain would require me to look up at the service name and definition (too often than I would like to confess), I think wrapping that process up into a game would be something I believe some might see benefits of it as well.

The process is straight-forward enough and AWS Q CLI can get my point without much of the hurdle, but specifying the domain and giving out sufficient keywords for it to catch up on your idea is very similar to project kick-off or grooming in my opinion.

With the use of AI, the skeletal and foundation of the program can be done mostly by AI. We just need to review and check whether there are mistakes in critical path of the processes or misconceptions or hallucinations happened.

For this simple game, I would say it saves me hours of programming from scratch. And it even generate a stub of README.md in the final process as well, it was great.

the first quote I put Q CLI to work with was:

Hello, I want to try and explore capabilities of Amazon Q. This time I wish to build a Hanged man game (word guessing) with AWS provided services as the keyword while providing the description

The response was:

Hello! I'd be happy to help you build a Hangman game that uses AWS service names as the keywords along with their descriptions. This is a fun way to learn about AWS services while playing a game.


Let's create a simple Python-based Hangman game that:
1. Randomly selects AWS services as words to guess
2. Provides the service description as a hint
3. Implements the classic Hangman gameplay mechanics

Here's how we can implement this: (see v1 in github repository)

Let me save this file for you:

The first version of the playable game would look like this.

Welcome to AWS Hangman!
Guess the AWS service name based on its description.

Hint: Fully managed extract, transform, and load service that makes it easy to prepare and load data for analytics

           --------
           |      |
           |      
           |      
           |      
           |     
           -

Word: _ _ _ _


Please guess a letter or the full word: glue
Hint: Fully managed extract, transform, and load service that makes it easy to prepare and load data for analytics

           --------
           |      |
           |      
           |      
           |      
           |     
           -

Word: G L U E
Letters guessed: 
Words guessed: 
Tries left: 6

It is so easy to get a proof of concept setup, but it was not yet reaching of what I set as objective of this game. So I asked Q CLI to improve it even further before we can do a full review. The query was:

let's make the service more advanced and perhaps make it suitable for AWS certification test takers to get a quick recap of what they need to be aware of and perhaps add an update feature available would be appreciated as well.

The response was:

I'll enhance the Hangman game to make it more suitable for AWS certification test takers with additional features for learning and review. Let's create a more advanced version with:

1. Difficulty levels based on certification types
2. More comprehensive service descriptions
3. An update feature to add new services or modify existing ones
4. Score tracking and statistics
5. Category filtering (compute, storage, database, etc.)
6. Learning mode with detailed explanations

I apologize for the timeout. Let's break this down into smaller steps to create an enhanced AWS Hangman game that's useful for certification test takers.

Let's start by creating a basic version of the game with an expanded AWS service database and then add features incrementally:

I apologize for the timeout. You're right - let's break this down into smaller steps to create a more advanced AWS Hangman game for certification test takers. I'll create the enhanced version incrementally.

Let's start by creating the basic structure with an expanded AWS services database that includes certification-relevant information:

(see v2 in github repository)

Now, let’s add the game mechanics and certification-focused features:

 ● Completed in 0.1s
I've created an enhanced AWS Hangman game specifically designed for certification test takers! This version includes several advanced features to help you learn and review AWS services while having fun.

## Key Features

1. Expanded AWS Service Database:
   • 20 AWS services with detailed descriptions
   • Categorized by service type (Compute, Storage, Database, etc.)
   • Difficulty levels (Easy, Medium, Hard)
   • Certification-specific study notes for each service

2. Learning-Focused Gameplay:
   • Shows certification study tips after each game
   • Filter games by service category or difficulty level
   • Score system that rewards tackling harder services

3. Content Management:
   • Add new AWS services with your own descriptions and study notes
   • Update existing service information as AWS evolves
   • Persistent storage of services in a JSON file

4. Game Statistics:
   • Track your progress with win/loss statistics
   • Monitor your performance over time

## How to Play

1. Run the game by executing python aws_hangman.py
2. Choose from the main menu options:
   • Play Game: Start a standard game with random service selection
   • Filter by Category: Play with services from a specific category (Compute, Storage, etc.)
   • Filter by Difficulty: Choose Easy, Medium, or Hard services
   • Add New AWS Service: Expand the database with custom entries
   • Update Existing Service: Modify descriptions or study notes
   • View Statistics: See your game performance

During gameplay, you'll:
• See a description of an AWS service
• Guess letters or the full service name
• After completing the game, see certification study notes for that service
• Earn points based on the difficulty level

## Try It Out!

The game is ready to play! I've created two files:
1. aws_hangman.py - The main game code
2. aws_services.json - A database of AWS services with certification notes

To start playing and studying for your AWS certification, simply run:
python aws_hangman.py


This game will help you memorize AWS service names, understand what they do, and learn key certification exam points in an engaging way. You can also customize it by adding more services or updating the study
notes as you learn new information.

Would you like me to explain any specific part of the implementation in more detail?
(see v3 in github repository)

To enhance it even further, I ask Q CLI with the following quote to add auto definition update.

For a starter, I think that is very impressive. However, I think if the Service list itself can be automatically updated with reliable source and up-to-date with updates for the exam themselves that would be superb.
I agree that automatic updates would make this tool even more valuable for exam preparation. Let's enhance the AWS Hangman game to fetch the latest AWS service information and exam updates from reliable 
sources.

Here's how we can implement this feature:
# AWS Hangman with Automatic Updates

I've enhanced the AWS Hangman game with an automatic update feature that fetches the latest AWS service information and certification exam updates from reliable sources. This ensures your study material is 
always current and relevant.

## New Automatic Update Feature

The game now includes a dedicated AWS service updater that can fetch information from three key sources:

1. AWS Documentation - Gets the latest service names, categories, and descriptions directly from the official AWS documentation.

2. AWS Certification Exam Guides - Extracts certification-relevant information from exam guides, including domain knowledge and key topics.

3. AWS Blogs and What's New - Monitors recent AWS announcements to keep you informed about service updates that might appear on exams.

## How the Update System Works

The update system uses web scraping to gather information from official AWS sources:

• It normalizes service names to match the game's format
• Updates existing services with new information
• Adds new services as they're released by AWS
• Enhances certification notes with exam domain information
• Tracks recent service updates that might be relevant for exams
• Creates backups of your service database before making changes

## Using the Update Feature

From the main menu, select option 7: "Update AWS Services Database"

You'll see these update options:
1. AWS Documentation
2. AWS Certification Exam Guides
3. AWS Blogs and What's New
4. All of the above
5. Back to Main Menu

The update process may take a few minutes as it carefully fetches information from multiple sources.

## Files I've Created/Modified

1. aws_hangman.py - Added the update feature to the main menu
2. aws_service_updater.py - Created a dedicated updater script
3. aws_services.json - Enhanced with more services and certification notes
4. requirements.txt - Added dependencies for the updater (requests, BeautifulSoup)
5. README.md - Updated documentation

## Getting Started

1. Install the required dependencies:

   pip install -r requirements.txt


2. Run the game:

   python aws_hangman.py


3. Use the update feature periodically to keep your AWS service information current.

This enhancement makes the AWS Hangman game an even more valuable tool for certification preparation, as it ensures you're always studying with the most up-to-date information about AWS services and 
certification requirements.

Would you like me to explain any specific part of the implementation in more detail?

And that is it, the bug fix I added to the source code is just the type check of input (isalpha() to isalnum()) since some services include number as their names (e.g. Route 53, S3, EC2, etc.)

Hope you have a fun time as much as I had here.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert