Spaces:
Runtime error
Runtime error
File size: 2,830 Bytes
707417d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
import streamlit as st
import random
import pandas as pd
# Define the game mechanics
def generate_scenario():
scenarios = ['You are a superhero saving the world from a meteorite',
'You are a pirate searching for treasure on a deserted island',
'You are a chef trying to win a cooking competition',
'You are a detective solving a murder case']
return random.choice(scenarios)
def calculate_score(slider_values):
bluffing_score = slider_values[0]
deduction_score = slider_values[1]
humor_score = slider_values[2]
memory_score = slider_values[3]
roleplay_score = slider_values[4]
total_score = bluffing_score + deduction_score + humor_score + memory_score + roleplay_score
return total_score
def play_game(slider_values):
scenario = generate_scenario()
st.write('Act out the following scenario: ' + scenario)
total_score = calculate_score(slider_values)
st.write('Your total score is: ' + str(total_score))
# Save game history to a dataframe
game_history_df = pd.DataFrame({'Scenario': [scenario],
'Bluffing': [slider_values[0]],
'Deduction': [slider_values[1]],
'Humor': [slider_values[2]],
'Memory': [slider_values[3]],
'Roleplay': [slider_values[4]],
'Total Score': [total_score]})
return game_history_df
def save_game_history(game_history_df):
game_history_df.to_csv('game_history.csv', index=False)
st.write('Game history saved!')
st.write(game_history_df)
def run_simulations():
simulations = 1000
total_scores = []
for i in range(simulations):
slider_values = [random.randint(1, 10) for i in range(5)]
total_score = calculate_score(slider_values)
total_scores.append(total_score)
st.write('Average score from ' + str(simulations) + ' simulations: ' + str(sum(total_scores)/len(total_scores)))
# Define the Streamlit app
st.title('Acting Game Mechanics')
st.write('Welcome to the Acting Game Mechanics! This game measures your ability to bluff, deduce, use humor, remember details, and role-play. Drag the sliders to the left or right to adjust each skill, and click "Play" to act out a scenario and receive a score.')
slider_values = [st.slider('Bluffing', 1, 10, 5),
st.slider('Deduction', 1, 10, 5),
st.slider('Humor', 1, 10, 5),
st.slider('Memory', 1, 10, 5),
st.slider('Roleplay', 1, 10, 5)]
if st.button('Play'):
game_history_df = play_game(slider_values)
save_game_history(game_history_df)
if st.button('Run simulations'):
run_simulations() |