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,62 +1,64 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module Pokerstats
|
2
|
+
module HandStatisticsAPI
|
3
|
+
def initialize handstatistics
|
4
|
+
@hand_statistics = handstatistics
|
5
|
+
end
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
def self.exposed_methods
|
8
|
+
self.public_instance_methods - StatisticsHolder.public_instance_methods
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def report screen_name
|
12
|
+
automatic_report screen_name
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
def register_player screen_name, street
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
def street_transition street
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
21
|
+
def street_transition_for_player street, player
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
def apply_action action, street
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
def automatic_report screen_name
|
28
|
+
result = {}
|
29
|
+
self.class.report_specification.each do |each|
|
30
|
+
result[each[0]] = send(each[2], screen_name)
|
31
|
+
end
|
32
|
+
result
|
30
33
|
end
|
31
|
-
result
|
32
|
-
end
|
33
34
|
|
34
|
-
|
35
|
+
private
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
module ClassMethods
|
38
|
+
def report_specification
|
39
|
+
[
|
40
|
+
# [key, sql_type, function]
|
41
|
+
]
|
42
|
+
end
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
def rails_migration_segment_for_player_data
|
45
|
+
prefix = "\n" + " " * 10
|
46
|
+
result = "#{prefix}# FROM #{self.to_s}"
|
47
|
+
report_specification.each do |each|
|
48
|
+
result += "#{prefix}t.#{each[1]}\t#{each[0].inspect}"
|
49
|
+
end
|
50
|
+
result += "\n"
|
48
51
|
end
|
49
|
-
result += "\n"
|
50
|
-
end
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
53
|
+
def rails_generator_command_line_for_player_data
|
54
|
+
report_specification.inject("") do |string, each|
|
55
|
+
string + "#{each[0]}:#{each[1]} "
|
56
|
+
end
|
55
57
|
end
|
56
58
|
end
|
57
|
-
end
|
58
59
|
|
59
|
-
|
60
|
-
|
60
|
+
def self.included(klass)
|
61
|
+
klass.extend ClassMethods
|
62
|
+
end
|
61
63
|
end
|
62
64
|
end
|
@@ -1,56 +1,58 @@
|
|
1
|
-
|
1
|
+
module Pokerstats
|
2
|
+
class PlayerStatistics
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
4
|
+
def initialize
|
5
|
+
@aggregate_statistics = {}
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def aggregate_numeric_statistic each_player, reports, aggregate_stat, hand_stat
|
12
|
-
@aggregate_statistics[each_player][aggregate_stat] ||= 0
|
13
|
-
@aggregate_statistics[each_player][aggregate_stat] += reports[each_player][hand_stat]
|
14
|
-
end
|
8
|
+
def reports
|
9
|
+
@aggregate_statistics
|
10
|
+
end
|
15
11
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
def aggregate_numeric_statistic each_player, reports, aggregate_stat, hand_stat
|
13
|
+
@aggregate_statistics[each_player][aggregate_stat] ||= 0
|
14
|
+
@aggregate_statistics[each_player][aggregate_stat] += reports[each_player][hand_stat]
|
15
|
+
end
|
20
16
|
|
21
|
-
|
22
|
-
|
23
|
-
if /^is_/ =~ hand_stat.to_s
|
17
|
+
def aggregate_boolean_statistic each_player, reports, aggregate_stat, hand_stat
|
18
|
+
@aggregate_statistics[each_player][aggregate_stat] ||= 0
|
24
19
|
@aggregate_statistics[each_player][aggregate_stat] += 1 if reports[each_player][hand_stat]
|
25
|
-
else
|
26
|
-
@aggregate_statistics[each_player][aggregate_stat] += reports[each_player][hand_stat]
|
27
20
|
end
|
28
|
-
end
|
29
21
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
22
|
+
def aggregate_statistic each_player, reports, aggregate_stat, hand_stat
|
23
|
+
@aggregate_statistics[each_player][aggregate_stat] ||= 0
|
24
|
+
if /^is_/ =~ hand_stat.to_s
|
25
|
+
@aggregate_statistics[each_player][aggregate_stat] += 1 if reports[each_player][hand_stat]
|
26
|
+
else
|
27
|
+
@aggregate_statistics[each_player][aggregate_stat] += reports[each_player][hand_stat]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def record hand_statistics
|
32
|
+
reports = hand_statistics.reports
|
33
|
+
reports.keys.each do |each_player|
|
34
|
+
@aggregate_statistics[each_player] ||= {}
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
36
|
+
@aggregate_statistics[each_player][:t_hands] ||= 0
|
37
|
+
@aggregate_statistics[each_player][:t_hands] += 1
|
38
|
+
@aggregate_statistics[each_player][:t_vpip] ||= 0
|
39
|
+
@aggregate_statistics[each_player][:t_vpip] += 1 unless reports[each_player][:paid].zero?
|
40
|
+
aggregate_numeric_statistic each_player, reports, :t_posted, :posted
|
41
|
+
aggregate_numeric_statistic each_player, reports, :t_paid, :paid
|
42
|
+
aggregate_numeric_statistic each_player, reports, :t_won, :won
|
43
|
+
aggregate_numeric_statistic each_player, reports, :t_preflop_passive, :preflop_passive
|
44
|
+
aggregate_numeric_statistic each_player, reports, :t_preflop_aggressive, :preflop_aggressive
|
45
|
+
aggregate_numeric_statistic each_player, reports, :t_postflop_passive, :postflop_passive
|
46
|
+
aggregate_numeric_statistic each_player, reports, :t_postflop_aggressive, :postflop_aggressive
|
47
|
+
aggregate_boolean_statistic each_player, reports, :t_blind_attack_opportunity, :is_blind_attack_opportunity
|
48
|
+
aggregate_boolean_statistic each_player, reports, :t_blind_attack_opportunity_taken, :is_blind_attack_opportunity_taken
|
49
|
+
aggregate_boolean_statistic each_player, reports, :t_blind_defense_opportunity, :is_blind_defense_opportunity
|
50
|
+
aggregate_boolean_statistic each_player, reports, :t_blind_defense_opportunity_taken, :is_blind_defense_opportunity_taken
|
51
|
+
aggregate_boolean_statistic each_player, reports, :t_pfr_opportunity, :is_pfr_opportunity
|
52
|
+
aggregate_boolean_statistic each_player, reports, :t_pfr_opportunity_taken, :is_pfr_opportunity_taken
|
53
|
+
aggregate_boolean_statistic each_player, reports, :t_cbet_opportunity, :is_cbet_opportunity
|
54
|
+
aggregate_boolean_statistic each_player, reports, :t_cbet_opportunity_taken, :is_cbet_opportunity_taken
|
55
|
+
end
|
54
56
|
end
|
55
57
|
end
|
56
58
|
end
|
@@ -1,55 +1,57 @@
|
|
1
|
-
|
1
|
+
module Pokerstats
|
2
|
+
class AggressionStatistics < HandStatistics::Plugin
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
def self.report_specification
|
5
|
+
[
|
6
|
+
# [key, sql_type, function]
|
7
|
+
[:preflop_passive, 'integer', :preflop_passive],
|
8
|
+
[:postflop_passive, 'integer', :postflop_passive],
|
9
|
+
[:preflop_aggressive, 'integer', :preflop_aggressive],
|
10
|
+
[:postflop_aggressive, 'integer', :postflop_aggressive]
|
11
|
+
]
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
def initialize handstatistics
|
15
|
+
super handstatistics
|
16
|
+
@preflop_passive = {}
|
17
|
+
@preflop_aggressive = {}
|
18
|
+
@postflop_passive = {}
|
19
|
+
@postflop_aggressive = {}
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
def preflop_passive(screen_name)
|
23
|
+
@preflop_passive[screen_name]
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
def postflop_passive(screen_name)
|
27
|
+
@postflop_passive[screen_name]
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
def preflop_aggressive(screen_name)
|
31
|
+
@preflop_aggressive[screen_name]
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
def postflop_aggressive(screen_name)
|
35
|
+
@postflop_aggressive[screen_name]
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
def register_player screen_name, street
|
39
|
+
@preflop_passive[screen_name] = 0
|
40
|
+
@preflop_aggressive[screen_name] = 0
|
41
|
+
@postflop_passive[screen_name] = 0
|
42
|
+
@postflop_aggressive[screen_name] = 0
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
45
|
+
def apply_action action, street
|
46
|
+
aggression = action[:aggression]
|
47
|
+
player = action[:screen_name]
|
48
|
+
if [:prelude, :preflop].member?(street)
|
49
|
+
@preflop_aggressive[player] +=1 if aggression == :aggressive
|
50
|
+
@preflop_passive[player] += 1 if aggression == :passive
|
51
|
+
else
|
52
|
+
@postflop_aggressive[player] +=1 if aggression == :aggressive
|
53
|
+
@postflop_passive[player] +=1 if aggression == :passive
|
54
|
+
end
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|
@@ -1,76 +1,78 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
module Pokerstats
|
2
|
+
class BlindAttackStatistics < HandStatistics::Plugin
|
3
|
+
def initialize handstatistics
|
4
|
+
super(handstatistics)
|
5
|
+
@blind_attack_state = :no_action_taken
|
6
|
+
@blind_attack_opportunity = {}
|
7
|
+
@blind_attack_opportunity_taken ={}
|
8
|
+
@blind_defense_opportunity = {}
|
9
|
+
@blind_defense_opportunity_taken = {}
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
def blind_attack_opportunity?(screen_name)
|
13
|
+
@blind_attack_opportunity[screen_name]
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
def blind_attack_opportunity_taken?(screen_name)
|
17
|
+
@blind_attack_opportunity_taken[screen_name]
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
def blind_defense_opportunity?(screen_name)
|
21
|
+
@blind_defense_opportunity[screen_name]
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
def blind_defense_opportunity_taken?(screen_name)
|
25
|
+
@blind_defense_opportunity_taken[screen_name]
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
def self.report_specification
|
29
|
+
[
|
30
|
+
# [key, sql_type, function]
|
31
|
+
[:is_blind_attack_opportunity, 'integer', :blind_attack_opportunity?],
|
32
|
+
[:is_blind_attack_opportunity_taken, 'integer', :blind_attack_opportunity_taken?],
|
33
|
+
[:is_blind_defense_opportunity, 'integer', :blind_defense_opportunity?],
|
34
|
+
[:is_blind_defense_opportunity_taken, 'integer', :blind_defense_opportunity_taken?]
|
35
|
+
]
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
38
|
+
# def report(screen_name)
|
39
|
+
# {
|
40
|
+
# :is_blind_attack_opportunity => blind_attack_opportunity?(screen_name),
|
41
|
+
# :is_blind_attack_opportunity_taken => blind_attack_opportunity_taken?(screen_name),
|
42
|
+
# :is_blind_defense_opportunity => blind_defense_opportunity?(screen_name),
|
43
|
+
# :is_blind_defense_opportunity_taken => blind_defense_opportunity_taken?(screen_name)
|
44
|
+
# }
|
45
|
+
# end
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
def apply_action action, street
|
48
|
+
player = action[:screen_name]
|
49
|
+
aggression = action[:aggression]
|
49
50
|
|
50
|
-
|
51
|
+
return if aggression == :neutral || street != :preflop
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
53
|
+
@blind_defense_opportunity[player] ||= @hand_statistics.blind?(player) && @blind_attack_state == :attacker_raised_first_in
|
54
|
+
@blind_defense_opportunity_taken[player] ||= @blind_defense_opportunity[player] && aggression != :fold
|
55
|
+
case @blind_attack_state
|
56
|
+
when :no_action_taken
|
57
|
+
@blind_attack_opportunity[player] ||= @hand_statistics.attacker?(player)
|
58
|
+
@blind_attack_opportunity_taken[player] ||= @hand_statistics.attacker?(player) && aggression == :aggressive
|
59
|
+
@blind_attack_state = case aggression
|
60
|
+
when :aggressive
|
61
|
+
@hand_statistics.attacker?(player) ? :attacker_raised_first_in : :responsive_action_taken
|
62
|
+
when :passive
|
63
|
+
:responsive_action_taken
|
64
|
+
else
|
65
|
+
:no_action_taken
|
66
|
+
end
|
67
|
+
when :attacker_raised_first_in
|
68
|
+
@blind_attack_opportunity[player] ||= false
|
69
|
+
@blind_attack_opportunity_taken[player] ||= false
|
70
|
+
@blind_attack_state = :responsive_action_taken unless [:check, :fold].member?(aggression)
|
71
|
+
when :responsive_action_taken
|
72
|
+
@blind_attack_opportunity[player] ||= false
|
73
|
+
@blind_attack_opportunity_taken[player] ||= false
|
74
|
+
else raise "invalid state: #{@blind_attack_state}"
|
65
75
|
end
|
66
|
-
when :attacker_raised_first_in
|
67
|
-
@blind_attack_opportunity[player] ||= false
|
68
|
-
@blind_attack_opportunity_taken[player] ||= false
|
69
|
-
@blind_attack_state = :responsive_action_taken unless [:check, :fold].member?(aggression)
|
70
|
-
when :responsive_action_taken
|
71
|
-
@blind_attack_opportunity[player] ||= false
|
72
|
-
@blind_attack_opportunity_taken[player] ||= false
|
73
|
-
else raise "invalid state: #{@blind_attack_state}"
|
74
76
|
end
|
75
77
|
end
|
76
78
|
end
|