Skip to content
MIYA·AI·LAB / generative-AI test logs LLM · Claude Code · MLX · Ollama
AI MiyaAILab_
  • // Lab
  • // all logs
JA / EN
← Miya-Gadget
Generative AI PC

Your First Program with Claude Code! Building a Game Through Conversation

November 16, 2025 · Shichinomiya
Your First Program with Claude Code! Building a Game Through Conversation

In the previous article, we got Claude Code installed and ran a simple program. This time, let’s take it a step further and try “building a game through conversation.”

One of the first hurdles programming beginners face is the “I don’t know what to build” wall. But with Claude Code, that’s not a problem — you can build something together through conversation!

What we’re building today is a “number guessing game.” It’s a simple game where you try to guess a number the computer has picked, but it’s packed with programming fundamentals.

 

Table of Contents

Toggle
  • Recap of the Previous Article
  • Game Specifications
      • Game Flow
  • Consulting Claude Code
      • Creating a Project Folder
      • Giving Instructions to Claude Code
  • Examining the Generated Program
      • number_guess.py
  • Playing the Game
  • Improving the Game
      • Adding a Difficulty Selection Feature
      • The Updated Program
  • Handling Errors
      • Common Errors
      • When You Hit an Error
  • Tips for Effective Conversations with Claude Code
      • Be Specific
      • Don’t Hesitate to Ask Questions
      • Improve Incrementally
  • What We Learned
  • Next Time
  • Summary
  • You might also like

Recap of the Previous Article

Let’s quickly review what we covered last time.

  • Installing Claude Code: We installed it easily using PowerShell
  • First program: We displayed Hello World
  • Simple calculator: We built an addition program

If you haven’t read the previous article yet, I recommend checking out the Complete Guide to Using Claude Code first.

 

Game Specifications

First, let’s decide what kind of game we’re building. Here are the specifications:

Game Flow

  1. The computer picks a random number between 1 and 100
  2. The player guesses the number
  3. Hints like “higher” or “lower” are given
  4. The game ends when you guess correctly
  5. The number of attempts is displayed

It’s simple, but it covers all the basics: random number generation, input handling, conditional branching, and loops.

 

Consulting Claude Code

Let’s fire up Claude Code and describe the game we want to build.

Open PowerShell and navigate to your project folder.

Creating a Project Folder

You can use the test_project folder from last time, or create a new one. This time, let’s create a new game_project folder.


Creating the project folder

Once the folder is created, navigate into it and launch Claude Code.

Giving Instructions to Claude Code

Once Claude Code is running, try giving it a prompt like this:

My prompt:
“I want to make a number guessing game. The computer picks a number between 1 and 100, and the player tries to guess it. Please add a hint feature too.”


Requesting Claude Code to create a number guessing game

Claude Code responds with something like “Got it!” and starts building the program.

When I tried it, the program was done in about 10 seconds. Impressive!

 

Examining the Generated Program

Here’s the program Claude Code created:

number_guess.py

import random

def number_guessing_game():
    # Generate a random number between 1 and 100
    target_number = random.randint(1, 100)
    attempts = 0

    print("Welcome to the Number Guessing Game!")
    print("Guess a number between 1 and 100.")
    print()

    while True:
        try:
            # Get the player's input
            guess = int(input("Enter your guess: "))
            attempts += 1

            # Check input range
            if guess < 1 or guess > 100:
                print("Please enter a number between 1 and 100!")
                continue

            # Check the guess
            if guess == target_number:
                print(f"Correct! You got it in {attempts} attempts!")
                break
            elif guess < target_number:
                print("Higher!")
            else:
                print("Lower!")

        except ValueError:
            print("Please enter a valid number!")

if __name__ == "__main__":
    number_guessing_game()

Looking at the code, it follows the specifications perfectly:

  • Random number generation: random.randint(1, 100) picks a number between 1 and 100
  • Loop: while True keeps going until the correct answer
  • Conditional branching: if/elif/else provides hints
  • Error handling: Handles non-numeric input

Writing this from scratch as a beginner would be quite challenging, but Claude Code does it in seconds!

 

Playing the Game

Let’s run it right away.

Enter the following command in PowerShell:

python number_guess.py


Number guessing game in action

It works!

I got it on my 6th try. Harder than I expected!

 

Improving the Game

Here’s where it gets fun. After playing the game, if you think “I’d like to change this,” just ask Claude Code.

Adding a Difficulty Selection Feature

For example, I wanted to add difficulty levels.

My prompt:
“Please add a difficulty selection at the start of the game: Easy (1-50), Normal (1-100), Hard (1-500).”


Requesting difficulty selection feature

Claude Code then modifies the program accordingly.

The Updated Program

Here’s the difficulty selection code that was added:

def select_difficulty():
    print("Select difficulty:")
    print("1. Easy (1-50)")
    print("2. Normal (1-100)")
    print("3. Hard (1-500)")

    while True:
        choice = input("Choose (1-3): ")
        if choice == "1":
            return 50
        elif choice == "2":
            return 100
        elif choice == "3":
            return 500
        else:
            print("Please enter 1, 2, or 3")

Just like that, you can keep adding features incrementally.

 

Handling Errors

You’ll occasionally run into errors while building programs. But don’t worry — Claude Code can help you fix them.

Common Errors

Error 1: ModuleNotFoundError

If you get something like “random module not found,” Python may not be installed correctly.

Error 2: IndentationError

This is an indentation error. Python is strict about indentation, so be careful when copy-pasting code.

When You Hit an Error

Just paste the error message directly into Claude Code.

My prompt:
“I got this error: (paste the error message)”

Claude Code will explain the cause and fix it for you. This is genuinely useful!

 

Tips for Effective Conversations with Claude Code

After using Claude Code several times, here are some tips I’ve picked up for getting the best results.

Be Specific

  • Bad: “Make a game”
  • Good: “Make a number guessing game for 1-100 with a hint feature”

The more specific you are, the closer the result will be to what you want.

Don’t Hesitate to Ask Questions

If you don’t understand part of the code, just ask.

Example questions:
“What does random.randint do?”
“Can you explain how the while loop works?”

Claude Code will explain it clearly.

Improve Incrementally

Instead of trying to build everything at once, start with something that works and then add features.

  1. Build the basic game
  2. Play it
  3. Add what you want changed
  4. Play it again

This cycle is key.

 

What We Learned

In this article, we accomplished the following:

  • Interactive development: Building programs through conversation with Claude Code
  • Program improvement: Iteratively enhancing a working program
  • Error handling: Solving errors by consulting Claude Code
  • Fundamentals: Using random numbers, loops, and conditional branching in practice

Programming is really about building things step by step like this.

 

Next Time

In the next article (Level 3), we’ll build something more practical.

“Simplify Task Management with Claude Code! Building a Simple Todo List App”

Let’s build a tool you can actually use in daily life. A Todo list is something you’ll use every day.

Stay tuned!

 

Summary

In this article, we built a number guessing game with Claude Code.

Key takeaways:

  • Give Claude Code specific instructions
  • The trick is to improve incrementally
  • When errors occur, just share them with Claude Code
  • Don’t hesitate to ask about anything you don’t understand

Programming is surprisingly easy when you can build things through conversation like this!

Let’s keep learning and having fun together. See you next time!

You might also like

More generative-AI logs from the lab.

  • Tesla V100 32GB in 2026: Local LLM Benchmark with Qwen 3.6 — 98.8 tok/s on MoE 35B, 1.6x Faster Than M1 Max (Used, ≈$900)
  • Build a Budget Tracker App with Claude Code: Data Visualization Made Easy
  • Dual Tesla V100 SXM2 on a Single PCIe Slot: 64GB VRAM & 300 GB/s NVLink Tested — Is This $700 Setup Worth It?
  • Can GTX 1080 Ti Run Modern AI? Qwen 3.5 Local LLM Benchmark Results
Previous Article The Complete Guide to Claude Code: Get Started with AI Development on Windows in 5 Minutes
Next Article Simplify Task Management with Claude Code! Building a Simple Todo List App

Related Posts

Can you really cut your AI API bill? I deployed the context-compression tool “Headroom” and measured it

Can you really cut your AI API bill? I deployed the context-compression tool “Headroom” and measured it

Darkbloom Review: Can a Mac Really Earn Money Serving AI? (I Tested It for a Day)

Darkbloom Review: Can a Mac Really Earn Money Serving AI? (I Tested It for a Day)

Building a Weather Forecast App with Claude Code and API Integration

Building a Weather Forecast App with Claude Code and API Integration

Automate Email Sending with Claude Code: Fully Automating Routine Tasks

Automate Email Sending with Claude Code: Fully Automating Routine Tasks

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Shichinomiya

Shichinomiya

A blogger who loves PC and gadgets. Sharing daily discoveries.

@shichinomiya_s

Popular Posts

  • Does the trending Claude Code skill “ADHD” actually make the agent smarter? A measured duel vs single-shot
  • Modded RTX 4080 32GB Benchmarked: Qwen3.8-27B at 262K Context, 125B MoE, and MiniMax H3 Video — What 32GB Actually Delivers
  • Dual Tesla V100 SXM2 on a Single PCIe Slot: 64GB VRAM & 300 GB/s NVLink Tested — Is This $700 Setup Worth It?
  • Automate Email Sending with Claude Code: Fully Automating Routine Tasks
  • Auto-Generate PDF Reports with Claude Code: From Raw Data to Polished Documents

Categories

  • Announcements
  • Cars
  • Cycling
  • Gadgets
  • Generative AI
  • Home Appliances
  • Internet Service
  • Outings
  • Overseas Shopping
  • PC
  • Rental Servers & VPS
  • Travel

MiyaAILab

A hands-on lab for generative AI — new models, tools, and services tested for real, from benchmarks to everyday usefulness.

Lab

  • AI Lab Home
  • All Generative-AI Logs
  • ← Back to Miya-Gadget

Latest

  • Dual Tesla V100 SXM2 on a Single PCIe Slot: 64GB VRAM & 300 GB/s NVLink Tested — Is This $700 Setup Worth It?
  • Modded RTX 4080 32GB Benchmarked: Qwen3.8-27B at 262K Context, 125B MoE, and MiniMax H3 Video — What 32GB Actually Delivers
  • Tesla V100 32GB Runs Qwen3.8-27B: 131k Context on a Single Card — Measured Benchmark
  • Tesla V100 32GB in 2026: Local LLM Benchmark with Qwen 3.6 — 98.8 tok/s on MoE 35B, 1.6x Faster Than M1 Max (Used, ≈$900)
© 2026 Miya AI Lab — a section of Miya-Gadget. miyagadget.page