Spaces:
Runtime error
Runtime error
import streamlit as st | |
import random | |
# Define the player cards | |
player_cards = { | |
"Player 1": { | |
"name": "Player 1", | |
"sketch": "π©", | |
"score": 0, | |
"mime": "" | |
}, | |
"Player 2": { | |
"name": "Player 2", | |
"sketch": "π¨", | |
"score": 0, | |
"mime": "" | |
} | |
} | |
# Define the game settings | |
num_rounds = 5 | |
# Define the possible actions | |
actions = ["jump", "dance", "sing", "sleep", "laugh", "cry", "eat", "drink", "run", "swim"] | |
# Define the Streamlit app | |
def app(): | |
st.set_page_config(page_title="Mime Game", page_icon="π", layout="wide") | |
st.title("Mime Game") | |
st.sidebar.write("# Player Cards") | |
for player, attributes in player_cards.items(): | |
st.sidebar.write(f"## {player}") | |
st.sidebar.write(f"Name: {attributes['name']}") | |
st.sidebar.write(f"Sketch: {attributes['sketch']}") | |
st.sidebar.write(f"Score: {attributes['score']}") | |
st.sidebar.write("# Game Settings") | |
num_rounds = st.sidebar.slider("Number of rounds to play", 1, 10, 5) | |
# Start the game when the user clicks the "Play Game" button | |
if st.button("Play Game"): | |
# Play the game for the specified number of rounds | |
for i in range(num_rounds): | |
st.write(f"Round {i+1}") | |
for player, attributes in player_cards.items(): | |
# Ask the player to perform an action using mime or mimicry | |
st.write(f"{attributes['sketch']} {attributes['name']}, it's your turn to perform an action using mime or mimicry.") | |
mime = st.text_input("Enter your mime/mimicry") | |
attributes["mime"] = mime | |
# Randomly select an action and ask the other player to guess it | |
action = random.choice(actions) | |
st.write(f"The action is: {action}") | |
for player, attributes in player_cards.items(): | |
if attributes["mime"] == action: | |
attributes["score"] += 1 | |
st.write(f"{attributes['sketch']} {attributes['name']} guessed the action correctly! π") | |
else: | |
st.write(f"{attributes['sketch']} {attributes['name']} failed to guess the action.") | |
# Display the final scores | |
st.write("# Final Scores") | |
for player, attributes in player_cards.items(): | |
st.write(f"{attributes['sketch']} {attributes['name']}: {attributes['score']} points") | |
if __name__ == "__main__": | |
app() |