wizardwerdna-pokerstats 1.0.14 → 1.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/checkps +7 -8
- data/lib/pokerstats.rb +2 -0
- data/lib/pokerstats/hand_constants.rb +25 -23
- data/lib/pokerstats/hand_history.rb +29 -26
- data/lib/pokerstats/hand_statistics.rb +173 -173
- data/lib/pokerstats/hand_statistics_api.rb +46 -44
- data/lib/pokerstats/player_statistics.rb +47 -45
- data/lib/pokerstats/plugins/aggression_statistics.rb +46 -44
- data/lib/pokerstats/plugins/blind_attack_statistics.rb +65 -63
- data/lib/pokerstats/plugins/cash_statistics.rb +82 -80
- data/lib/pokerstats/plugins/continuation_bet_statistics.rb +57 -55
- data/lib/pokerstats/plugins/preflop_raise_statistics.rb +40 -38
- data/lib/pokerstats/poker-edge.rb +39 -37
- data/lib/pokerstats/pokerstars_file.rb +77 -76
- data/lib/pokerstats/pokerstars_hand_history_parser.rb +100 -98
- data/pokerstats.gemspec +3 -4
- data/spec/hand_statistics_spec.rb +2 -0
- data/spec/player_statistics_spec.rb +1 -0
- data/spec/pokerstars_file_spec.rb +1 -1
- data/spec/pokerstars_hand_history_parser.rb +1 -1
- metadata +3 -5
- data/spec/zpokerstars_hand_history_parser_integration.txt +0 -62
@@ -1,93 +1,95 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
module Pokerstats
|
2
|
+
class CashStatistics < HandStatistics::Plugin
|
3
|
+
def initialize handstatistics
|
4
|
+
super handstatistics
|
5
|
+
@posted = {}
|
6
|
+
@paid = {}
|
7
|
+
@paid_this_round = {}
|
8
|
+
@won = {}
|
9
|
+
@cards = {}
|
10
|
+
@stats = {:posted => @posted, :paid => @paid, :won => @won, :cards => @cards}
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def posted(player)
|
14
|
+
@posted[player]
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
def paid(player)
|
18
|
+
@paid[player]
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
def paid_this_round(player)
|
22
|
+
@paid_this_round[player]
|
23
|
+
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
def won(player)
|
26
|
+
@won[player]
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
def cards(player)
|
30
|
+
@cards[player]
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
33
|
+
def self.report_specification
|
34
|
+
[
|
35
|
+
# [key, sql_type, function]
|
36
|
+
[:posted, 'decimal', :posted],
|
37
|
+
[:paid, 'decimal', :paid],
|
38
|
+
[:won, 'decimal', :won],
|
39
|
+
[:cards, 'string', :cards]
|
40
|
+
]
|
41
|
+
end
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
43
|
+
# def report(screen_name)
|
44
|
+
# {
|
45
|
+
# :posted => posted(screen_name),
|
46
|
+
# :paid => paid(screen_name),
|
47
|
+
# :won => won(screen_name),
|
48
|
+
# :cards => cards(screen_name)
|
49
|
+
# }
|
50
|
+
# end
|
50
51
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
def stats(player=nil)
|
53
|
+
return @stats unless player
|
54
|
+
# @stats.inject({}){|last, pair| last.merge(pair[0] => pair[1][player])}
|
55
|
+
end
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
def register_player(screen_name, street)
|
58
|
+
@posted[screen_name] = 0
|
59
|
+
@paid[screen_name] = 0
|
60
|
+
@won[screen_name] = 0
|
61
|
+
end
|
61
62
|
|
62
|
-
|
63
|
-
|
64
|
-
|
63
|
+
def street_transition_for_player street, player
|
64
|
+
@paid_this_round[player] = 0 unless street == :preflop
|
65
|
+
end
|
65
66
|
|
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
|
-
|
67
|
+
def apply_action action, street
|
68
|
+
player = action[:screen_name]
|
69
|
+
description = action[:description]
|
70
|
+
result = action[:result]
|
71
|
+
amount = action[:amount]
|
72
|
+
data = action[:data]
|
73
|
+
case result
|
74
|
+
when :post
|
75
|
+
@posted[player] += amount
|
76
|
+
@paid_this_round[player] += amount unless description == "antes"
|
77
|
+
when :pay
|
78
|
+
@paid[player] ||= 0
|
79
|
+
@paid[player] += amount
|
80
|
+
@paid_this_round[player] += amount
|
81
|
+
when :pay_to
|
82
|
+
net_amount_paid = amount - @paid_this_round[player]
|
83
|
+
action[:net_amount_paid] = net_amount_paid
|
84
|
+
@paid[player] += net_amount_paid
|
85
|
+
@paid_this_round[player] += net_amount_paid
|
86
|
+
when :win
|
87
|
+
@won[player] += amount
|
88
|
+
when :neutral
|
89
|
+
when :cards
|
90
|
+
@cards[player] = data
|
91
|
+
else raise "invalid action result: #{result.inspect}"
|
92
|
+
end
|
91
93
|
end
|
92
94
|
end
|
93
|
-
end
|
95
|
+
end
|
@@ -1,65 +1,67 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def cbet_opportunity?(screen_name, street = :flop)
|
12
|
-
# puts "cbet_opportunity?(#{screen_name}, #{street})"
|
13
|
-
# puts @first_aggression_opportunity.inspect
|
14
|
-
@number_preflop_raises==1 && @last_preflop_raiser==screen_name && @first_aggression_opportunity[street] && @first_aggression_opportunity[street][screen_name]
|
15
|
-
end
|
1
|
+
module Pokerstats
|
2
|
+
class ContinuationBetStatistics < HandStatistics::Plugin
|
3
|
+
def initialize handstatistics
|
4
|
+
super(handstatistics)
|
5
|
+
@last_preflop_raiser = nil
|
6
|
+
@number_preflop_raises = 0
|
7
|
+
@first_aggressor = {}
|
8
|
+
@first_aggression_opportunity = {}
|
9
|
+
@first_aggression_opportunity_taken = {}
|
10
|
+
end
|
16
11
|
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
def cbet_opportunity?(screen_name, street = :flop)
|
13
|
+
# puts "cbet_opportunity?(#{screen_name}, #{street})"
|
14
|
+
# puts @first_aggression_opportunity.inspect
|
15
|
+
@number_preflop_raises==1 && @last_preflop_raiser==screen_name && @first_aggression_opportunity[street] && @first_aggression_opportunity[street][screen_name]
|
16
|
+
end
|
20
17
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
[:is_cbet_opportunity, 'integer', :cbet_opportunity?],
|
25
|
-
[:is_cbet_opportunity_taken, 'integer', :cbet_opportunity_taken?]
|
26
|
-
]
|
27
|
-
end
|
18
|
+
def cbet_opportunity_taken?(screen_name, street = :flop)
|
19
|
+
cbet_opportunity?(screen_name) && @first_aggression_opportunity_taken[street][screen_name]
|
20
|
+
end
|
28
21
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
22
|
+
def self.report_specification
|
23
|
+
[
|
24
|
+
# [key, sql_type, function]
|
25
|
+
[:is_cbet_opportunity, 'integer', :cbet_opportunity?],
|
26
|
+
[:is_cbet_opportunity_taken, 'integer', :cbet_opportunity_taken?]
|
27
|
+
]
|
28
|
+
end
|
36
29
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
30
|
+
#
|
31
|
+
# def report(screen_name)
|
32
|
+
# {
|
33
|
+
# :is_cbet_opportunity => cbet_opportunity?(screen_name),
|
34
|
+
# :is_cbet_opportunity_taken => cbet_opportunity_taken?(screen_name)
|
35
|
+
# }
|
36
|
+
# end
|
43
37
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
38
|
+
def street_transition street
|
39
|
+
@first_aggressor[street] = nil
|
40
|
+
@first_aggression_opportunity[street] = {}
|
41
|
+
@first_aggression_opportunity_taken[street] = {}
|
42
|
+
super(street)
|
43
|
+
end
|
48
44
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
result = action[:result]
|
53
|
-
if street == :preflop and result == :pay_to
|
54
|
-
@number_preflop_raises += 1
|
55
|
-
@last_preflop_raiser = player
|
45
|
+
def street_transition_for_player street, player
|
46
|
+
@first_aggression_opportunity[street][player] = nil
|
47
|
+
@first_aggression_opportunity_taken[street][player] = false
|
56
48
|
end
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
49
|
+
|
50
|
+
def apply_action action, street
|
51
|
+
player = action[:screen_name]
|
52
|
+
aggression = action[:aggression]
|
53
|
+
result = action[:result]
|
54
|
+
if street == :preflop and result == :pay_to
|
55
|
+
@number_preflop_raises += 1
|
56
|
+
@last_preflop_raiser = player
|
57
|
+
end
|
58
|
+
if aggression != :neutral && @first_aggressor[street].nil? && @first_aggression_opportunity[street][player].nil?
|
59
|
+
@first_aggression_opportunity[street][player] = true
|
60
|
+
if aggression == :aggressive
|
61
|
+
@first_aggressor[street] = player
|
62
|
+
@first_aggression_opportunity_taken[street][player] = true
|
63
|
+
@hand_statistics.players.each {|player| @first_aggression_opportunity[street][player] ||= false}
|
64
|
+
end
|
63
65
|
end
|
64
66
|
end
|
65
67
|
end
|
@@ -1,47 +1,49 @@
|
|
1
|
-
|
1
|
+
module Pokerstats
|
2
|
+
class PreflopRaiseStatistics < HandStatistics::Plugin
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
def initialize handstatistics
|
5
|
+
super handstatistics
|
6
|
+
@pfr_opportunity = {}
|
7
|
+
@pfr_opportunity_taken = {}
|
8
|
+
@pfr_size_in_bb = {}
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def pfr_opportunity?(screen_name)
|
12
|
+
@pfr_opportunity[screen_name]
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
def pfr_opportunity_taken?(screen_name)
|
16
|
+
@pfr_opportunity[screen_name] && @pfr_opportunity_taken[screen_name]
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
def self.report_specification
|
20
|
+
[
|
21
|
+
# [key, sql_type, function]
|
22
|
+
[:is_pfr_opportunity, 'integer', :pfr_opportunity?],
|
23
|
+
[:is_pfr_opportunity_taken, 'integer', :pfr_opportunity_taken?]
|
24
|
+
]
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
# def report screen_name
|
28
|
+
# {
|
29
|
+
# :is_pfr_opportunity => pfr_opportunity?(screen_name),
|
30
|
+
# :is_pfr_opportunity_taken => pfr_opportunity_taken?(screen_name)
|
31
|
+
# }
|
32
|
+
# end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
34
|
+
def apply_action action, street
|
35
|
+
# puts "pfr: apply_action #{street}, #{action.inspect}"
|
36
|
+
result = action[:result]
|
37
|
+
player = action[:screen_name]
|
38
|
+
if street == :preflop and [:pay, :pay_to, :neutral].member?(result) and @pfr_opportunity[player].nil?
|
39
|
+
case result
|
40
|
+
when :pay, :neutral
|
41
|
+
@pfr_opportunity[player] = true
|
42
|
+
@pfr_opportunity_taken[player] = false
|
43
|
+
when :pay_to
|
44
|
+
@hand_statistics.players.each {|each_player| @pfr_opportunity[each_player] ||= (each_player == player)}
|
45
|
+
@pfr_opportunity_taken[player] = true
|
46
|
+
end
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
@@ -2,54 +2,56 @@ require 'rubygems'
|
|
2
2
|
require 'hpricot'
|
3
3
|
require 'open-uri'
|
4
4
|
|
5
|
-
|
5
|
+
module Pokerstats
|
6
|
+
class PokerEdge
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
def initialize screen_name
|
9
|
+
@screen_name = URI.escape(screen_name)
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
def get_response_from_internet
|
13
|
+
url = "http://www.poker-edge.com/whoami.php?name=#{@screen_name}"
|
14
|
+
puts url
|
15
|
+
open(url) do |f|
|
16
|
+
@response = f.read
|
17
|
+
end
|
18
|
+
@response
|
16
19
|
end
|
17
|
-
@response
|
18
|
-
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
def response
|
22
|
+
@response ||= get_response_from_internet
|
23
|
+
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
def preflop_style
|
26
|
+
if self.response =~ /(Pre-Flop Tend.*\n)/
|
27
|
+
verbose = $1.gsub(/<\/?[^>]*>/, "")
|
28
|
+
if verbose =~ /Pre-Flop Tendency: ([^-]*) -/
|
29
|
+
preflop_style = $1
|
30
|
+
else
|
31
|
+
preflop_style = "N/A"
|
32
|
+
end
|
31
33
|
end
|
34
|
+
preflop_style
|
32
35
|
end
|
33
|
-
preflop_style
|
34
|
-
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
def player_type
|
38
|
+
if response =~ /(Player Type.*\n)/
|
39
|
+
verbose = $1.gsub(/<\/?[^>]*>/, "")
|
40
|
+
if verbose =~ /[Yy]ou are a ([^(]* \(.*\))/
|
41
|
+
player = $1
|
42
|
+
else
|
43
|
+
player = ""
|
44
|
+
end
|
43
45
|
end
|
46
|
+
player
|
44
47
|
end
|
45
|
-
player
|
46
|
-
end
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
def report format = "%20s -- %s -- %s\n"
|
50
|
+
open("foo.html", "w+") do |file|
|
51
|
+
file.write(response)
|
52
|
+
end
|
53
|
+
`open foo.html`
|
54
|
+
printf(format, @screen_name, preflop_style, player_type)
|
51
55
|
end
|
52
|
-
`open foo.html`
|
53
|
-
printf(format, @screen_name, preflop_style, player_type)
|
54
56
|
end
|
55
57
|
end
|