<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Manan patel</title>
    <description>The latest articles on DEV Community by Manan patel (@manan_patel_9132df5914bcf).</description>
    <link>https://dev.to/manan_patel_9132df5914bcf</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3195371%2Fef3f8706-20af-45c9-8f78-1ddbb1230e0c.png</url>
      <title>DEV Community: Manan patel</title>
      <link>https://dev.to/manan_patel_9132df5914bcf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/manan_patel_9132df5914bcf"/>
    <language>en</language>
    <item>
      <title>1 Prompt, 6 Runs: Rebuilding a Classic Cricket Game Using Amazon Q CLI</title>
      <dc:creator>Manan patel</dc:creator>
      <pubDate>Thu, 22 May 2025 16:14:30 +0000</pubDate>
      <link>https://dev.to/manan_patel_9132df5914bcf/1-prompt-6-runs-rebuilding-a-classic-cricket-game-using-amazon-q-cli-4edd</link>
      <guid>https://dev.to/manan_patel_9132df5914bcf/1-prompt-6-runs-rebuilding-a-classic-cricket-game-using-amazon-q-cli-4edd</guid>
      <description>&lt;p&gt;&lt;strong&gt;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.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;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.&lt;br&gt;
I was absolutely hooked on this game!&lt;br&gt;
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.&lt;br&gt;
Yes, you read that right. Just 1 prompt to bring my favourite childhood game to life!&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;To get started, you'll need to install Amazon Q CLI. Follow the official installation guide &lt;a href="https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-installing.html" rel="noopener noreferrer"&gt;here&lt;/a&gt; to set it up on your system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prompt I used with Q CLI:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;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.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  In return, Amazon Q CLI gave me:
&lt;/h2&gt;

&lt;p&gt;Within moments, I had a fully functional cricket game with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;An interactive gameplay loop with ball-by-ball turns&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Smart random logic for computer guesses&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Clear tracking of runs and player outs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Seamless transition between user input and computer logic&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Well-structured, clean, and easy-to-understand Python code&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💡 &lt;strong&gt;Pro Tip:&lt;/strong&gt; 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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the Logic with Q CLI
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F01ii76jcf928inohtbkk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F01ii76jcf928inohtbkk.png" alt="Image description" width="800" height="528"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Documentation
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Amazon Q CLI’s Step-by-Step Explanation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F15skznpla801bi7ysdet.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F15skznpla801bi7ysdet.png" alt="Image description" width="800" height="333"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A Quick Look at the Game in Action
&lt;/h2&gt;

&lt;p&gt;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!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1v2ys9s2kl7r7lsve0ne.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1v2ys9s2kl7r7lsve0ne.png" alt="Image description" width="800" height="630"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Took Away
&lt;/h2&gt;

&lt;p&gt;Working on this project helped me understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Managing user interaction in a game loop&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Integrating random logic for AI opponent moves&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Leveraging Amazon Q CLI to speed up development&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Writing modular, maintainable Python code&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;And most of all:&lt;/strong&gt; bringing a beloved childhood game into the digital world.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ready to Play?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Feel free to download the code, try it out, and customize it! Add new features, or multiplayer support - make this game truly yours.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;a href="https://github.com/MananPatel13/cricket_game" rel="noopener noreferrer"&gt;Cricket Game&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>amazonqcli</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
