Spaces:
Runtime error
Runtime error
File size: 3,229 Bytes
65ad6d3 d02f947 83e89fc d02f947 83e89fc d02f947 83e89fc d02f947 83e89fc d02f947 83e89fc d02f947 83e89fc d02f947 83e89fc d02f947 83e89fc d02f947 83e89fc d02f947 83e89fc d02f947 83e89fc d02f947 83e89fc d02f947 83e89fc d02f947 83e89fc d02f947 83e89fc d02f947 83e89fc d02f947 83e89fc d02f947 83e89fc | 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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
import streamlit as st
import pandas as pd
import random
import hmac
import hashlib
st.set_page_config(page_title="Stake Dice Strategy - v2.3", layout="wide")
st.title("π² Stake Dice Auto Strategy Simulator - v2.3 (Manual-Only Features)")
st.sidebar.header("Simulation Settings")
initial_balance = st.sidebar.number_input("Starting Balance (USD)", value=200.0)
base_bet = st.sidebar.number_input("Base Bet (USD)", value=0.0001, step=0.0001, format="%.4f")
num_bets = st.sidebar.number_input("Number of Bets", value=5000, step=1000)
num_runs = st.sidebar.number_input("Number of Runs", value=5, step=1)
random_seed = st.sidebar.number_input("Random Seed", value=42, step=1)
random.seed(random_seed)
st.sidebar.markdown("---")
st.sidebar.subheader("π Provably Fair Dice (Optional)")
use_provably_fair = st.sidebar.checkbox("Use Provably Fair Dice", value=False)
client_seed = st.sidebar.text_input("Client Seed", value="widichandra")
server_seed = "serverseed123"
house_edge = 1.0
def roll_dice(nonce):
if use_provably_fair:
message = f"{client_seed}:{nonce}"
hmac_hash = hmac.new(server_seed.encode(), message.encode(), hashlib.sha256).hexdigest()
int_val = int(hmac_hash[:13], 16)
float_val = int_val / float(2**52)
roll = (float_val * 10001) / 100
return min(round(roll, 5), 100.00000)
else:
roll = (random.random() * 10001) / 100
return min(round(roll, 5), 100.00000)
def simulate_v23(run_id):
balance = initial_balance
bet = base_bet
win_chance = 2.02
multiplier = (100 - house_edge) / win_chance
win_streak = 0
loss_count = 0
over_under = "Under"
max_bet_cap = initial_balance * 0.2
data = []
for i in range(num_bets):
if balance < bet or bet > max_bet_cap:
break
roll = roll_dice(i + run_id * num_bets)
is_win = roll < win_chance if over_under == "Under" else roll > (100 - win_chance)
result = {
"Run": run_id,
"Round": i + 1,
"Bet": bet,
"Roll": roll,
"Over/Under": over_under
}
if is_win:
win = bet * multiplier
balance += win - bet
bet = base_bet
win_streak += 1
loss_count = 0
if win_streak % 2 == 0:
over_under = "Over" if over_under == "Under" else "Under"
else:
balance -= bet
loss_count += 1
win_streak = 0
if loss_count % 10 == 0:
bet *= 2
bet = min(bet, max_bet_cap)
result["Balance"] = round(balance, 4)
result["Result"] = "Win" if is_win else "Loss"
data.append(result)
df = pd.DataFrame(data)
return df
st.subheader("π Simulation Result")
all_data = []
for run in range(1, num_runs + 1):
df = simulate_v23(run)
df["Strategy"] = "Improved v2.3 (Manual Only)"
all_data.append(df)
result_df = pd.concat(all_data, ignore_index=True)
st.dataframe(result_df)
st.download_button("π₯ Download CSV", data=result_df.to_csv(index=False), file_name="stake_dice_v23_simulation.csv")
with st.expander("π Show Full Log"):
st.dataframe(result_df)
|