def start_game():
print("Welcome to the 'Choose Your Own Adventure' game!")
print("You are in a dark forest. There are two paths in front of you.")
print("1. Take the left path.")
print("2. Take the right path.")
choice = input("Which path do you choose? (1 or 2): ")
if choice == "1":
left_path()
elif choice == "2":
right_path()
else:
print("Invalid choice. Please choose 1 or 2.")
start_game()
def left_path():
print("\nYou chose the left path. After walking for a while, you encounter a river.")
print("1. Try to swim across.")
print("2. Look for a bridge.")
choice = input("What do you do? (1 or 2): ")
if choice == "1":
swim_across()
elif choice == "2":
find_bridge()
else:
print("Invalid choice. Please choose 1 or 2.")
left_path()
def right_path():
print("\nYou chose the right path. You find a cave.")
print("1. Enter the cave.")
print("2. Walk past the cave.")
choice = input("What do you do? (1 or 2): ")
if choice == "1":
enter_cave()
elif choice == "2":
walk_past_cave()
else:
print("Invalid choice. Please choose 1 or 2.")
right_path()
def swim_across():
print("\nYou decided to swim across the river. The current is strong and you struggle.")
print("1. Keep swimming.")
print("2. Turn back.")
choice = input("What do you do? (1 or 2): ")
if choice == "1":
print("\nYou bravely keep swimming and reach the other side safely. You win!")
elif choice == "2":
print("\nYou turn back and find another way around. However, you are exhausted and
decide to rest. Game over.")
else:
print("Invalid choice. Please choose 1 or 2.")
swim_across()
def find_bridge():
print("\nYou decided to look for a bridge. After a long search, you find one and cross the river
safely.")
print("1. Continue walking.")
print("2. Rest for a while.")
choice = input("What do you do? (1 or 2): ")
if choice == "1":
print("\nYou continue walking and find a village. You win!")
elif choice == "2":
print("\nYou rest for a while and then continue your journey. Unfortunately, it gets dark and
you get lost. Game over.")
else:
print("Invalid choice. Please choose 1 or 2.")
find_bridge()
def enter_cave():
print("\nYou enter the cave and find it is inhabited by a friendly dragon.")
print("1. Talk to the dragon.")
print("2. Try to sneak past the dragon.")
choice = input("What do you do? (1 or 2): ")
if choice == "1":
print("\nThe dragon is friendly and offers you a ride to a faraway land. You win!")
elif choice == "2":
print("\nYou try to sneak past the dragon but it wakes up and, startled, breathes fire. Game
over.")
else:
print("Invalid choice. Please choose 1 or 2.")
enter_cave()
def walk_past_cave():
print("\nYou walk past the cave and continue your journey.")
print("1. Climb a tree to get a better view of your surroundings.")
print("2. Keep walking on the path.")
choice = input("What do you do? (1 or 2): ")
if choice == "1":
print("\nYou climb a tree and see a beautiful castle in the distance. You win!")
elif choice == "2":
print("\nYou keep walking and find yourself back where you started. Game over.")
else:
print("Invalid choice. Please choose 1 or 2.")
walk_past_cave()
# Start the game
start_game()