Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,3 @@
|
|
1 |
-
# Team.Click.Battle.Multiplayer
|
2 |
-
|
3 |
import streamlit as st
|
4 |
import random
|
5 |
import time
|
@@ -19,6 +17,13 @@ def run_scenario(duration=100, click_card_limit=None):
|
|
19 |
click_cards = 0
|
20 |
chat = []
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
while time.time() - start_time < duration:
|
23 |
if click_card_limit is None or click_cards < click_card_limit:
|
24 |
click_cards += 1
|
@@ -33,36 +38,25 @@ def run_scenario(duration=100, click_card_limit=None):
|
|
33 |
else:
|
34 |
votes[team[0]][1] += clicks
|
35 |
chat.append((team, vote_type, clicks))
|
36 |
-
time.sleep(random.uniform(0, 1)) # Random sleep between 0 and 1 seconds
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
f.write(f"{team}: {vote_counts[0]} upvotes, {vote_counts[1]} downvotes\n")
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
value = []
|
50 |
|
51 |
-
|
52 |
-
labels.append(f"{team[1]} {team[2]}")
|
53 |
-
source += [i, i]
|
54 |
-
target += [len(teams), len(teams) + 1]
|
55 |
-
value += [votes[team[0]][0], votes[team[0]][1]]
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
fig = go.Figure(data=[go.Sankey(
|
60 |
-
node=dict(pad=15, thickness=20, line=dict(color='black', width=0.5), label=labels),
|
61 |
-
link=dict(source=source, target=target, value=value))])
|
62 |
|
63 |
-
|
64 |
|
65 |
-
return
|
66 |
|
67 |
st.title("Team Upvotes and Downvotes Emoji Game")
|
68 |
|
@@ -72,20 +66,19 @@ click_card_limit = st.slider("Click Card Limit", min_value=0, max_value=100, val
|
|
72 |
st.write(f"Running scenario for {duration} seconds with {click_card_limit} click cards...")
|
73 |
votes, chat = run_scenario(duration, click_card_limit)
|
74 |
|
75 |
-
save_votes_to_file(votes)
|
76 |
-
|
77 |
st.header("Results")
|
78 |
for team, vote_counts in votes.items():
|
79 |
st.write(f"{team}: {vote_counts[0]} upvotes, {vote_counts[1]} downvotes")
|
80 |
|
81 |
st.header("Chat")
|
82 |
for message in chat:
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
85 |
|
86 |
st.header("Sankey Graph")
|
87 |
fig = create_sankey(votes)
|
88 |
-
st.plotly_chart(fig)
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import random
|
3 |
import time
|
|
|
17 |
click_cards = 0
|
18 |
chat = []
|
19 |
|
20 |
+
fig = go.Figure(data=[go.Sankey(
|
21 |
+
node=dict(pad=15, thickness=20, line=dict(color='black', width=0.5),
|
22 |
+
label=[f"{team[1]} {team[2]}" for team in teams] + ['Upvotes', 'Downvotes']),
|
23 |
+
link=dict(source=[], target=[], value=[]))])
|
24 |
+
|
25 |
+
st.plotly_chart(fig, use_container_width=True)
|
26 |
+
|
27 |
while time.time() - start_time < duration:
|
28 |
if click_card_limit is None or click_cards < click_card_limit:
|
29 |
click_cards += 1
|
|
|
38 |
else:
|
39 |
votes[team[0]][1] += clicks
|
40 |
chat.append((team, vote_type, clicks))
|
|
|
41 |
|
42 |
+
source, target, value = [], [], []
|
43 |
+
for i, team in enumerate(teams):
|
44 |
+
source += [i, i]
|
45 |
+
target += [len(teams), len(teams) + 1]
|
46 |
+
value += [votes[team[0]][0], votes[team[0]][1]]
|
|
|
47 |
|
48 |
+
fig = go.Figure(data=[go.Sankey(
|
49 |
+
node=dict(pad=15, thickness=20, line=dict(color='black', width=0.5),
|
50 |
+
label=[f"{team[1]} {team[2]}" for team in teams] + ['Upvotes', 'Downvotes']),
|
51 |
+
link=dict(source=source, target=target, value=value))])
|
|
|
52 |
|
53 |
+
fig.update_layout(title_text='Location Simulator by Nickname', title_font=dict(size=24, color='blue'))
|
|
|
|
|
|
|
|
|
54 |
|
55 |
+
st.plotly_chart(fig, use_container_width=True)
|
|
|
|
|
|
|
|
|
56 |
|
57 |
+
time.sleep(random.uniform(0, 1)) # Random sleep between 0 and 1 seconds
|
58 |
|
59 |
+
return votes, chat
|
60 |
|
61 |
st.title("Team Upvotes and Downvotes Emoji Game")
|
62 |
|
|
|
66 |
st.write(f"Running scenario for {duration} seconds with {click_card_limit} click cards...")
|
67 |
votes, chat = run_scenario(duration, click_card_limit)
|
68 |
|
|
|
|
|
69 |
st.header("Results")
|
70 |
for team, vote_counts in votes.items():
|
71 |
st.write(f"{team}: {vote_counts[0]} upvotes, {vote_counts[1]} downvotes")
|
72 |
|
73 |
st.header("Chat")
|
74 |
for message in chat:
|
75 |
+
team, vote_type, clicks = message
|
76 |
+
st.write(f"{team[1]} {team[2]}: {clicks} {vote_type}s")
|
77 |
+
|
78 |
+
st.header("Final Results")
|
79 |
+
for team, vote_counts in votes.items():
|
80 |
+
st.write(f"{team}: {vote_counts[0]} upvotes, {vote_counts[1]} downvotes")
|
81 |
|
82 |
st.header("Sankey Graph")
|
83 |
fig = create_sankey(votes)
|
84 |
+
st.plotly_chart(fig, use_container_width=True)
|
|
|
|
|
|