Spaces:
Sleeping
Sleeping
File size: 2,705 Bytes
b578b56 |
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 |
import streamlit as st
from prettytable import PrettyTable
import simulation as s
from poker_functions import Card
def run_simulation(
hand: list[str],
flop: list[str] = None,
turn: list[str] = None,
river: list[str] = None,
sims=10000,
) -> None:
sim = s.simulation_one_player(hand, flop, turn, river, sims=sims)
hc_pct = s.percent(sim[1], sim[0])
hc_ratio = s.ratio(sim[1], sim[0])
pair_pct = s.percent(sim[2], sim[0])
pair_ratio = s.ratio(sim[2], sim[0])
two_pair_pct = s.percent(sim[3], sim[0])
two_pair_ratio = s.ratio(sim[3], sim[0])
three_ok_pct = s.percent(sim[4], sim[0])
three_ok_ratio = s.ratio(sim[4], sim[0])
straight_pct = s.percent(sim[5], sim[0])
straight_ratio = s.ratio(sim[5], sim[0])
flush_pct = s.percent(sim[6], sim[0])
flush_ratio = s.ratio(sim[6], sim[0])
boat_pct = s.percent(sim[7], sim[0])
boat_ratio = s.ratio(sim[7], sim[0])
quads_pct = s.percent(sim[8], sim[0])
quads_ratio = s.ratio(sim[8], sim[0])
strt_flush_pct = s.percent(sim[9], sim[0])
strt_flush_ratio = s.ratio(sim[9], sim[0])
hole_card_str = f"{Card(hand[0]).pretty_name} {Card(hand[1]).pretty_name}"
table = PrettyTable()
table.field_names = ["Your Hand", "Board"]
if flop is None:
flop = []
if turn is None:
turn = []
if river is None:
river = []
board_str = "".join(f"{Card(card).pretty_name} " for card in (flop + turn + river))
table.add_row([hole_card_str, board_str])
odds = PrettyTable()
odds.add_column(
"Best Final Hand",
[
"High Card",
"Pair",
"Two Pair",
"Three of a Kind",
"Straight",
"Flush",
"Full House",
"Four of a Kind",
"Straight Flush",
],
)
odds.add_column(
"% Prob",
[
hc_pct,
pair_pct,
two_pair_pct,
three_ok_pct,
straight_pct,
flush_pct,
boat_pct,
quads_pct,
strt_flush_pct,
],
)
odds.add_column(
"Odds",
[
hc_ratio,
pair_ratio,
two_pair_ratio,
three_ok_ratio,
straight_ratio,
flush_ratio,
boat_ratio,
quads_ratio,
strt_flush_ratio,
],
)
st.divider()
st.subheader("Odds")
st.write(table, "\n")
st.write(f"We ran your hand {sims} times. Here's the odds:\n")
st.write(odds, "\n")
st.divider()
if __name__ == "__main__":
run_simulation(["As", "Ah"], ["2s", "3s", "4s"], sims=4000)
|