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