#Import the necessary libraries import streamlit as st import random #Set up the game st.title("Welcome to Zork!") st.write("You are in a dark, damp cave. You can see a faint light in the distance and hear a distant rumbling sound.") #Create a list of available moves moves = ["Go left", "Go right", "Go forward", "Go backward"] #Create a loop to allow the user to make moves while True: st.write("What do you want to do?") move = st.selectbox("Choose your move:", moves) if move == "Go left": st.write("You go left and find yourself in a small room. There is a lever in the corner.") lever = st.selectbox("Do you pull the lever?", ["Yes", "No"]) if lever == "Yes": st.write("You pull the lever and a door opens. You walk through the door and find yourself in a large chamber with a treasure chest!") break else: st.write("You decide not to pull the lever and continue exploring the cave.") elif move == "Go right": st.write("You go right and find yourself in a large room. There is a giant monster blocking your path!") monster = st.selectbox("Do you try to fight the monster?", ["Yes", "No"]) if monster == "Yes": monster_hp = random.randint(1,10) player_hp = random.randint(1,10) st.write("You attack the monster with all your might! You hit it for {} damage, but it hits you back for {} damage!".format(player_hp, monster_hp)) if player_hp > monster_hp: st.write("You defeated the monster! You continue exploring the cave and eventually find your way out.") break else: st.write("The monster was too strong! You are defeated.") break else: st.write("You decide not to fight the monster and continue exploring the cave.") elif move == "Go forward": st.write("You go forward and find yourself in a large chamber. There is a treasure chest in the center of the room!") treasure = st.selectbox("Do you open the treasure chest?", ["Yes", "No"]) if treasure == "Yes": st.write("You open the chest and find a mysterious artifact inside. You take the artifact and continue exploring the cave.") break else: st.write("You decide not to open the chest and continue exploring the cave.") elif move == "Go backward": st.write("You go backward and find yourself in a dead end. There is nothing else to do here.")