awacke1 commited on
Commit
bef0dab
ยท
1 Parent(s): 4926a8f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -14
app.py CHANGED
@@ -10,15 +10,12 @@ EMOJI_LIST = {4: "๐ŸŽ‚", 6: "๐Ÿ€", 8: "๐Ÿ„", 10: "๐Ÿ", 12: "๐Ÿ‚", 20: "๐Ÿƒ
10
 
11
  # Define the dice types and default number of rolls
12
  DICE_TYPES = [4, 6, 8, 10, 12, 20, 50, 100]
13
- DEFAULT_ROLLS = 10
14
 
15
  # Define a function to roll dice
16
  def roll_dice(num_rolls, dice_type):
17
  rolls = np.random.randint(1, dice_type + 1, size=num_rolls)
18
- variables = np.random.randn(num_rolls)
19
- df = pd.DataFrame({"Roll": rolls, "Variable": variables})
20
- df.index.name = f"{dice_type}-sided dice"
21
- return df
22
 
23
  # Define a function to plot tokens
24
  def plot_tokens(health_tokens, coin_tokens):
@@ -38,21 +35,20 @@ num_rolls = st.slider("Choose the number of rolls:", 1, 1000000, DEFAULT_ROLLS)
38
  # Roll dice for each type and accumulate high rolls and tokens
39
  history = {"health_tokens": [0], "coin_tokens": [0]}
40
  for dice_type in DICE_TYPES:
41
- df = roll_dice(num_rolls, dice_type)
 
42
  st.write(f"Results for {dice_type}-sided dice:")
43
- for roll, var in zip(df["Roll"], df["Variable"]):
44
- st.write(f"{EMOJI_LIST[dice_type]} {roll} ({var:.2f})")
45
  if roll == dice_type:
46
  st.write("Congratulations! You rolled the highest value!")
47
  if dice_type == 100:
48
  st.write("Adding 10 coins for rolling over 90 on 100-sided dice.")
49
  history["coin_tokens"].append(history["coin_tokens"][-1] + 10)
50
- history[f"{dice_type}-sided dice high rolls"] = sum(df["Roll"] == dice_type)
51
- history["roll_history"] = {**history.get("roll_history", {}), f"{dice_type}-sided dice": df}
52
-
53
- # Update token accumulation
54
- history["health_tokens"].append(sum(df.loc[20, "Roll"] == 20))
55
- history["coin_tokens"].append(sum(df.loc[100, "Roll"] == 100) * 10)
56
 
57
  # Plot token accumulation
58
  st.write("Token Accumulation:")
@@ -66,3 +62,4 @@ df.to_csv(filename, index=False)
66
 
67
  # Show download link for CSV file
68
  st.markdown(f'<a href="data:file/csv;base64,{b64encode(open(filename, "rb").read()).decode()}" download="{filename}">Download CSV File</a>', unsafe_allow_html=True)
 
 
10
 
11
  # Define the dice types and default number of rolls
12
  DICE_TYPES = [4, 6, 8, 10, 12, 20, 50, 100]
13
+ DEFAULT_ROLLS = 3
14
 
15
  # Define a function to roll dice
16
  def roll_dice(num_rolls, dice_type):
17
  rolls = np.random.randint(1, dice_type + 1, size=num_rolls)
18
+ return rolls
 
 
 
19
 
20
  # Define a function to plot tokens
21
  def plot_tokens(health_tokens, coin_tokens):
 
35
  # Roll dice for each type and accumulate high rolls and tokens
36
  history = {"health_tokens": [0], "coin_tokens": [0]}
37
  for dice_type in DICE_TYPES:
38
+ rolls = roll_dice(num_rolls, dice_type)
39
+ highest_rolls = sum(roll == dice_type for roll in rolls)
40
  st.write(f"Results for {dice_type}-sided dice:")
41
+ for roll in rolls:
42
+ st.write(f"{EMOJI_LIST[dice_type]} {roll}")
43
  if roll == dice_type:
44
  st.write("Congratulations! You rolled the highest value!")
45
  if dice_type == 100:
46
  st.write("Adding 10 coins for rolling over 90 on 100-sided dice.")
47
  history["coin_tokens"].append(history["coin_tokens"][-1] + 10)
48
+ history[f"{dice_type}-sided dice high rolls"] = highest_rolls
49
+ history["roll_history"] = {**history.get("roll_history", {}), dice_type: rolls}
50
+ history["health_tokens"].append(history.get("20-sided dice high rolls", 0))
51
+ history["coin_tokens"].append(history.get("100-sided dice high rolls", 0))
 
 
52
 
53
  # Plot token accumulation
54
  st.write("Token Accumulation:")
 
62
 
63
  # Show download link for CSV file
64
  st.markdown(f'<a href="data:file/csv;base64,{b64encode(open(filename, "rb").read()).decode()}" download="{filename}">Download CSV File</a>', unsafe_allow_html=True)
65
+