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