xtreys 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- xtreys-0.2.0/PKG-INFO +147 -0
- xtreys-0.2.0/README.md +134 -0
- xtreys-0.2.0/pyproject.toml +25 -0
- xtreys-0.2.0/setup.cfg +4 -0
- xtreys-0.2.0/xtreys.egg-info/PKG-INFO +147 -0
- xtreys-0.2.0/xtreys.egg-info/SOURCES.txt +10 -0
- xtreys-0.2.0/xtreys.egg-info/dependency_links.txt +1 -0
- xtreys-0.2.0/xtreys.egg-info/requires.txt +1 -0
- xtreys-0.2.0/xtreys.egg-info/top_level.txt +1 -0
- xtreys-0.2.0/xtreyspf/__init__.py +8 -0
- xtreys-0.2.0/xtreyspf/equity.py +74 -0
- xtreys-0.2.0/xtreyspf/evaluator.py +60 -0
xtreys-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: xtreys
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: An extended add-on that is mixable with Treys.
|
|
5
|
+
Author: TheCursedOne
|
|
6
|
+
Project-URL: Homepage, https://github.com/bingchiliingsacker-dot/XtreysPF
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.7
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: treys
|
|
13
|
+
|
|
14
|
+
## Description
|
|
15
|
+
|
|
16
|
+
**Xtreys**(*eXtended treys*) is a lightweight **add-on** to the library **Treys**. **Xtreys** uses integers created from **Treys** to rank hole cards, calculate equity, etc.
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
First, **open** your terminal and **run**:
|
|
24
|
+
```bash
|
|
25
|
+
pip install git+https://github.com/bingchiliingsacker-dot/XtreysPF.git
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
or:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install xtreyspf
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Note: If you run into any issues installing or using XtreysPF, feel free to open a ticket on the **Issues** tab!
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## Usages
|
|
38
|
+
|
|
39
|
+
One of **Xtreys**' goals is to evaluate hole cards only.
|
|
40
|
+
Cards are ranked from 1 to 91 with 'A-A' or pocket Ace's being the strongest and a '2-7' being the weakest pair
|
|
41
|
+
|
|
42
|
+
The function for this is ```preflop_eval```.
|
|
43
|
+
|
|
44
|
+
Here is a quick test to see if **Xtreys** is working:
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from treys import Deck
|
|
48
|
+
from xtreys import preflop_eval
|
|
49
|
+
|
|
50
|
+
d = Deck()
|
|
51
|
+
cards = d.draw(2)
|
|
52
|
+
|
|
53
|
+
rank = preflop_eval(cards)
|
|
54
|
+
print(f"Pre-flop hand rank:\t{rank}") #Output: Pre-flop hand rank: 1-91
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Another usage of **Xtreys** is calculating the approximate and accurate equity of cards.
|
|
58
|
+
```approximate_equity``` gives an approximate equity from 0.1(lowest) to 0.9(highest).
|
|
59
|
+
|
|
60
|
+
Heres a quick test:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from xtreys import approximate_equity
|
|
64
|
+
|
|
65
|
+
d = Deck()
|
|
66
|
+
|
|
67
|
+
cards = d.draw(2)
|
|
68
|
+
flop_board = d.draw(3)
|
|
69
|
+
turn_card, river_card = d.draw(1), d.draw(1)
|
|
70
|
+
|
|
71
|
+
turn_board = flop_board + turn_card
|
|
72
|
+
river_board = flop_board + river_card
|
|
73
|
+
|
|
74
|
+
flop_equity = approximate_equity(cards, flop_board)
|
|
75
|
+
|
|
76
|
+
print('---Flop---')
|
|
77
|
+
print(f'Approximate equity:\t{flop_equity}')
|
|
78
|
+
print('')
|
|
79
|
+
|
|
80
|
+
turn_equity = approximate_equity(cards, turn_board)
|
|
81
|
+
|
|
82
|
+
print('---Turn---')
|
|
83
|
+
print(f'Approximate equity:\t{turn_equity}')
|
|
84
|
+
print('')
|
|
85
|
+
|
|
86
|
+
river_equity = approximate_equity(cards, river_board)
|
|
87
|
+
|
|
88
|
+
print('---River---')
|
|
89
|
+
print(f'Approximate equity:\t{river_equity}')
|
|
90
|
+
|
|
91
|
+
'''
|
|
92
|
+
Output:
|
|
93
|
+
---Flop---
|
|
94
|
+
Approximate equity: 0.2
|
|
95
|
+
|
|
96
|
+
---Turn---
|
|
97
|
+
Approximate equity: 0.3
|
|
98
|
+
|
|
99
|
+
---River---
|
|
100
|
+
Approximate equity: 0.2
|
|
101
|
+
'''
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Accurate equity outputs a much more pinpoint equity than approximate equity, it needs a cards variable of type list[int], a board variable of type list[int], and how many Monte-Carlo simulations you want to make(default=50).
|
|
105
|
+
|
|
106
|
+
Heres a quick test for ```accurate_equity```:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from xtreys import accurate_equity
|
|
110
|
+
d = Deck()
|
|
111
|
+
|
|
112
|
+
cards = d.draw(2)
|
|
113
|
+
flop_board = d.draw(3)
|
|
114
|
+
turn_card, river_card = d.draw(1), d.draw(1)
|
|
115
|
+
|
|
116
|
+
turn_board = flop_board + turn_card
|
|
117
|
+
|
|
118
|
+
flop_equity = accurate_equity(cards, flop_board, 100)
|
|
119
|
+
|
|
120
|
+
print('---Flop---')
|
|
121
|
+
print(f'Accurate equity:\t{flop_equity:.2f}')
|
|
122
|
+
print('')
|
|
123
|
+
|
|
124
|
+
turn_equity = accurate_equity(cards, turn_board, 150)
|
|
125
|
+
|
|
126
|
+
print('---Turn---')
|
|
127
|
+
print(f'Accurate equity:\t{turn_equity:.2f}')
|
|
128
|
+
print('')
|
|
129
|
+
|
|
130
|
+
river_equity = accurate_equity(cards, river_board)
|
|
131
|
+
|
|
132
|
+
print('---River---')
|
|
133
|
+
print(f'Accurate equity:\t{river_equity:.2f}')
|
|
134
|
+
river_board = flop_board + river_card
|
|
135
|
+
|
|
136
|
+
'''
|
|
137
|
+
Output:
|
|
138
|
+
|
|
139
|
+
---Flop---
|
|
140
|
+
Accurate equity: 0.54
|
|
141
|
+
|
|
142
|
+
---Turn---
|
|
143
|
+
Accurate equity: 0.39
|
|
144
|
+
|
|
145
|
+
---River---
|
|
146
|
+
Accurate equity: 0.30
|
|
147
|
+
'''
|
xtreys-0.2.0/README.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
## Description
|
|
2
|
+
|
|
3
|
+
**Xtreys**(*eXtended treys*) is a lightweight **add-on** to the library **Treys**. **Xtreys** uses integers created from **Treys** to rank hole cards, calculate equity, etc.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
First, **open** your terminal and **run**:
|
|
11
|
+
```bash
|
|
12
|
+
pip install git+https://github.com/bingchiliingsacker-dot/XtreysPF.git
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
or:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install xtreyspf
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Note: If you run into any issues installing or using XtreysPF, feel free to open a ticket on the **Issues** tab!
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## Usages
|
|
25
|
+
|
|
26
|
+
One of **Xtreys**' goals is to evaluate hole cards only.
|
|
27
|
+
Cards are ranked from 1 to 91 with 'A-A' or pocket Ace's being the strongest and a '2-7' being the weakest pair
|
|
28
|
+
|
|
29
|
+
The function for this is ```preflop_eval```.
|
|
30
|
+
|
|
31
|
+
Here is a quick test to see if **Xtreys** is working:
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from treys import Deck
|
|
35
|
+
from xtreys import preflop_eval
|
|
36
|
+
|
|
37
|
+
d = Deck()
|
|
38
|
+
cards = d.draw(2)
|
|
39
|
+
|
|
40
|
+
rank = preflop_eval(cards)
|
|
41
|
+
print(f"Pre-flop hand rank:\t{rank}") #Output: Pre-flop hand rank: 1-91
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Another usage of **Xtreys** is calculating the approximate and accurate equity of cards.
|
|
45
|
+
```approximate_equity``` gives an approximate equity from 0.1(lowest) to 0.9(highest).
|
|
46
|
+
|
|
47
|
+
Heres a quick test:
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from xtreys import approximate_equity
|
|
51
|
+
|
|
52
|
+
d = Deck()
|
|
53
|
+
|
|
54
|
+
cards = d.draw(2)
|
|
55
|
+
flop_board = d.draw(3)
|
|
56
|
+
turn_card, river_card = d.draw(1), d.draw(1)
|
|
57
|
+
|
|
58
|
+
turn_board = flop_board + turn_card
|
|
59
|
+
river_board = flop_board + river_card
|
|
60
|
+
|
|
61
|
+
flop_equity = approximate_equity(cards, flop_board)
|
|
62
|
+
|
|
63
|
+
print('---Flop---')
|
|
64
|
+
print(f'Approximate equity:\t{flop_equity}')
|
|
65
|
+
print('')
|
|
66
|
+
|
|
67
|
+
turn_equity = approximate_equity(cards, turn_board)
|
|
68
|
+
|
|
69
|
+
print('---Turn---')
|
|
70
|
+
print(f'Approximate equity:\t{turn_equity}')
|
|
71
|
+
print('')
|
|
72
|
+
|
|
73
|
+
river_equity = approximate_equity(cards, river_board)
|
|
74
|
+
|
|
75
|
+
print('---River---')
|
|
76
|
+
print(f'Approximate equity:\t{river_equity}')
|
|
77
|
+
|
|
78
|
+
'''
|
|
79
|
+
Output:
|
|
80
|
+
---Flop---
|
|
81
|
+
Approximate equity: 0.2
|
|
82
|
+
|
|
83
|
+
---Turn---
|
|
84
|
+
Approximate equity: 0.3
|
|
85
|
+
|
|
86
|
+
---River---
|
|
87
|
+
Approximate equity: 0.2
|
|
88
|
+
'''
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Accurate equity outputs a much more pinpoint equity than approximate equity, it needs a cards variable of type list[int], a board variable of type list[int], and how many Monte-Carlo simulations you want to make(default=50).
|
|
92
|
+
|
|
93
|
+
Heres a quick test for ```accurate_equity```:
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from xtreys import accurate_equity
|
|
97
|
+
d = Deck()
|
|
98
|
+
|
|
99
|
+
cards = d.draw(2)
|
|
100
|
+
flop_board = d.draw(3)
|
|
101
|
+
turn_card, river_card = d.draw(1), d.draw(1)
|
|
102
|
+
|
|
103
|
+
turn_board = flop_board + turn_card
|
|
104
|
+
|
|
105
|
+
flop_equity = accurate_equity(cards, flop_board, 100)
|
|
106
|
+
|
|
107
|
+
print('---Flop---')
|
|
108
|
+
print(f'Accurate equity:\t{flop_equity:.2f}')
|
|
109
|
+
print('')
|
|
110
|
+
|
|
111
|
+
turn_equity = accurate_equity(cards, turn_board, 150)
|
|
112
|
+
|
|
113
|
+
print('---Turn---')
|
|
114
|
+
print(f'Accurate equity:\t{turn_equity:.2f}')
|
|
115
|
+
print('')
|
|
116
|
+
|
|
117
|
+
river_equity = accurate_equity(cards, river_board)
|
|
118
|
+
|
|
119
|
+
print('---River---')
|
|
120
|
+
print(f'Accurate equity:\t{river_equity:.2f}')
|
|
121
|
+
river_board = flop_board + river_card
|
|
122
|
+
|
|
123
|
+
'''
|
|
124
|
+
Output:
|
|
125
|
+
|
|
126
|
+
---Flop---
|
|
127
|
+
Accurate equity: 0.54
|
|
128
|
+
|
|
129
|
+
---Turn---
|
|
130
|
+
Accurate equity: 0.39
|
|
131
|
+
|
|
132
|
+
---River---
|
|
133
|
+
Accurate equity: 0.30
|
|
134
|
+
'''
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ['setuptools>=61.0']
|
|
3
|
+
build-backend = 'setuptools.build_meta'
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = 'xtreys'
|
|
7
|
+
version = '0.2.0'
|
|
8
|
+
authors = [
|
|
9
|
+
{ name='TheCursedOne' },
|
|
10
|
+
]
|
|
11
|
+
description = 'An extended add-on that is mixable with Treys.'
|
|
12
|
+
readme = 'README.md'
|
|
13
|
+
requires-python = '>=3.7'
|
|
14
|
+
classifiers = [
|
|
15
|
+
'Programming Language :: Python :: 3',
|
|
16
|
+
'License :: OSI Approved :: MIT License',
|
|
17
|
+
'Operating System :: OS Independent',
|
|
18
|
+
]
|
|
19
|
+
dependencies = [
|
|
20
|
+
'treys'
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
'Homepage' = 'https://github.com/bingchiliingsacker-dot/XtreysPF'
|
|
25
|
+
|
xtreys-0.2.0/setup.cfg
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: xtreys
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: An extended add-on that is mixable with Treys.
|
|
5
|
+
Author: TheCursedOne
|
|
6
|
+
Project-URL: Homepage, https://github.com/bingchiliingsacker-dot/XtreysPF
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.7
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: treys
|
|
13
|
+
|
|
14
|
+
## Description
|
|
15
|
+
|
|
16
|
+
**Xtreys**(*eXtended treys*) is a lightweight **add-on** to the library **Treys**. **Xtreys** uses integers created from **Treys** to rank hole cards, calculate equity, etc.
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
First, **open** your terminal and **run**:
|
|
24
|
+
```bash
|
|
25
|
+
pip install git+https://github.com/bingchiliingsacker-dot/XtreysPF.git
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
or:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install xtreyspf
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Note: If you run into any issues installing or using XtreysPF, feel free to open a ticket on the **Issues** tab!
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## Usages
|
|
38
|
+
|
|
39
|
+
One of **Xtreys**' goals is to evaluate hole cards only.
|
|
40
|
+
Cards are ranked from 1 to 91 with 'A-A' or pocket Ace's being the strongest and a '2-7' being the weakest pair
|
|
41
|
+
|
|
42
|
+
The function for this is ```preflop_eval```.
|
|
43
|
+
|
|
44
|
+
Here is a quick test to see if **Xtreys** is working:
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from treys import Deck
|
|
48
|
+
from xtreys import preflop_eval
|
|
49
|
+
|
|
50
|
+
d = Deck()
|
|
51
|
+
cards = d.draw(2)
|
|
52
|
+
|
|
53
|
+
rank = preflop_eval(cards)
|
|
54
|
+
print(f"Pre-flop hand rank:\t{rank}") #Output: Pre-flop hand rank: 1-91
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Another usage of **Xtreys** is calculating the approximate and accurate equity of cards.
|
|
58
|
+
```approximate_equity``` gives an approximate equity from 0.1(lowest) to 0.9(highest).
|
|
59
|
+
|
|
60
|
+
Heres a quick test:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from xtreys import approximate_equity
|
|
64
|
+
|
|
65
|
+
d = Deck()
|
|
66
|
+
|
|
67
|
+
cards = d.draw(2)
|
|
68
|
+
flop_board = d.draw(3)
|
|
69
|
+
turn_card, river_card = d.draw(1), d.draw(1)
|
|
70
|
+
|
|
71
|
+
turn_board = flop_board + turn_card
|
|
72
|
+
river_board = flop_board + river_card
|
|
73
|
+
|
|
74
|
+
flop_equity = approximate_equity(cards, flop_board)
|
|
75
|
+
|
|
76
|
+
print('---Flop---')
|
|
77
|
+
print(f'Approximate equity:\t{flop_equity}')
|
|
78
|
+
print('')
|
|
79
|
+
|
|
80
|
+
turn_equity = approximate_equity(cards, turn_board)
|
|
81
|
+
|
|
82
|
+
print('---Turn---')
|
|
83
|
+
print(f'Approximate equity:\t{turn_equity}')
|
|
84
|
+
print('')
|
|
85
|
+
|
|
86
|
+
river_equity = approximate_equity(cards, river_board)
|
|
87
|
+
|
|
88
|
+
print('---River---')
|
|
89
|
+
print(f'Approximate equity:\t{river_equity}')
|
|
90
|
+
|
|
91
|
+
'''
|
|
92
|
+
Output:
|
|
93
|
+
---Flop---
|
|
94
|
+
Approximate equity: 0.2
|
|
95
|
+
|
|
96
|
+
---Turn---
|
|
97
|
+
Approximate equity: 0.3
|
|
98
|
+
|
|
99
|
+
---River---
|
|
100
|
+
Approximate equity: 0.2
|
|
101
|
+
'''
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Accurate equity outputs a much more pinpoint equity than approximate equity, it needs a cards variable of type list[int], a board variable of type list[int], and how many Monte-Carlo simulations you want to make(default=50).
|
|
105
|
+
|
|
106
|
+
Heres a quick test for ```accurate_equity```:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from xtreys import accurate_equity
|
|
110
|
+
d = Deck()
|
|
111
|
+
|
|
112
|
+
cards = d.draw(2)
|
|
113
|
+
flop_board = d.draw(3)
|
|
114
|
+
turn_card, river_card = d.draw(1), d.draw(1)
|
|
115
|
+
|
|
116
|
+
turn_board = flop_board + turn_card
|
|
117
|
+
|
|
118
|
+
flop_equity = accurate_equity(cards, flop_board, 100)
|
|
119
|
+
|
|
120
|
+
print('---Flop---')
|
|
121
|
+
print(f'Accurate equity:\t{flop_equity:.2f}')
|
|
122
|
+
print('')
|
|
123
|
+
|
|
124
|
+
turn_equity = accurate_equity(cards, turn_board, 150)
|
|
125
|
+
|
|
126
|
+
print('---Turn---')
|
|
127
|
+
print(f'Accurate equity:\t{turn_equity:.2f}')
|
|
128
|
+
print('')
|
|
129
|
+
|
|
130
|
+
river_equity = accurate_equity(cards, river_board)
|
|
131
|
+
|
|
132
|
+
print('---River---')
|
|
133
|
+
print(f'Accurate equity:\t{river_equity:.2f}')
|
|
134
|
+
river_board = flop_board + river_card
|
|
135
|
+
|
|
136
|
+
'''
|
|
137
|
+
Output:
|
|
138
|
+
|
|
139
|
+
---Flop---
|
|
140
|
+
Accurate equity: 0.54
|
|
141
|
+
|
|
142
|
+
---Turn---
|
|
143
|
+
Accurate equity: 0.39
|
|
144
|
+
|
|
145
|
+
---River---
|
|
146
|
+
Accurate equity: 0.30
|
|
147
|
+
'''
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
treys
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
xtreyspf
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
from treys import Evaluator
|
|
2
|
+
|
|
3
|
+
evaluator = Evaluator()
|
|
4
|
+
|
|
5
|
+
def accurate_equity(
|
|
6
|
+
cards: list[int],
|
|
7
|
+
board: list[int],
|
|
8
|
+
simulations: int = 50
|
|
9
|
+
) -> float:
|
|
10
|
+
'''
|
|
11
|
+
Accurately finds the equity/win rate of
|
|
12
|
+
variable cards. Uses Monte-Carlo simulation
|
|
13
|
+
method to evaluate which kind of makes it less
|
|
14
|
+
accurate but its still accurate.
|
|
15
|
+
|
|
16
|
+
Simulations variable can be changed to what your heart desires.
|
|
17
|
+
|
|
18
|
+
Cards variable needs the list of raw strings generated from Deck().
|
|
19
|
+
|
|
20
|
+
Board variable also needs the list of raw strings generated from Deck().
|
|
21
|
+
'''
|
|
22
|
+
|
|
23
|
+
win = 0
|
|
24
|
+
tie = 0
|
|
25
|
+
lose = 0
|
|
26
|
+
player_rank_equivalent = evaluator.evaluate(board, cards)
|
|
27
|
+
|
|
28
|
+
for _ in range(simulations):
|
|
29
|
+
|
|
30
|
+
deck = Deck()
|
|
31
|
+
|
|
32
|
+
hand = deck.draw(2)
|
|
33
|
+
|
|
34
|
+
hand_rank_equivalent = evaluator.evaluate(board, hand)
|
|
35
|
+
|
|
36
|
+
if hand_rank_equivalent > player_rank_equivalent:
|
|
37
|
+
win += 1
|
|
38
|
+
elif hand_rank_equivalent == player_rank_equivalent:
|
|
39
|
+
tie += 1
|
|
40
|
+
else:
|
|
41
|
+
lose += 1
|
|
42
|
+
|
|
43
|
+
total_possibility = win + tie + lose
|
|
44
|
+
return (win + 0.5 * tie) / total_possibility
|
|
45
|
+
|
|
46
|
+
def approximate_equity(
|
|
47
|
+
cards: list[int],
|
|
48
|
+
board: list[int]
|
|
49
|
+
) -> float:
|
|
50
|
+
'''
|
|
51
|
+
Finds the approximate win rate of the card.
|
|
52
|
+
I do not recommend this function unless
|
|
53
|
+
you are calculating the equity of post-flop
|
|
54
|
+
without a worry of hacking.
|
|
55
|
+
|
|
56
|
+
Cards and board variables both need the list of raw integers generated from Deck()
|
|
57
|
+
'''
|
|
58
|
+
|
|
59
|
+
approxy = evaluator.evaluate(board, cards)
|
|
60
|
+
rank_class = evaluator.get_rank_class(approxy)
|
|
61
|
+
|
|
62
|
+
approximate_book = {
|
|
63
|
+
1: 0.9,
|
|
64
|
+
2: 0.8,
|
|
65
|
+
3: 0.7,
|
|
66
|
+
4: 0.6,
|
|
67
|
+
5: 0.5,
|
|
68
|
+
6: 0.4,
|
|
69
|
+
7: 0.3,
|
|
70
|
+
8: 0.2,
|
|
71
|
+
9: 0.1,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return approximate_book.get(rank_class, 0.0)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#=============================================================================
|
|
2
|
+
#----------------------------OPEN-SOURCE CODE---------------------------------
|
|
3
|
+
#
|
|
4
|
+
# An extended add-on of the library treys.
|
|
5
|
+
#
|
|
6
|
+
# MADE BY: TheCursedOne
|
|
7
|
+
#=============================================================================
|
|
8
|
+
|
|
9
|
+
from treys import Card, Evaluator
|
|
10
|
+
|
|
11
|
+
evaluator = Evaluator()
|
|
12
|
+
|
|
13
|
+
CARD_COMBINATIONS = {
|
|
14
|
+
# --- PAIRS TIER (#1 to #13) ---
|
|
15
|
+
'A-A': 1, 'K-K': 2, 'Q-Q': 3, 'J-J': 4, 'T-T': 5,
|
|
16
|
+
'9-9': 6, '8-8': 7, '7-7': 8, '6-6': 9, '5-5': 10,
|
|
17
|
+
'4-4': 11, '3-3': 12, '2-2': 13,
|
|
18
|
+
|
|
19
|
+
# --- HIGH CARDS TIER (#14 to #91) ---
|
|
20
|
+
'A-K': 14, 'A-Q': 15, 'A-J': 16, 'K-Q': 17, 'A-T': 18,
|
|
21
|
+
'K-J': 19, 'Q-J': 20, 'K-T': 21, 'Q-T': 22, 'J-T': 23,
|
|
22
|
+
|
|
23
|
+
'A-9': 24, 'A-8': 25, 'A-7': 26, 'A-6': 27, 'A-5': 28,
|
|
24
|
+
'A-4': 29, 'A-3': 30, 'A-2': 31,
|
|
25
|
+
|
|
26
|
+
'K-9': 32, 'K-8': 33, 'K-7': 34, 'K-6': 35, 'K-5': 36,
|
|
27
|
+
'K-4': 37, 'K-3': 38, 'K-2': 39,
|
|
28
|
+
|
|
29
|
+
'Q-9': 40, 'Q-8': 41, 'Q-7': 42, 'Q-6': 43, 'Q-5': 44,
|
|
30
|
+
'Q-4': 45, 'Q-3': 46, 'Q-2': 47,
|
|
31
|
+
|
|
32
|
+
'J-9': 48, 'J-8': 49, 'J-7': 50, 'T-9': 51, 'J-6': 52,
|
|
33
|
+
'T-8': 53, 'J-5': 54, 'J-4': 55, 'J-3': 56, 'J-2': 57,
|
|
34
|
+
|
|
35
|
+
'T-7': 58, '9-8': 59, 'T-6': 60, '9-7': 61, 'T-5': 62,
|
|
36
|
+
'T-4': 63, 'T-3': 64, 'T-2': 65, '9-6': 66, '9-5': 67,
|
|
37
|
+
'9-4': 68, '9-3': 69, '9-2': 70,
|
|
38
|
+
|
|
39
|
+
'8-7': 71, '8-6': 72, '8-5': 73, '8-4': 74, '8-3': 75,
|
|
40
|
+
'8-2': 76, '7-6': 77, '7-5': 78, '7-4': 79, '7-3': 80,
|
|
41
|
+
|
|
42
|
+
'6-5': 81, '6-4': 82, '6-3': 83, '5-4': 84, '6-2': 85,
|
|
43
|
+
'5-3': 86, '4-3': 87, '5-2': 88, '4-2': 89, '3-2': 90,
|
|
44
|
+
'7-2': 91
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def preflop_eval(cards: list[int] | list[str]) -> int:
|
|
49
|
+
'''
|
|
50
|
+
Note: both [4883929747, 47828274732] and [Ah, Kd] are accepted.
|
|
51
|
+
'''
|
|
52
|
+
card_1 = Card.int_to_str(cards[0]) if isinstance(cards[0], int) else cards[0]
|
|
53
|
+
card_2 = Card.int_to_str(cards[1]) if isinstance(cards[1], int) else cards[1]
|
|
54
|
+
|
|
55
|
+
card_rank = f'{card_1[0]}-{card_2[0]}'
|
|
56
|
+
|
|
57
|
+
if card_rank not in CARD_COMBINATIONS:
|
|
58
|
+
card_rank = f'{card_2[0]}-{card_1[0]}'
|
|
59
|
+
|
|
60
|
+
return CARD_COMBINATIONS.get(card_rank, 91)
|