DEV Community

Cover image for Building the Name Match Memory Game: My Experience with Amazon Q CLI
Warda Liaqat
Warda Liaqat

Posted on

Building the Name Match Memory Game: My Experience with Amazon Q CLI

Introduction

Have you ever been at a networking event, recognized someone's face, but completely blanked on their name? It's happened to all of us! This common social challenge inspired me to build the Name Match Memory Game a simple but effective tool to help people practice connecting faces with names.

The idea was straightforward: create a game that shows users face images, presents multiple name options, and helps them practice making the right connections. What started as a simple command-line tool evolved into a full-fledged web application, all with the help of Amazon Q CLI.


Setting Up Amazon Q CLI

Getting started with Amazon Q CLI on my Windows machine using WSL (Windows Subsystem for Linux) took a bit of setup, but was worth the effort.

First, I needed to install the AWS CLI and configure it with my credentials:

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
aws configure
Enter fullscreen mode Exit fullscreen mode

Then I installed Amazon Q CLI:

curl -Lo "/tmp/q-cli.deb" "https://d3op2l77j7wnti.cloudfront.net/releases/amazon-q-cli/v0.1.0/amazon-q-cli_0.1.0_amd64.deb"
sudo dpkg -i /tmp/q-cli.deb
Enter fullscreen mode Exit fullscreen mode

I faced a couple of challenges during setup:

  • Getting the shell initialization right (needed to add Q CLI to my PATH)
  • Understanding the correct commands to start a chat session
  • Ensuring my AWS credentials were properly configured

After some troubleshooting, I was able to start Q CLI with a simple command:

q chat
Enter fullscreen mode Exit fullscreen mode

Using Q CLI to Build the Game

Once I had Q CLI running, the development process was surprisingly smooth. I started by describing my game idea:

Create a Python CLI game that helps users remember people's names and faces.

Q CLI immediately understood what I wanted and helped me design the core game logic. We started with a command-line version that:

  • Stored people's data in a JSON file
  • Displayed "faces" (as file paths in the CLI version)
  • Presented multiple-choice name options
  • Tracked correct/incorrect answers

Here's a snippet of the initial game logic Q CLI helped me create:

def play_game(self, num_rounds: int = 5) -> None:
    """Play the name matching game with multiple choice options."""
    if len(self.people_data) < 4:
        print("You need at least 4 people in the database to play the game.")
        return

    num_rounds = min(num_rounds, len(self.people_data))
    score = 0

    # Select people for this game session
    sorted_people = sorted(self.people_data, key=lambda x: x["times_shown"])
    game_people = sorted_people[:num_rounds]

    for round_num, person in enumerate(game_people, 1):
        # Generate options (3-4 name choices)
        options = [person["name"]]
        other_names = [p["name"] for p in self.people_data if p["name"] != person["name"]]
        options.extend(random.sample(other_names, min(3, len(other_names))))
        random.shuffle(options)

        # Display options and get answer
        # ...
Enter fullscreen mode Exit fullscreen mode

After testing the CLI version, I asked Q CLI to help me convert it to a web application using Flask. This was where Q CLI really shined—it generated the complete Flask application structure, HTML templates, and even CSS styling.


Game Features

The final web-based game includes several key features:

1. Interactive Start Page

Q CLI helped me create an engaging start page with:

  • A gradient background
  • Preview of random faces from the database
  • Clear game instructions
  • Animated "Start Playing" button

2. Game Mechanics

  • Random Face Selection: Each round shows a different face
  • Multiple Choice: 3-4 name options as radio buttons
  • Immediate Feedback: Users learn right away if they were correct
  • Score Tracking: Progress is shown throughout the 5-round game
  • Final Results: Accuracy and performance summary at the end

3. Data Management

The game uses two simple JSON files:

  • people_data.json: Stores person information with IDs and names
  • game_stats.json: Tracks game statistics across sessions
// Example people_data.json
[
  {
    "id": "alice",
    "name": "Alice Johnson"
  },
  {
    "id": "bob",
    "name": "Bob Smith"
  }
]
Enter fullscreen mode Exit fullscreen mode

4. Image Handling

Images are stored in the static/images/ directory and named according to person IDs (e.g., alice.jpg). The Flask application dynamically loads these images during gameplay.


Running the Game

Getting the game running required a few steps:

Prerequisites

  • Python 3.6+
  • Flask
  • Virtual environment

Setup Process

I created a virtual environment and installed Flask:

python3 -m venv venv
source venv/bin/activate
pip install flask
Enter fullscreen mode Exit fullscreen mode

This was another area where I faced challenges—initially getting a ModuleNotFoundError: No module named 'flask' error. Q CLI helped me troubleshoot this by explaining I needed to install Flask in my virtual environment.

Starting the Game

Once everything was set up, starting the game was simple:

python app.py
Enter fullscreen mode Exit fullscreen mode

Then I could access the game by opening a browser and navigating to:

http://127.0.0.1:5000/

Adding New People

To add new people to the game:

  1. Add their information to people_data.json with a unique ID
  2. Place their image in static/images/ with the filename matching their ID

My Learnings and Reflections

Working with Amazon Q CLI to build this game taught me several valuable lessons:

  1. AI-assisted coding is powerful: Q CLI helped me go from concept to working application much faster than I could have alone. It understood my requirements and generated well-structured code.
  2. Interactive problem-solving: When I hit roadblocks (like Flask installation issues), Q CLI provided clear, step-by-step solutions.
  3. Learning by doing: The conversational nature of Q CLI allowed me to learn Flask web development concepts as we built the application together.
  4. Iterative development: I could easily request changes or enhancements, like adding the start page, and Q CLI would help implement them.

What I enjoyed most was how Q CLI maintained context throughout our conversation. It remembered what we had built earlier and could refer back to previous code when making improvements.


What's Next?

This project is just the beginning! With the foundation in place, I'm planning several enhancements:

  1. User Authentication: Allow multiple users to track their individual progress
  2. Upload Interface: Web form to add new people and images directly
  3. Database Integration: Replace JSON files with a proper database
  4. Leaderboard: Compare performance with other users
  5. Difficulty Levels: Add timed challenges and harder modes
  6. Mobile Optimization: Make the game fully responsive for on-the-go practice

Conclusion

Building the Name Match Memory Game with Amazon Q CLI was both educational and enjoyable. The tool helped me transform a simple idea into a functional web application, even as someone relatively new to Flask development.

If you have a project idea but aren't sure how to implement it, I highly recommend giving Amazon Q CLI a try. The interactive, conversational approach to coding makes development more accessible and helps bridge knowledge gaps as you build.

Have you used Amazon Q CLI for any of your projects? I'd love to hear about your experiences in the comments!


Ready to improve your name-face memory?

Check out the GitHub repository to try the game yourself!

Top comments (0)