This content originally appeared on DEV Community and was authored by Manan patel
We all remember playing hand-cricket with friends — choosing numbers, hoping not to get out. I decided to bring that nostalgic game to life using Python and Amazon Q CLI.
Introduction
We all had that one go-to game during school breaks or boring classes — the legendary hand-cricket game. With nothing but fingers and imagination, it brought endless excitement, strategy, and friendly competition.
I was absolutely hooked on this game!
So, I decided to recreate that nostalgic cricket experience using Python — but here’s the twist: I used Amazon Q CLI to build the entire game in just 1 prompt.
Yes, you read that right. Just 1 prompt to bring my favourite childhood game to life!
Installation
To get started, you'll need to install Amazon Q CLI. Follow the official installation guide here to set it up on your system.
Prompt I used with Q CLI:
Generate a Python game using the pygame library that simulates a simple cricket batting innings against the computer.
Gameplay rules
---------------
1. The human plays as the batsman; the computer bowls by choosing a random number 1-6 each turn.
2. Display six clickable buttons (or on-screen rectangles) labeled 1-6 for the user’s shot.
3. When the user clicks a button:
a. Read that number as `user_shot`.
b. Computer randomly chooses `computer_ball = random.randint(1, 6)`.
c. If the two numbers are equal, display a big “OUT!” message, show the final score, and reveal a “Play Again” button.
d. If different, add `user_shot` to the running total and update the score display.
4. Show on screen each turn: current score, last shot, last ball, and turn count.
5. “Play Again” resets the state (score = 0, turn = 1, clear messages).
6. Close window cleanly on QUIT.
Implementation requirements
---------------------------
* Single file called `cricket_game.py`.
* Use `pygame.font` for text and `pygame.draw.rect` for buttons.
* Fixed window size (e.g., 800×600) with a simple background color.
* Organize code into functions/classes: e.g. `Button`, `GameState`, `main()`.
* Handle frame rate with `pygame.time.Clock()`.
* Put startup in `if __name__ == "__main__": main()`.
* Use only pygame and Python standard library (no extra dependencies).
* Comment the code generously and comply with PEP 8.
In return, Amazon Q CLI gave me:
Within moments, I had a fully functional cricket game with:
An interactive gameplay loop with ball-by-ball turns
Smart random logic for computer guesses
Clear tracking of runs and player outs
Seamless transition between user input and computer logic
Well-structured, clean, and easy-to-understand Python code
💡 Pro Tip: Amazon Q CLI isn’t just about generating code - it also acts as a coding partner, offering suggestions, logic explanations, and ways to make your code cleaner and more efficient.
Understanding the Logic with Q CLI
Amazon Q CLI didn’t just generate the code - it also explained each part, helping me understand the logic step by step. Below is a snapshot of that.
Documentation
Clear documentation is key to any project — it helps others (and your future self) understand the purpose and usage. So, I asked Amazon Q CLI to generate a README.md file for me, and it delivered a well-structured, ready-to-use document in seconds.
Amazon Q CLI’s Step-by-Step Explanation
A Quick Look at the Game in Action
Here’s a glimpse of the cricket game UI — simple, clean, and nostalgic. The interface shows your guess, the computer's random pick, and keeps track of your score until you're out. Just like the hand-cricket games we played growing up — now in digital form!
What I Took Away
Working on this project helped me understand:
Managing user interaction in a game loop
Integrating random logic for AI opponent moves
Leveraging Amazon Q CLI to speed up development
Writing modular, maintainable Python code
And most of all: bringing a beloved childhood game into the digital world.
Ready to Play?
Feel free to download the code, try it out, and customize it! Add new features, or multiplayer support - make this game truly yours.
GitHub Repository: Cricket Game
This content originally appeared on DEV Community and was authored by Manan patel

Manan patel | Sciencx (2025-05-22T16:14:30+00:00) 1 Prompt, 6 Runs: Rebuilding a Classic Cricket Game Using Amazon Q CLI. Retrieved from https://www.scien.cx/2025/05/22/1-prompt-6-runs-rebuilding-a-classic-cricket-game-using-amazon-q-cli/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.