Class: Pokerstats::BlindAttackStatistics

Inherits:
HandStatistics::Plugin
  • Object
show all
Defined in:
lib/pokerstats/plugins/blind_attack_statistics.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handstatistics) ⇒ BlindAttackStatistics

Returns a new instance of BlindAttackStatistics.



3
4
5
6
7
8
9
10
# File 'lib/pokerstats/plugins/blind_attack_statistics.rb', line 3

def initialize handstatistics
  super(handstatistics)
  @blind_attack_state = :no_action_taken
  @blind_attack_opportunity = {}
  @blind_attack_opportunity_taken ={}
  @blind_defense_opportunity = {}
  @blind_defense_opportunity_taken = {}
end

Class Method Details

.report_specificationObject



28
29
30
31
32
33
34
35
36
# File 'lib/pokerstats/plugins/blind_attack_statistics.rb', line 28

def self.report_specification
  [
    # [key,                               sql_type,   function]
    [:is_blind_attack_opportunity,        'integer',  :blind_attack_opportunity?],
    [:is_blind_attack_opportunity_taken,  'integer',  :blind_attack_opportunity_taken?],
    [:is_blind_defense_opportunity,       'integer',  :blind_defense_opportunity?],
    [:is_blind_defense_opportunity_taken, 'integer',  :blind_defense_opportunity_taken?]
  ]
end

Instance Method Details

#apply_action(action, street) ⇒ Object

def report(screen_name)

{
  :is_blind_attack_opportunity => blind_attack_opportunity?(screen_name),
  :is_blind_attack_opportunity_taken => blind_attack_opportunity_taken?(screen_name),
  :is_blind_defense_opportunity => blind_defense_opportunity?(screen_name),
  :is_blind_defense_opportunity_taken => blind_defense_opportunity_taken?(screen_name)
}

end



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
# File 'lib/pokerstats/plugins/blind_attack_statistics.rb', line 47

def apply_action action, street
  player = action[:screen_name]
  aggression = action[:aggression]

  return if aggression == :neutral || street != :preflop

  @blind_defense_opportunity[player] ||= @hand_statistics.blind?(player) && @blind_attack_state == :attacker_raised_first_in
  @blind_defense_opportunity_taken[player] ||= @blind_defense_opportunity[player] && aggression != :fold
  case @blind_attack_state
  when :no_action_taken
    @blind_attack_opportunity[player] ||= @hand_statistics.attacker?(player)
    @blind_attack_opportunity_taken[player] ||= @hand_statistics.attacker?(player) && aggression == :aggressive
    @blind_attack_state = case aggression
    when :aggressive
      @hand_statistics.attacker?(player) ? :attacker_raised_first_in : :responsive_action_taken
    when :passive
      :responsive_action_taken
    else
      :no_action_taken
    end
  when :attacker_raised_first_in
    @blind_attack_opportunity[player] ||= false
    @blind_attack_opportunity_taken[player] ||= false
    @blind_attack_state = :responsive_action_taken unless [:check, :fold].member?(aggression)
  when :responsive_action_taken
    @blind_attack_opportunity[player] ||= false
    @blind_attack_opportunity_taken[player] ||= false      
  else raise "invalid state: #{@blind_attack_state}"
  end
end

#blind_attack_opportunity?(screen_name) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/pokerstats/plugins/blind_attack_statistics.rb', line 12

def blind_attack_opportunity?(screen_name)
  @blind_attack_opportunity[screen_name]
end

#blind_attack_opportunity_taken?(screen_name) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/pokerstats/plugins/blind_attack_statistics.rb', line 16

def blind_attack_opportunity_taken?(screen_name)
  @blind_attack_opportunity_taken[screen_name]
end

#blind_defense_opportunity?(screen_name) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/pokerstats/plugins/blind_attack_statistics.rb', line 20

def blind_defense_opportunity?(screen_name)
  @blind_defense_opportunity[screen_name]
end

#blind_defense_opportunity_taken?(screen_name) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/pokerstats/plugins/blind_attack_statistics.rb', line 24

def blind_defense_opportunity_taken?(screen_name)
  @blind_defense_opportunity_taken[screen_name]
end