settings
python
import random
adjectives = [“idyllic”, “secluded”, “bustling”, “ancient”, “futuristic”, “gritty”, “haunted”, “vibrant”, “oppressive”]
nouns = [“forest”, “city”, “desert”, “ocean”, “mountain”, “castle”, “ruins”, “space station”, “underwater city”]
adjective = random.choice(adjectives)
noun = random.choice(nouns)
print(f”The {adjective} {noun}”)
This code does the following:
- Imports the
randommodule: This module is used for generating random choices. - Defines lists of adjectives and nouns: These lists contain words that can be used to describe a setting.
- Selects random words from the lists: It uses
random.choice()to pick one adjective and one noun randomly. - Combines the words into a sentence: It uses an f-string to create a sentence like “The idyllic forest” or “The bustling city”.
- Prints the generated setting: The final sentence is printed to the console.
Let me know if you’d like to explore more complex setting generation or have any other creative coding ideas!
