widichandra commited on
Commit
ef31da9
Β·
verified Β·
1 Parent(s): 935da45

Upload streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +10 -16
src/streamlit_app.py CHANGED
@@ -6,7 +6,7 @@ import hmac
6
  import hashlib
7
 
8
  st.set_page_config(page_title="Stake Dice Strategy Simulator", layout="wide")
9
- st.title("🎲 Stake Dice Strategy Simulator: ZachXBT vs ZachXBT+")
10
 
11
  # Sidebar settings
12
  st.sidebar.header("Simulation Settings")
@@ -23,11 +23,8 @@ st.sidebar.subheader("πŸ” Provably Fair Dice (Optional)")
23
  use_provably_fair = st.sidebar.checkbox("Use Provably Fair Dice", value=False)
24
  client_seed = st.sidebar.text_input("Client Seed", value="widichandra")
25
  server_seed = "serverseed123"
 
26
 
27
- # Fixed house edge
28
- house_edge = 1.0 # 1%
29
-
30
- # Dice roll function
31
  def roll_dice(nonce):
32
  if use_provably_fair:
33
  message = f"{client_seed}:{nonce}"
@@ -40,7 +37,6 @@ def roll_dice(nonce):
40
  roll = (random.random() * 10001) / 100
41
  return min(round(roll, 5), 100.00000)
42
 
43
- # Updated strategy with cap, drawdown stop, and reset on 2x
44
  def simulate_strategy(improved=False, run_id=1):
45
  balance = initial_balance
46
  bet = base_bet
@@ -55,9 +51,9 @@ def simulate_strategy(improved=False, run_id=1):
55
  profit = 0.0
56
  win_streak = 0
57
  over_under_mode = "Under"
58
- max_bet_cap = initial_balance * 0.1
59
  dd_stop_threshold = initial_balance * 0.5
60
- reset_threshold = initial_balance * 2.0
61
 
62
  for i in range(num_bets):
63
  if balance < bet:
@@ -89,11 +85,13 @@ def simulate_strategy(improved=False, run_id=1):
89
  win_count += 1
90
  win_streak += 1
91
  loss_count = 0
92
- bet = base_bet
93
 
94
  if improved:
95
- if profit > 0.05:
96
- bet = max(base_bet, bet * 0.5)
 
 
 
97
  if profit < -0.10:
98
  win_chance = 5.00
99
  else:
@@ -135,7 +133,7 @@ def simulate_strategy(improved=False, run_id=1):
135
  }
136
  return df, summary
137
 
138
- # Run simulations
139
  st.subheader("πŸ“Š Multi-Run Strategy Comparison")
140
  all_data = []
141
  all_summary = []
@@ -155,12 +153,8 @@ for run in range(1, num_runs + 1):
155
  summary_df = pd.DataFrame(all_summary)
156
  full_data_df = pd.concat(all_data, ignore_index=True)
157
 
158
- # Display results
159
  st.dataframe(summary_df)
160
-
161
- # Download CSV
162
  st.download_button("πŸ“₯ Download Full Simulation CSV", full_data_df.to_csv(index=False), file_name="dice_dual_simulation.csv")
163
 
164
- # Optional raw data
165
  with st.expander("πŸ” Show Detailed Simulation Logs"):
166
  st.dataframe(full_data_df)
 
6
  import hashlib
7
 
8
  st.set_page_config(page_title="Stake Dice Strategy Simulator", layout="wide")
9
+ st.title("🎲 Stake Dice Strategy Simulator: ZachXBT vs ZachXBT+ v2.2")
10
 
11
  # Sidebar settings
12
  st.sidebar.header("Simulation Settings")
 
23
  use_provably_fair = st.sidebar.checkbox("Use Provably Fair Dice", value=False)
24
  client_seed = st.sidebar.text_input("Client Seed", value="widichandra")
25
  server_seed = "serverseed123"
26
+ house_edge = 1.0
27
 
 
 
 
 
28
  def roll_dice(nonce):
29
  if use_provably_fair:
30
  message = f"{client_seed}:{nonce}"
 
37
  roll = (random.random() * 10001) / 100
38
  return min(round(roll, 5), 100.00000)
39
 
 
40
  def simulate_strategy(improved=False, run_id=1):
41
  balance = initial_balance
42
  bet = base_bet
 
51
  profit = 0.0
52
  win_streak = 0
53
  over_under_mode = "Under"
54
+ max_bet_cap = initial_balance * 0.2
55
  dd_stop_threshold = initial_balance * 0.5
56
+ reset_threshold = initial_balance * 3.0
57
 
58
  for i in range(num_bets):
59
  if balance < bet:
 
85
  win_count += 1
86
  win_streak += 1
87
  loss_count = 0
 
88
 
89
  if improved:
90
+ if win_streak % 3 == 0:
91
+ bet *= 1.2
92
+ else:
93
+ bet = base_bet
94
+
95
  if profit < -0.10:
96
  win_chance = 5.00
97
  else:
 
133
  }
134
  return df, summary
135
 
136
+ # Run both strategies per run
137
  st.subheader("πŸ“Š Multi-Run Strategy Comparison")
138
  all_data = []
139
  all_summary = []
 
153
  summary_df = pd.DataFrame(all_summary)
154
  full_data_df = pd.concat(all_data, ignore_index=True)
155
 
 
156
  st.dataframe(summary_df)
 
 
157
  st.download_button("πŸ“₯ Download Full Simulation CSV", full_data_df.to_csv(index=False), file_name="dice_dual_simulation.csv")
158
 
 
159
  with st.expander("πŸ” Show Detailed Simulation Logs"):
160
  st.dataframe(full_data_df)