awacke1 commited on
Commit
7a29a2e
ยท
1 Parent(s): 291a98c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -159
app.py CHANGED
@@ -3,163 +3,6 @@
3
  #st.Markdown("TODO: A code density slider bar shows and adjusts the size of lines. ')
4
  #st.Markdown('Any ๐ŸŽฒDice๐ŸŽฒ way to compress the lines yet make it readable as optimal list of sets will do. Match language from good math books.')
5
 
6
- import os
7
- import streamlit as st
8
- import numpy as np
9
- import pandas as pd
10
- import plotly.express as px
11
- st.set_page_config(layout='wide')
12
- st.title('Any ๐ŸŽฒDice๐ŸŽฒ Way - STEM Math and Data Science Numerical Potluck')
13
- dice_types = [{'name': 'Six-sided Dice', 'sides': 6, 'emoji': '๐ŸŽฒ'},
14
- {'name': 'Twenty-sided Dice', 'sides': 20, 'emoji': '๐Ÿฟ'},
15
- {'name': 'Thirty-sided Dice', 'sides': 30, 'emoji': '๐Ÿฅ—'},
16
- {'name': 'One Hundred-sided Dice', 'sides': 100, 'emoji': '๐ŸŽ‚'}]
17
- if 'username' not in st.session_state:
18
- st.session_state.username = ''
19
- if 'dice_roll_history' not in st.session_state:
20
- st.session_state.dice_roll_history = pd.DataFrame()
21
- dice_type = st.selectbox('Choose a type of dice', dice_types, format_func=lambda d: f"{d['name']} {d['emoji']}")
22
- num_rolls = st.slider('How many times do you want to roll the dice?', 1, 1000000, 1000)
23
- rolls = np.random.randint(1, dice_type['sides'] + 1, num_rolls, dtype=np.uint64)
24
- roll_counts = pd.Series(rolls).value_counts().sort_index()
25
- fig = px.sunburst(names=[f'Roll {i}' for i in roll_counts.index],
26
- parents=['Dice Rolls'] * dice_type['sides'],
27
- values=roll_counts.values,
28
- color=[f'Roll {i}' for i in roll_counts.index],
29
- color_discrete_sequence=px.colors.qualitative.Dark24,
30
- maxdepth=2)
31
- fig.update_layout(title='Dice Roll Distribution', margin=dict(l=20, r=20, t=40, b=20), width=800, height=600)
32
- show_labels = st.checkbox('Show Labels', value=True)
33
- if not show_labels:
34
- fig.update_traces(textinfo='none')
35
- fig.show()
36
- bonus_match = False
37
- for dice in dice_types:
38
- if rolls[0] == dice['sides']:
39
- bonus_match = True
40
- bonus_dice_type = dice['name']
41
- bonus_dice_emoji = dice['emoji']
42
- break
43
- dice_roll_history = st.session_state.dice_roll_history
44
- new_roll_data = pd.DataFrame({'Roll': rolls,
45
- 'Count': np.ones(num_rolls, dtype=np.uint64),
46
- 'DiceNumberOfSides': [dice_type['sides']] * num_rolls,
47
- 'Username': [st.session_state.username] * num_rolls})
48
- if bonus_match:
49
- new_roll_data['BonusMatchToDiceName'] = [bonus_dice_type] * num_rolls
50
- new_roll_data['BonusMatchToDiceEmoji'] = [bonus_dice_emoji] * num_rolls
51
- dice_roll_history = dice_roll_history.append(new_roll_data, ignore_index=True)
52
- st.session_state.dice_roll_history = dice_roll_history
53
- include_name_column = st.checkbox('Include Username Column in Downloaded CSV', value=True)
54
- if st.button('Download Results'):
55
- filename = f'dice_roll_history_{st.session_state.username}{dice_type["emoji"]}.csv'
56
- if not include_name_column:
57
- dice_roll_history = dice_roll_history.drop(columns=['Username'])
58
- filename = f'dice_roll_history{dice_type["emoji"]}.csv'
59
- st.download_button(label='Download CSV', data=dice_roll_history.to_csv(index=False), file_name=filename, mime='text/csv')
60
- csv_files = [f for f in os.listdir('.') if os.path.isfile
61
- f.endswith('.csv') and 'dice_roll_history' in f]
62
- if csv_files:
63
- st.write('Downloaded files:')
64
- for csv_file in csv_files:
65
- st.markdown(f'[Download {csv_file}]({csv_file})')
66
- st.write('---')
67
- st.subheader('Settings')
68
- st.session_state.username = st.text_input('Username', st.session_state.username)
69
- st.write('---')
70
- st.subheader('Dice Roll History')
71
- st.write(dice_roll_history)
72
 
73
- st.write("""
74
- ๐Ÿž Bread
75
- ๐Ÿฅ Croissant
76
- ๐Ÿฅ– Baguette Bread
77
- ๐Ÿซ“ Flatbread
78
- ๐Ÿฅจ Pretzel
79
- ๐Ÿฅฏ Bagel
80
- ๐Ÿฅž Pancakes
81
- ๐Ÿง‡ Waffle
82
- ๐Ÿง€ Cheese Wedge
83
- ๐Ÿ– Meat on Bone
84
- ๐Ÿ— Poultry Leg
85
- ๐Ÿฅฉ Cut of Meat
86
- ๐Ÿฅ“ Bacon
87
- ๐Ÿ” Hamburger
88
- ๐ŸŸ French Fries
89
- ๐Ÿ• Pizza
90
- ๐ŸŒญ Hot Dog
91
- ๐Ÿฅช Sandwich
92
- ๐ŸŒฎ Taco
93
- ๐ŸŒฏ Burrito
94
- ๐Ÿซ” Tamale
95
- ๐Ÿฅ™ Stuffed Flatbread
96
- ๐Ÿง† Falafel
97
- ๐Ÿฅš Egg
98
- ๐Ÿณ Cooking
99
- ๐Ÿฅ˜ Shallow Pan of Food
100
- ๐Ÿฒ Pot of Food
101
- ๐Ÿซ• Fondue
102
- ๐Ÿฅฃ Bowl with Spoon
103
- ๐Ÿฅ— Green Salad
104
- ๐Ÿฟ Popcorn
105
- ๐Ÿงˆ Butter
106
- ๐Ÿง‚ Salt
107
- ๐Ÿฅซ Canned Food
108
- ๐Ÿฑ Bento Box
109
- ๐Ÿ˜ Rice Cracker
110
- ๐Ÿ™ Rice Ball
111
- ๐Ÿš Cooked Rice
112
- ๐Ÿ› Curry Rice
113
- ๐Ÿœ Steaming Bowl
114
- ๐Ÿ Spaghetti
115
- ๐Ÿ  Roasted Sweet Potato
116
- ๐Ÿข Oden
117
- ๐Ÿฃ Sushi
118
- ๐Ÿค Fried Shrimp
119
- ๐Ÿฅ Fish Cake with Swirl
120
- ๐Ÿฅฎ Moon Cake
121
- ๐Ÿก Dango
122
- ๐ŸฅŸ Dumpling
123
- ๐Ÿฅ  Fortune Cookie
124
- ๐Ÿฅก Takeout Box
125
- ๐Ÿฆช Oyster
126
- ๐Ÿฆ Soft Ice Cream
127
- ๐Ÿง Shaved Ice
128
- ๐Ÿจ Ice Cream
129
- ๐Ÿฉ Doughnut
130
- ๐Ÿช Cookie
131
- ๐ŸŽ‚ Birthday Cake
132
- ๐Ÿฐ Shortcake
133
- ๐Ÿง Cupcake
134
- ๐Ÿฅง Pie
135
- ๐Ÿซ Chocolate Bar
136
- ๐Ÿฌ Candy
137
- ๐Ÿญ Lollipop
138
- ๐Ÿฎ Custard
139
- ๐Ÿฏ Honey Pot
140
- ๐Ÿผ Baby Bottle
141
- ๐Ÿฅ› Glass of Milk
142
- โ˜• Hot Beverage
143
- ๐Ÿซ– Teapot
144
- ๐Ÿต Teacup Without Handle
145
- ๐Ÿถ Sake
146
- ๐Ÿพ Bottle with Popping Cork
147
- ๐Ÿท Wine Glass
148
- ๐Ÿธ Cocktail Glass
149
- ๐Ÿน Tropical Drink
150
- ๐Ÿบ Beer Mug
151
- ๐Ÿป Clinking Beer Mugs
152
- ๐Ÿฅ‚ Clinking Glasses
153
- ๐Ÿฅƒ Tumbler Glass
154
- ๐Ÿซ— Pouring Liquid
155
- ๐Ÿฅค Cup with Straw
156
- ๐Ÿง‹ Bubble Tea
157
- ๐Ÿงƒ Beverage Box
158
- ๐Ÿง‰ Mate
159
- ๐ŸงŠ Ice
160
- ๐Ÿฅข Chopsticks
161
- ๐Ÿฝ๏ธ Fork and Knife with Plate
162
- ๐Ÿด Fork and Knife
163
- ๐Ÿฅ„ Spoon
164
- ๐Ÿซ™ Jar
165
- """)
 
3
  #st.Markdown("TODO: A code density slider bar shows and adjusts the size of lines. ')
4
  #st.Markdown('Any ๐ŸŽฒDice๐ŸŽฒ way to compress the lines yet make it readable as optimal list of sets will do. Match language from good math books.')
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
+
8
+ st.write("๐Ÿž Bread, ๐Ÿฅ Croissant, ๐Ÿฅ– Baguette Bread, ๐Ÿซ“ Flatbread, ๐Ÿฅจ Pretzel, ๐Ÿฅฏ Bagel, ๐Ÿฅž Pancakes, ๐Ÿง‡ Waffle, ๐Ÿง€ Cheese Wedge, ๐Ÿ– Meat on Bone, ๐Ÿ— Poultry Leg, ๐Ÿฅฉ Cut of Meat, ๐Ÿฅ“ Bacon, ๐Ÿ” Hamburger, ๐ŸŸ French Fries, ๐Ÿ• Pizza, ๐ŸŒญ Hot Dog, ๐Ÿฅช Sandwich, ๐ŸŒฎ Taco, ๐ŸŒฏ Burrito, ๐Ÿซ” Tamale, ๐Ÿฅ™ Stuffed Flatbread, ๐Ÿง† Falafel, ๐Ÿฅš Egg, ๐Ÿณ Cooking, ๐Ÿฅ˜ Shallow Pan of Food, ๐Ÿฒ Pot of Food, ๐Ÿซ• Fondue, ๐Ÿฅฃ Bowl with Spoon, ๐Ÿฅ— Green Salad, ๐Ÿฟ Popcorn, ๐Ÿงˆ Butter, ๐Ÿง‚ Salt, ๐Ÿฅซ Canned Food, ๐Ÿฑ Bento Box, ๐Ÿ˜ Rice Cracker, ๐Ÿ™ Rice Ball, ๐Ÿš Cooked Rice, ๐Ÿ› Curry Rice, ๐Ÿœ Steaming Bowl, ๐Ÿ Spaghetti, ๐Ÿ  Roasted Sweet Potato, ๐Ÿข Oden, ๐Ÿฃ Sushi, ๐Ÿค Fried Shrimp, ๐Ÿฅ Fish Cake with Swirl, ๐Ÿฅฎ Moon Cake, ๐Ÿก Dango, ๐ŸฅŸ Dumpling, ๐Ÿฅ  Fortune Cookie, ๐Ÿฅก Takeout Box, ๐Ÿฆช Oyster, ๐Ÿฆ Soft Ice Cream, ๐Ÿง Shaved Ice, ๐Ÿจ Ice Cream, ๐Ÿฉ Doughnut, ๐Ÿช Cookie, ๐ŸŽ‚ Birthday Cake, ๐Ÿฐ Shortcake, ๐Ÿง Cupcake, ๐Ÿฅง Pie, ๐Ÿซ Chocolate Bar, ๐Ÿฌ Candy, ๐Ÿญ Lollipop, ๐Ÿฎ Custard, ๐Ÿฏ Honey Pot, ๐Ÿผ Baby Bottle, ๐Ÿฅ› Glass of Milk, โ˜• Hot Beverage, ๐Ÿซ– Teapot, ๐Ÿต Teacup Without Handle, ๐Ÿถ Sake, ๐Ÿพ Bottle with Popping Cork, ๐Ÿท Wine Glass, ๐Ÿธ Cocktail Glass, ๐Ÿน Tropical Drink, ๐Ÿบ Beer Mug, ๐Ÿป Clinking Beer Mugs, ๐Ÿฅ‚ Clinking Glasses, ๐Ÿฅƒ Tumbler Glass, ๐Ÿซ— Pouring Liquid, ๐Ÿฅค Cup with Straw, ๐Ÿง‹ Bubble Tea, ๐Ÿงƒ Beverage Box, ๐Ÿง‰ Mate, ๐ŸงŠ Ice, ๐Ÿฅข Chopsticks, ๐Ÿฝ๏ธ Fork and Knife with Plate, ๐Ÿด Fork and Knife, ๐Ÿฅ„ Spoon, ๐Ÿซ™ Jar")