Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ad6b7ef

Browse files
style: format code with autopep8
Format code with autopep8 This commit fixes the style issues introduced in af73a2a according to the output from Autopep8. Details: None
1 parent 3fed88f commit ad6b7ef

File tree

1 file changed

+52
-24
lines changed

1 file changed

+52
-24
lines changed

‎AI Driven Storytelling Game/ai-storytelling-game.py

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import random
22

3+
34
class StoryNode:
45
def __init__(self, text, options=None, effects=None):
56
self.text = text
67
self.options = options or []
78
self.effects = effects or {}
89

10+
911
class Character:
1012
def __init__(self, name):
1113
self.name = name
1214
self.inventory = []
1315
self.traits = {}
1416

17+
1518
class StoryGame:
1619
def __init__(self):
1720
self.story_map = {}
@@ -45,6 +48,7 @@ def get_current_text(self):
4548
def is_game_over(self):
4649
return not self.current_node
4750

51+
4852
# Create the game
4953
game = StoryGame()
5054

@@ -54,31 +58,55 @@ def is_game_over(self):
5458
game.player = player
5559

5660
nodes_data = [
57-
("start", "You wake up in a mysterious land. Do you explore or rest?", ["explore", "rest"]),
58-
("explore", "You venture deep into the woods and find an old cabin. Do you enter or continue exploring?", ["enter_cabin", "continue_exploring"]),
59-
("rest", "You find a cozy spot and rest for a while. When you wake up, you see a map nearby. Will you follow the map or ignore it?", ["follow_map", "ignore_map"]),
60-
("enter_cabin", "Inside the cabin, you discover a hidden passage. Do you enter the passage or stay in the cabin?", ["enter_passage", "stay_in_cabin"]),
61-
("continue_exploring", "You stumble upon a magical waterfall. Do you drink from it or move on?", ["drink_water", "move_on"]),
62-
("follow_map", "Following the map, you find a hidden treasure. Do you take it or leave it?", ["take_treasure", "leave_treasure"]),
63-
("enter_passage", "The passage leads to an ancient temple. Do you explore further or leave?", ["explore_temple", "leave_temple"]),
64-
("stay_in_cabin", "You find a journal that reveals the history of the land. Do you keep reading or close the journal?", ["keep_reading", "close_journal"]),
65-
("drink_water", "Drinking from the waterfall grants you enhanced senses. Will you use them to uncover secrets or continue your journey?", ["uncover_secrets", "continue_journey"]),
66-
("move_on", "As you move on, you encounter a talking animal. Do you listen to its advice or ignore it?", ["listen_to_animal", "ignore_animal"]),
67-
("enter_passage", "The passage leads to an underground city. Do you explore the city or return to the surface?", ["explore_city", "return_to_surface"]),
68-
("uncover_secrets", "Using your enhanced senses, you find a hidden cave. Do you enter the cave or keep moving?", ["enter_cave", "keep_moving"]),
69-
("listen_to_animal", "The animal warns you of danger ahead. Do you heed its warning or take your chances?", ["heed_warning", "take_chances"]),
70-
("node88", "You come across a portal that leads to another realm. Do you step through or stay?", ["step_through", "stay"]),
71-
("explore_city", "You discover an ancient artifact that can grant a wish. What do you wish for?", ["wish_for_power", "wish_for_wisdom"]),
72-
("return_to_surface", "You emerge from the passage and find yourself in a bustling marketplace. Do you explore or leave?", ["explore_marketplace", "leave_marketplace"]),
73-
("enter_cave", "Inside the cave, you find a friendly spirit. Do you converse with it or leave?", ["converse_with_spirit", "leave_cave"]),
74-
("keep_moving", "You continue your journey and encounter a group of fellow travelers. Do you join them or go your own way?", ["join_travelers", "go_own_way"]),
75-
("heed_warning", "You avoid the danger and find a hidden treasure. What will you do with the treasure?", ["share_treasure", "keep_treasure"]),
76-
("take_chances", "Your gamble pays off, and you uncover a secret passage. Will you enter it or continue?", ["enter_secret_passage", "continue_journey"]),
77-
("step_through", "You step through the portal and find yourself in a futuristic city. How do you navigate this new world?", ["explore_futuristic_city", "find_a_way_back"]),
61+
("start", "You wake up in a mysterious land. Do you explore or rest?",
62+
["explore", "rest"]),
63+
("explore", "You venture deep into the woods and find an old cabin. Do you enter or continue exploring?", [
64+
"enter_cabin", "continue_exploring"]),
65+
("rest", "You find a cozy spot and rest for a while. When you wake up, you see a map nearby. Will you follow the map or ignore it?", [
66+
"follow_map", "ignore_map"]),
67+
("enter_cabin", "Inside the cabin, you discover a hidden passage. Do you enter the passage or stay in the cabin?", [
68+
"enter_passage", "stay_in_cabin"]),
69+
("continue_exploring", "You stumble upon a magical waterfall. Do you drink from it or move on?", [
70+
"drink_water", "move_on"]),
71+
("follow_map", "Following the map, you find a hidden treasure. Do you take it or leave it?", [
72+
"take_treasure", "leave_treasure"]),
73+
("enter_passage", "The passage leads to an ancient temple. Do you explore further or leave?", [
74+
"explore_temple", "leave_temple"]),
75+
("stay_in_cabin", "You find a journal that reveals the history of the land. Do you keep reading or close the journal?", [
76+
"keep_reading", "close_journal"]),
77+
("drink_water", "Drinking from the waterfall grants you enhanced senses. Will you use them to uncover secrets or continue your journey?", [
78+
"uncover_secrets", "continue_journey"]),
79+
("move_on", "As you move on, you encounter a talking animal. Do you listen to its advice or ignore it?", [
80+
"listen_to_animal", "ignore_animal"]),
81+
("enter_passage", "The passage leads to an underground city. Do you explore the city or return to the surface?", [
82+
"explore_city", "return_to_surface"]),
83+
("uncover_secrets", "Using your enhanced senses, you find a hidden cave. Do you enter the cave or keep moving?", [
84+
"enter_cave", "keep_moving"]),
85+
("listen_to_animal", "The animal warns you of danger ahead. Do you heed its warning or take your chances?", [
86+
"heed_warning", "take_chances"]),
87+
("node88", "You come across a portal that leads to another realm. Do you step through or stay?", [
88+
"step_through", "stay"]),
89+
("explore_city", "You discover an ancient artifact that can grant a wish. What do you wish for?", [
90+
"wish_for_power", "wish_for_wisdom"]),
91+
("return_to_surface", "You emerge from the passage and find yourself in a bustling marketplace. Do you explore or leave?", [
92+
"explore_marketplace", "leave_marketplace"]),
93+
("enter_cave", "Inside the cave, you find a friendly spirit. Do you converse with it or leave?", [
94+
"converse_with_spirit", "leave_cave"]),
95+
("keep_moving", "You continue your journey and encounter a group of fellow travelers. Do you join them or go your own way?", [
96+
"join_travelers", "go_own_way"]),
97+
("heed_warning", "You avoid the danger and find a hidden treasure. What will you do with the treasure?", [
98+
"share_treasure", "keep_treasure"]),
99+
("take_chances", "Your gamble pays off, and you uncover a secret passage. Will you enter it or continue?", [
100+
"enter_secret_passage", "continue_journey"]),
101+
("step_through", "You step through the portal and find yourself in a futuristic city. How do you navigate this new world?", [
102+
"explore_futuristic_city", "find_a_way_back"]),
78103
("stay", "You decide to stay in the current realm, building a new life for yourself.", []),
79-
("explore_marketplace", "In the marketplace, you meet a mysterious merchant. Will you buy a rare item or ignore the merchant?", ["buy_item", "ignore_merchant"]),
80-
("leave_marketplace", "You leave the marketplace and find yourself in a tranquil garden. Do you explore further or rest?", ["explore_garden", "rest_in_garden"]),
81-
("node89", "You face a final challenge. Do you confront it head-on or seek help?", ["confront", "seek_help"]),
104+
("explore_marketplace", "In the marketplace, you meet a mysterious merchant. Will you buy a rare item or ignore the merchant?", [
105+
"buy_item", "ignore_merchant"]),
106+
("leave_marketplace", "You leave the marketplace and find yourself in a tranquil garden. Do you explore further or rest?", [
107+
"explore_garden", "rest_in_garden"]),
108+
("node89", "You face a final challenge. Do you confront it head-on or seek help?",
109+
["confront", "seek_help"]),
82110
("confront", "With courage, you conquer the challenge and become a legend.", []),
83111
("seek_help", "You gather allies and together you overcome the final obstacle.", []),
84112
]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /