Coding planet name generator, it's Scratch pseudocode
- User
Coding planet name generator, it's Scratch pseudocode
- Assistant
Designing a planet name generator in Scratch involves a combination of list operations and random selection. The following pseudocode outlines how you could create such a generator, keeping in mind the limitations and capabilities of Scratch.
Before starting, consider creating lists that contain syllables or parts of names that sound "planetary." You might have separate lists for beginnings, middles, and ends of names, or you could have one list with many options and combine selections randomly.
Initialization
-
Create three lists,
Beginnings,Middles, andEnds. Fill these lists with suitable syllables or word parts. For example:Beginningsmight include "Zar", "Mer", "Quar", "Terra", "Ven", "Luna".Middlesmight include "turn", "gorn", "phas", "clipt", "stron".Endsmight include "us", "ix", "on", "ar", "or".
-
Create a variable
PlanetNameto store the generated name.
User Action to Generate a Name
-
When the user triggers the generation (e.g., by clicking a button or a sprite):
-
Set
PlanetNameto an empty string to ensure it starts fresh. -
Randomly pick one part from each list (
Beginnings,Middles,Ends) and concatenate them. In Scratch, selecting a random item can be done using thepick random 1 to [length of list]block. Specifically:- Add a random item from
BeginningstoPlanetName. - Optionally, add a random item from
MiddlestoPlanetNameto make the names more complex. You might skip this step sometimes for variety, using a random decision (e.g.,if pick random 1 to 2 = 1 then). - Add a random item from
EndstoPlanetName.
- Add a random item from
-
-
Display
PlanetNameto the user. This could be done by setting the text of a label, changing a sprite's text bubble, or any other method of displaying text in Scratch.
Scratch Blocks (High-level conceptual representation)
- When [sprite/button] clicked:
- set
PlanetNameto"" - add (join (item (pick random 1 to (length of Beginnings)) of Beginnings) (item (pick random 1 to (length of Middles)) of Middles) (item (pick random 1 to (length of Ends)) of Ends)) to
PlanetName - say
PlanetNamefor 2 seconds
- set
Remember, this is a simplified and conceptual representation. Scratch uses blocks, and creating or modifying lists, picking random items, and concatenating strings (joining them) would all be done through dragging and connecting blocks in the Scratch interface.
This approach provides a flexible foundation. You can enrich the generator by adding more syllables, creating rules for how often middles are added, or even introducing additional criteria for name generation, like themes or unique characteristics (e.g., temperature, size, color) that influence the name parts chosen.
-