File size: 2,876 Bytes
7fe06e0
 
 
 
 
 
 
 
 
 
 
 
 
f055702
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7fe06e0
 
 
 
 
f055702
7fe06e0
f055702
 
68c52f8
 
7fe06e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f055702
 
68c52f8
7fe06e0
68c52f8
7fe06e0
68c52f8
7fe06e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8ff8a56
 
68c52f8
 
 
79470c6
7fe06e0
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import streamlit as st
import random
import time
import plotly.graph_objects as go

teams = [
    ('Team 1', '๐Ÿ˜Ž', 'Cool Squad', 'New York City'),
    ('Team 2', '๐Ÿš€', 'Rocketeers', 'Los Angeles'),
    ('Team 3', '๐Ÿค–', 'Robo Gang', 'San Francisco'),
    ('Team 4', '๐ŸŒŸ', 'Super Stars', 'Chicago'),
    ('Team 5', '๐Ÿ‰', 'Dragons', 'Houston')
]

def create_sankey(votes, turn):
    labels = [f"{team[1]} {team[2]}" for team in teams] + ['Upvotes', 'Downvotes']
    source = []
    target = []
    value = []

    for i, team in enumerate(teams):
        source += [i, i]
        target += [len(teams), len(teams) + 1]
        value += [votes[team[0]][0], votes[team[0]][1]]

    fig = go.Figure(data=[go.Sankey(
        node=dict(pad=15, thickness=20, line=dict(color='black', width=0.5), label=labels),
        link=dict(source=source, target=target, value=value))])

    fig.update_layout(title_text=f'Location Simulator by Nickname (Turn {turn})', title_font=dict(size=24, color='blue'))

    return fig

def run_scenario(duration=100, click_card_limit=None):
    start_time = time.time()
    votes = {team[0]: [0, 0] for team in teams}  # Initialize upvotes and downvotes
    click_cards = 0
    chat = []
    turn = 0

    st.header("Sankey Graph")
    fig = create_sankey(votes, turn)
    st.plotly_chart(fig, use_container_width=True)

    while time.time() - start_time < duration:
        if click_card_limit is None or click_cards < click_card_limit:
            click_cards += 1

        team = random.choice(teams)
        vote_type = random.choice(['upvote', 'downvote'])
        clicks = 1 + 3 * (click_cards > 0)
        click_cards -= clicks > 1

        if vote_type == 'upvote':
            votes[team[0]][0] += clicks
        else:
            votes[team[0]][1] += clicks
        chat.append((team, vote_type, clicks))

        turn += 1
        fig = create_sankey(votes, turn)
        st.plotly_chart(fig, use_container_width=True)

        time.sleep(random.uniform(0, 1))  # Random sleep between 0 and 1 seconds

    return votes, chat

st.title("Team Upvotes and Downvotes Emoji Game")

duration = st.slider("Duration (seconds)", min_value=0, max_value=100, value=10, step=1)
click_card_limit = st.slider("Click Card Limit", min_value=0, max_value=100, value=10, step=1)

st.write(f"Running scenario for {duration} seconds with {click_card_limit} click cards...")
votes, chat = run_scenario(duration, click_card_limit)

st.header("Results")
for team, vote_counts in votes.items():
    st.write(f"{team}: {vote_counts[0]} upvotes, {vote_counts[1]} downvotes")

st.header("Chat")
for message in chat:
    team, vote_type, clicks = message
    st.write(f"{team[1]} {team[2]}: {clicks} {vote_type}s")

st.header("Final Results")
for team, vote_counts in votes.items():
    st.write(f"{team}: {vote_counts[0]} upvotes, {vote_counts[1]} downvotes")