-
Notifications
You must be signed in to change notification settings - Fork 73
/
examples.py
63 lines (46 loc) · 1.74 KB
/
examples.py
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
from phevaluator import evaluate_cards
from phevaluator import evaluate_omaha_cards
def example1() -> None:
print("Example 1: A Texas Holdem example")
a = 7 * 4 + 0 # 9c
b = 2 * 4 + 0 # 4c
c = 2 * 4 + 3 # 4s
d = 7 * 4 + 1 # 9d
e = 2 * 4 + 2 # 4h
# Player 1
f = 10 * 4 + 0 # Qc
g = 4 * 4 + 0 # 6c
# Player 2
h = 0 * 4 + 0 # 2c
i = 7 * 4 + 2 # 9h
rank1 = evaluate_cards(a, b, c, d, e, f, g) # expected 292
rank2 = evaluate_cards(a, b, c, d, e, h, i) # expected 236
print(f"The rank of the hand in player 1 is {rank1}")
print(f"The rank of the hand in player 2 is {rank2}")
print("Player 2 has a stronger hand")
def example2() -> None:
print("Example 2: Another Texas Holdem example")
rank1 = evaluate_cards("9c", "4c", "4s", "9d", "4h", "Qc", "6c") # expected 292
rank2 = evaluate_cards("9c", "4c", "4s", "9d", "4h", "2c", "9h") # expected 236
print(f"The rank of the hand in player 1 is {rank1}")
print(f"The rank of the hand in player 2 is {rank2}")
print("Player 2 has a stronger hand")
def example3() -> None:
print("Example 3: An Omaha poker example")
# fmt: off
rank1 = evaluate_omaha_cards(
"4c", "5c", "6c", "7s", "8s", # community cards
"2c", "9c", "As", "Kd", # player hole cards
)
rank2 = evaluate_omaha_cards(
"4c", "5c", "6c", "7s", "8s", # community cards
"6s", "9s", "Ts", "Js", # player hole cards
)
# fmt: on
print(f"The rank of the hand in player 1 is {rank1}") # expected 1578
print(f"The rank of the hand in player 2 is {rank2}") # expected 1604
print("Player 1 has a stronger hand")
if __name__ == "__main__":
example1()
example2()
example3()