-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreflop_ranges.py
More file actions
executable file
·78 lines (65 loc) · 2 KB
/
Copy pathpreflop_ranges.py
File metadata and controls
executable file
·78 lines (65 loc) · 2 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
#!/home/oscar/anaconda3/bin/python3
from common.range import Range
from common.hand import Hand
from common.card import Card
from pprint import pprint
import operator
import json
#with open('lightdump.json') as data_file:
with open('dump.json') as data_file:
data = json.load(data_file)
values = []
for i in data:
if 'infos' in i:
if 'currency' in i['infos']:
if i['infos']['currency'] not in values:
values.append(i['infos']['currency'])
if '0,' in i['infos']['currency'] :
print(i['filename'])
print('Stakes parsed:',values)
players = {}
ranges = [Range(''),Range(''),Range(''),Range('')]
probas = [{},{},{},{}]
parsedHands = 0
for hand in data:
if 'players' in hand:
parsedHands += 1
for player in hand['players']:
if player['name'] in players:
players[player['name']] += 1
else:
players[player['name']] = 1
if player['name'] == 'daftReivaX' and player['seat'] in [4,5,6,1]:
ind = (player['seat']-4)%6
for action in hand['actions']['PREFLOP']:
if action['name'] == 'daftReivaX' and action['type'] == 'raises':
h = Hand([Card(hand['cards']['daftReivaX'][0]),Card(hand['cards']['daftReivaX'][1])])
h = h.getStandardNotation()
if h not in probas[ind]:
probas[ind][h] = 0
probas[ind][h] += 1
elif action['name'] == 'daftReivaX' and action['type'] == 'fold':
h = Hand([Card(hand['cards']['daftReivaX'][0]),Card(hand['cards']['daftReivaX'][1])])
h = h.getStandardNotation()
if h not in probas[ind]:
probas[ind][h] = 0
probas[ind][h] -= 1
for idx,proba in enumerate(probas):
for hand in proba:
if proba[hand] > 0:
ranges[idx].addRange(hand)
print('\n\n\n',parsedHands,'hands parsed:')
print('\n\nEP range:')
ranges[0].print()
print('\n\nMP range:')
ranges[1].print()
print('\n\nCU range:')
ranges[2].print()
print('\n\nBU range:')
ranges[3].print()
pl = sorted(players.items(), key=operator.itemgetter(1))
print(pl)
print('Players: hands:')
for k,v in pl:
if v > 30:
print(k,' ',v)