Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
> Virat:
|
| 2 |
+
import random
|
| 3 |
+
|
| 4 |
+
def generate_story(character, setting, mood):
|
| 5 |
+
|
| 6 |
+
story_openings = [
|
| 7 |
+
f"{character} woke up one morning feeling incredibly {mood}.",
|
| 8 |
+
f"In the heart of {setting}, {character} began an unusual day.",
|
| 9 |
+
f"{character} always believed in dreams, but today felt different.",
|
| 10 |
+
]
|
| 11 |
+
|
| 12 |
+
conflicts = [
|
| 13 |
+
f"Suddenly, a strange sound echoed through the {setting}.",
|
| 14 |
+
f"Out of nowhere, a mysterious figure appeared before {character}.",
|
| 15 |
+
f"The wind whispered secrets that only {character} could hear.",
|
| 16 |
+
]
|
| 17 |
+
|
| 18 |
+
actions = [
|
| 19 |
+
f"With courage, {character} decided to follow the clues.",
|
| 20 |
+
f"{character} took a deep breath and walked towards the unknown.",
|
| 21 |
+
f"A spark of curiosity led {character} deeper into the {setting}.",
|
| 22 |
+
]
|
| 23 |
+
|
| 24 |
+
resolutions = [
|
| 25 |
+
f"And in the end, {character} discovered something magical.",
|
| 26 |
+
f"Surprisingly, the journey turned out to be the best adventure ever.",
|
| 27 |
+
f"{character} returned home with a heart full of stories and wisdom.",
|
| 28 |
+
]
|
| 29 |
+
|
| 30 |
+
# Pick random lines
|
| 31 |
+
story = [
|
| 32 |
+
random.choice(story_openings),
|
| 33 |
+
random.choice(conflicts),
|
| 34 |
+
random.choice(actions),
|
| 35 |
+
random.choice(resolutions)
|
| 36 |
+
]
|
| 37 |
+
|
| 38 |
+
return "\n".join(story)
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
# -----------------------------
|
| 42 |
+
# RUN THE STORY GENERATOR
|
| 43 |
+
# -----------------------------
|
| 44 |
+
character = input("Enter a character name: ")
|
| 45 |
+
setting = input("Enter a setting: ")
|
| 46 |
+
mood = input("Enter a mood (happy, mysterious, adventurous, etc.): ")
|
| 47 |
+
|
| 48 |
+
print("\n Your Story:\n")
|
| 49 |
+
print(generate_story(character, setting, mood))
|
| 50 |
+
|
| 51 |
+
> Virat:
|
| 52 |
+
import random
|
| 53 |
+
|
| 54 |
+
def generate_story(character, setting, mood):
|
| 55 |
+
|
| 56 |
+
story_openings = [
|
| 57 |
+
f"{character} woke up one morning feeling incredibly {mood}.",
|
| 58 |
+
f"In the heart of {setting}, {character} began an unusual day.",
|
| 59 |
+
f"{character} always believed in dreams, but today felt different.",
|
| 60 |
+
]
|
| 61 |
+
|
| 62 |
+
conflicts = [
|
| 63 |
+
f"Suddenly, a strange sound echoed through the {setting}.",
|
| 64 |
+
f"Out of nowhere, a mysterious figure appeared before {character}.",
|
| 65 |
+
f"The wind whispered secrets that only {character} could hear.",
|
| 66 |
+
]
|
| 67 |
+
|
| 68 |
+
actions = [
|
| 69 |
+
f"With courage, {character} decided to follow the clues.",
|
| 70 |
+
f"{character} took a deep breath and walked towards the unknown.",
|
| 71 |
+
f"A spark of curiosity led {character} deeper into the {setting}.",
|
| 72 |
+
]
|
| 73 |
+
|
| 74 |
+
resolutions = [
|
| 75 |
+
f"And in the end, {character} discovered something magical.",
|
| 76 |
+
f"Surprisingly, the journey turned out to be the best adventure ever.",
|
| 77 |
+
f"{character} returned home with a heart full of stories and wisdom.",
|
| 78 |
+
]
|
| 79 |
+
|
| 80 |
+
# Pick random lines
|
| 81 |
+
story = [
|
| 82 |
+
random.choice(story_openings),
|
| 83 |
+
random.choice(conflicts),
|
| 84 |
+
random.choice(actions),
|
| 85 |
+
random.choice(resolutions)
|
| 86 |
+
]
|
| 87 |
+
|
| 88 |
+
return "\n".join(story)
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
# -----------------------------
|
| 92 |
+
# RUN THE STORY GENERATOR
|
| 93 |
+
# -----------------------------
|
| 94 |
+
character = input("Enter a character name: ")
|
| 95 |
+
setting = input("Enter a setting: ")
|
| 96 |
+
mood = input("Enter a mood (happy, mysterious, adventurous, etc.): ")
|
| 97 |
+
|
| 98 |
+
print("\n Your Story:\n")
|
| 99 |
+
print(generate_story(character, setting, mood))
|