-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
100 lines (64 loc) · 3.06 KB
/
main.py
File metadata and controls
100 lines (64 loc) · 3.06 KB
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
from eval_poker import simulate_win_percent
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import uvicorn
from mangum import Mangum
app = FastAPI()
origins = [
"https://rollsolid.com",
"https://rollsolid.vercel.app",
"https://rollsolid-matthibbs7.vercel.app",
"http://localhost",
"http://localhost:8080",
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
handler = Mangum(app)
@app.get("/")
async def root():
return {"message": "Hello World"}
@app.get("/implied_odds/")
async def calculate_pot_odds(chance_percent: int = 1, current_pot: float = 1.0, amount_to_call: float = 1.0):
implied_odds_dollars = ((1 / (chance_percent/100.0)) * amount_to_call) - (current_pot + amount_to_call)
return {"implied_odds_dollars": implied_odds_dollars}
# @app.get("/g_bucks/")
# async def calculate_pot_odds(chance_percent: int = 1, current_pot: float = 1.0, amount_to_call: float = 1.0):
# implied_odds_dollars = ((1 / (chance_percent/100.0)) * amount_to_call) - (current_pot + amount_to_call)
# return {"implied_odds_dollars": implied_odds_dollars}
from eval_poker import simulate_win_percent
@app.get("/implied_odds/")
async def calculate_implied_odds(chance_percent: int = 1, current_pot: float = 1.0, amount_to_call: float = 1.0):
implied_odds_dollars = ((1 / (chance_percent/100.0)) * amount_to_call) - (current_pot + amount_to_call)
return {"implied_odds_dollars": implied_odds_dollars}
@app.get("/pot_odds/")
async def calculate_pot_odds(current_pot: float = 1.0, bet: float = 1.0):
pot_odds = (current_pot + bet ) /bet
return {"pot_odds": pot_odds}
num_sims = 1000
# my_board_representation = ["3c", "3d", "7s"]
# my_hand = ["3h", "4s"]
@app.get("/get_win_rate/")
async def calculate_pot_odds(my_board_representation: str = "", my_hand:str = "", num_sims: int = 1000):
my_board_representation = [str(x) for x in my_board_representation.split(",")]
my_hand = [str(x) for x in my_hand.split(",")]
print(my_hand)
win_percent = simulate_win_percent(my_board_representation, my_hand, num_sims, n_other_players=3,print_sim=False, print_ravg=True, decimal_places=2)
return {"win_percent": win_percent}
@app.get("/get_win_rate/")
async def get_win_rate(my_board_representation: str = "", my_hand: str = "", num_sims: int = 100, n_other_players: int = 5):
if my_board_representation == ['']:
my_board_representation = None
print(f"my_board_representation: {my_board_representation}")
if my_board_representation == "" or my_board_representation == '' or my_board_representation == ['']:
# return {"x":my_board_representation}
my_board_representation = None
else:
my_board_representation = my_board_representation.split(',')
my_hand = my_hand.split(',')
win_rate = simulate_win_percent(my_board_representation, my_hand, num_sims, n_other_players=5,print_sim=False, print_ravg=True, decimal_places=2)
return {"win_rate": win_rate}