Past Lesson Note

This note is from 1 month ago. You're viewing content from a previous lesson.

Daily Note for September 17, 2026 Past Lesson

Today we will learn about procedural generation. You will look at one file. Then you will  edit the file to make it unique to your interests:

https://github.com/bmackenty/studentPythonStuff/blob/master/proc_gen_weapon_names.py

Today you will modify a Python program that generates fictional weapons and their stories. You can theme your version around space, animals, mythology, a game, a book, or another interest.

Procedural generation means creating content by following programmed rules. This program randomly selects words and phrases, then combines them into a description.

You do not need to understand every line today. Concentrate on the sections named in each task.

1. Open and run the original program — 10 minutes

  1. Open the file your teacher provides.
  2. Save your own copy as my_generator.py.
  3. Run the program.
  4. Read the description it produces.
  5. Run it two more times.

Answer these questions:

  • Identify two things that changed.
  • Identify one part of the sentence structure that stayed the same.

Checkpoint: Show your teacher or partner a generated description before you start editing.

2. Read two lines and make your first change — 10 minutes

Find these lines near the top:

 
weapon_age = ["Peace", "War", "Tranquility", "Sundering", "Rage", "Destruction", "Terror", "Doom", "Despair", "Glory", "Victory", "Darkeness", "Light", "Discovery"]
selected_weapon_age = random.choice(weapon_age)
 

The first line stores possible age names in a list.

The second line randomly chooses one item from that list and stores it in selected_weapon_age.

Complete this sentence:

random.choice(weapon_age) chooses ____________________.

Now:

  1. Find "Peace" in the list.
  2. Replace it with "Space Exploration".
  3. Keep the quotation marks.
  4. Save and run the program.

Your new phrase might not appear immediately because the program makes a random choice.

To test your change directly, temporarily replace the whole list line with:

 
weapon_age = ["Space Exploration"]
 

Run it again. With only one item available, the program must select that item.

Checkpoint: Find “the age of Space Exploration” in your output.

3. Choose a theme and change two lists — 15 minutes

Choose one theme. If you cannot decide, use space exploration.

Write:

My generator’s theme is ____________________.

First, edit weapon_age.

Replace its contents with at least four age names that fit your theme.

For example:

 
weapon_age = ["First Contact", "Lost Planets", "Robot Rebellion", "Star Travel"]
 

Save and run.

Next, find weapon_types_magic.

Replace its contents with at least three items that fit your theme:

 
weapon_types_magic = ["plasma wand", "gravity staff", "starlight sceptre"]
 

Save and run.

The program will only use this list in its description when it chooses the "magic" category. To check your new items, find the weapon_category list near the top and temporarily change it to:

 
weapon_category = ["magic"]
 

Run the program twice and check the item names.

You may keep this setting if you want your generator to produce only magic items.

Checkpoint: You have changed two lists, and the program still runs.

4. Share a result — 5 minutes

Show a partner one generated description.

Explain:

I changed __________. That affected __________ in the output.

5. Change the materials and history — 15 minutes

First, find weapon_material.

Replace the materials with at least five different materials that fit your theme.

For example:

 
weapon_material = ["moon rock", "titanium", "star crystal", "meteorite iron", "alien glass"]
 

Keep at least five materials because this program sometimes selects five at once.

Save and run.

Next, find weapon_past_event_1.

This section contains numbered historical events. Find the entry beginning with 2:.

Replace that entry with your own sentence. For example:

 
    2: "This weapon spent 100 years in an abandoned space station before a robot discovered it.",
 

Keep:

  • The number and colon: 2:
  • The quotation marks around the sentence.
  • The comma after the closing quotation mark.

Save and run.

Your event may not appear on every run because the program chooses randomly from several events.

Checkpoint: Your file contains personalized materials and one original historical event.

6. Test and improve your generator — 15 minutes

  1. Run your program three times.
  2. Read each description.
  3. Check that the program finishes without an error.
  4. Look for evidence of your changes.
  5. Improve one word or sentence that does not fit your theme.
  6. Save and run again.

Show your partner:

  • One list you changed.
  • The historical event you wrote.
  • One generated description.

Ask your partner:

Which part of my theme can you recognize in the output?

If your program stops working

Check the last line you edited:

Check Correct example
Text has quotation marks on both sides. "moon rock"
List items have commas between them. ["moon rock", "alien glass"]
The list has opening and closing square brackets. ["moon rock"]
The variable name has not changed. weapon_material = ...

If you are still stuck, undo your last edit and run the program again. Ask for help before making more changes.

7. Submit and reflect — 10 minutes

Submit:

  • Your saved my_generator.py file.
  • One generated description, copied as text or shown in a screenshot.
  • Your answers to these questions:
  1. Identify two lists you changed.
  2. Explain what random.choice() does.
  3. Describe how one of your edits affected the output.

Finished early?

Choose one:

  • Add two more items to a list you already edited.
  • Rewrite another historical event.
  • Find human_names and replace three names with fictional character names.
  • Explain why running the program twice might produce some of the same choices.