Class: Pokerstats::ContinuationBetStatistics

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handstatistics) ⇒ ContinuationBetStatistics

Returns a new instance of ContinuationBetStatistics.



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

def initialize handstatistics
  super(handstatistics)
  @last_preflop_raiser = nil
  @number_preflop_raises = 0
  @first_aggressor = {}
  @first_aggression_opportunity = {}
  @first_aggression_opportunity_taken = {}
end

Class Method Details

.report_specificationObject



22
23
24
25
26
27
28
# File 'lib/pokerstats/plugins/continuation_bet_statistics.rb', line 22

def self.report_specification
  [
    # [key,                     sql_type,   function]
    [:is_cbet_opportunity,       'integer',  :cbet_opportunity?],
    [:is_cbet_opportunity_taken, 'integer',  :cbet_opportunity_taken?]
  ]
end

Instance Method Details

#apply_action(action, street) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/pokerstats/plugins/continuation_bet_statistics.rb', line 50

def apply_action action, street
  player = action[:screen_name]
  aggression = action[:aggression]
  result = action[:result]
  if street == :preflop and result == :pay_to
    @number_preflop_raises += 1
    @last_preflop_raiser = player
  end
  if aggression != :neutral && @first_aggressor[street].nil? && @first_aggression_opportunity[street][player].nil?
    @first_aggression_opportunity[street][player] = true
    if aggression == :aggressive
      @first_aggressor[street] = player
      @first_aggression_opportunity_taken[street][player] = true
      @hand_statistics.players.each {|player| @first_aggression_opportunity[street][player] ||= false}
    end
  end
end

#cbet_opportunity?(screen_name, street = :flop) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
# File 'lib/pokerstats/plugins/continuation_bet_statistics.rb', line 12

def cbet_opportunity?(screen_name, street = :flop)
  # puts "cbet_opportunity?(#{screen_name}, #{street})"
  # puts @first_aggression_opportunity.inspect
  @number_preflop_raises==1 && @last_preflop_raiser==screen_name && @first_aggression_opportunity[street] && @first_aggression_opportunity[street][screen_name]
end

#cbet_opportunity_taken?(screen_name, street = :flop) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/pokerstats/plugins/continuation_bet_statistics.rb', line 18

def cbet_opportunity_taken?(screen_name, street = :flop)
  cbet_opportunity?(screen_name) && @first_aggression_opportunity_taken[street][screen_name]
end

#street_transition(street) ⇒ Object

def report(screen_name)

{
  :is_cbet_opportunity => cbet_opportunity?(screen_name),
  :is_cbet_opportunity_taken => cbet_opportunity_taken?(screen_name)
}

end



38
39
40
41
42
43
# File 'lib/pokerstats/plugins/continuation_bet_statistics.rb', line 38

def street_transition street
  @first_aggressor[street] = nil
  @first_aggression_opportunity[street] = {}
  @first_aggression_opportunity_taken[street] = {}
  super(street)
end

#street_transition_for_player(street, player) ⇒ Object



45
46
47
48
# File 'lib/pokerstats/plugins/continuation_bet_statistics.rb', line 45

def street_transition_for_player street, player
  @first_aggression_opportunity[street][player] = nil
  @first_aggression_opportunity_taken[street][player] = false
end