pokerstats 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/pokerstats.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pokerstats}
8
- s.version = "2.1.0"
8
+ s.version = "2.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andrew C. Greenberg"]
12
- s.date = %q{2009-11-24}
12
+ s.date = %q{2010-02-23}
13
13
  s.default_executable = %q{checkps}
14
14
  s.description = %q{a library for extracting, computing and reporting statistics of poker hands parsed from hand history files}
15
15
  s.email = %q{wizardwerdna@gmail.com}
@@ -1,5 +1,6 @@
1
+ # coding: utf-8
1
2
  require 'rubygems'
2
- require 'activesupport'
3
+ require 'active_support'
3
4
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
4
5
  require File.expand_path(File.dirname(__FILE__) + '/../lib/pokerstats/hand_history')
5
6
 
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'
2
- require 'activesupport'
2
+ require 'active_support'
3
3
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
4
4
  require File.expand_path(File.dirname(__FILE__) + '/../lib/pokerstats/hand_statistics')
5
5
  require File.expand_path(File.dirname(__FILE__) + '/../lib/pokerstats/hand_classification')
@@ -89,7 +89,19 @@ Spec::Matchers.define :have_saw_street_statistics_specified_by do |hash_of_hashe
89
89
  end
90
90
 
91
91
  def bet_statistics_proc_symbol(street, bet, prefix = "")
92
- "#{prefix}#{street}_#{bet}bet".to_s
92
+ street_first = case street
93
+ when :preflop then :p
94
+ when :flop then :f
95
+ when :turn then :t
96
+ when :river then :r
97
+ end
98
+ prefix_adjust = case prefix
99
+ when "fold_to_" then "f2_"
100
+ when "call_" then "c_"
101
+ when "" then ""
102
+ else raise "wtf? #{prefix}"
103
+ end
104
+ "#{prefix_adjust}#{street_first}_#{bet}bet".to_s
93
105
  end
94
106
 
95
107
  Spec::Matchers.define :have_street_bet_statistics_specified_by do |street_hash, prefix|
@@ -131,14 +143,20 @@ Spec::Matchers.define :have_consistent_street_bet_statistics do
131
143
  match do |hand_statistics|
132
144
  @errors = []
133
145
  for street in [:flop, :turn, :river]
146
+ street_first = case street
147
+ when :preflop then :p
148
+ when :flop then :f
149
+ when :turn then :t
150
+ when :river then :r
151
+ end
134
152
  for player in hand_statistics.players
135
- fs = "fold_to_cbet_#{street}".to_sym
136
- cs = "call_cbet_#{street}".to_sym
153
+ fs = "f2_#{street_first}_cbet".to_sym
154
+ cs = "c_#{street_first}_cbet".to_sym
137
155
  if hand_statistics.send(fs, player).nil? ^ hand_statistics.send(cs, player).nil?
138
156
  @errors << {:fold_symbol => fs, :call_symbol => cs, :player => player}
139
157
  end
140
- fs = "fold_to_dbet_#{street}".to_sym
141
- cs = "call_dbet_#{street}".to_sym
158
+ fs = "f2_#{street_first}_dbet".to_sym
159
+ cs = "c_#{street_first}_dbet".to_sym
142
160
  if hand_statistics.send(fs, player).nil? ^ hand_statistics.send(cs, player).nil?
143
161
  @errors << {:fold_symbol => fs, :call_symbol => cs, :player => player}
144
162
  end
@@ -1587,12 +1605,12 @@ describe HandStatistics do
1587
1605
  register_check @bb
1588
1606
  register_bet @button, 2
1589
1607
  ["sb", "bb", "button"].each do |player|
1590
- @stats.cbet_flop(player).should be_nil
1591
- @stats.call_cbet_flop(player).should be_nil
1592
- @stats.fold_to_cbet_flop(player).should be_nil
1593
- @stats.dbet_flop(player).should be_nil
1594
- @stats.call_dbet_flop(player).should be_nil
1595
- @stats.fold_to_dbet_flop(player).should be_nil
1608
+ @stats.f_cbet(player).should be_nil
1609
+ @stats.c_f_cbet(player).should be_nil
1610
+ @stats.f2_f_cbet(player).should be_nil
1611
+ @stats.f_dbet(player).should be_nil
1612
+ @stats.c_f_dbet(player).should be_nil
1613
+ @stats.f2_f_dbet(player).should be_nil
1596
1614
  end
1597
1615
  @stats.should have_consistent_street_bet_statistics
1598
1616
  end
@@ -1614,22 +1632,22 @@ describe HandStatistics do
1614
1632
  end
1615
1633
  end
1616
1634
  it "should correctly compute cbet stats" do
1617
- [:flop, :turn, :river].each do |street|
1618
- @stats.send("cbet_#{street}", "sb").should be_nil
1619
- @stats.send("cbet_#{street}", "bb").should be_nil
1620
- @stats.send("cbet_#{street}", "button").should be_true
1621
- @stats.send("call_cbet_#{street}", "sb").should be_true
1622
- @stats.send("call_cbet_#{street}", "bb").should be_false
1623
- @stats.send("call_cbet_#{street}", "button").should be_nil
1624
- @stats.send("fold_to_cbet_#{street}", "sb").should be_false
1625
- @stats.send("fold_to_cbet_#{street}", "bb").should be_true
1626
- @stats.send("fold_to_cbet_#{street}", "button").should be_nil
1627
- @stats.send("dbet_#{street}", "sb").should be_false
1628
- @stats.send("dbet_#{street}", "bb").should be_false
1629
- @stats.send("dbet_#{street}", "button").should be_nil
1635
+ [:f, :t, :r].each do |street|
1636
+ @stats.send("#{street}_cbet", "sb").should be_nil
1637
+ @stats.send("#{street}_cbet", "bb").should be_nil
1638
+ @stats.send("#{street}_cbet", "button").should be_true
1639
+ @stats.send("c_#{street}_cbet", "sb").should be_true
1640
+ @stats.send("c_#{street}_cbet", "bb").should be_false
1641
+ @stats.send("c_#{street}_cbet", "button").should be_nil
1642
+ @stats.send("f2_#{street}_cbet", "sb").should be_false
1643
+ @stats.send("f2_#{street}_cbet", "bb").should be_true
1644
+ @stats.send("f2_#{street}_cbet", "button").should be_nil
1645
+ @stats.send("#{street}_dbet", "sb").should be_false
1646
+ @stats.send("#{street}_dbet", "bb").should be_false
1647
+ @stats.send("#{street}_dbet", "button").should be_nil
1630
1648
  [:sb, :bb, :button].each do |player|
1631
- @stats.send("call_dbet_#{street}", "sb").should be_nil
1632
- @stats.send("fold_to_dbet_#{street}", "bb").should be_nil
1649
+ @stats.send("c_#{street}_dbet", "sb").should be_nil
1650
+ @stats.send("f2_#{street}_dbet", "bb").should be_nil
1633
1651
  end
1634
1652
  @stats.should have_consistent_street_bet_statistics
1635
1653
  end
@@ -1653,21 +1671,21 @@ describe HandStatistics do
1653
1671
  end
1654
1672
  end
1655
1673
  it "should correctly compute cbet stats" do
1656
- [:flop, :turn, :river].each do |street|
1674
+ [:f, :t, :r].each do |street|
1657
1675
  [:sb, :bb, :button].each do |player|
1658
- @stats.send("cbet_#{street}", player).should be_nil
1659
- @stats.send("call_cbet_#{street}", player).should be_nil
1660
- @stats.send("fold_to_cbet_#{street}", player).should be_nil
1676
+ @stats.send("#{street}_cbet", player).should be_nil
1677
+ @stats.send("c_#{street}_cbet", player).should be_nil
1678
+ @stats.send("f2_#{street}_cbet", player).should be_nil
1661
1679
  end
1662
- @stats.send("dbet_#{street}", "sb").should be_false
1663
- @stats.send("dbet_#{street}", "bb").should be_true
1664
- @stats.send("dbet_#{street}", "button").should be_nil
1665
- @stats.send("call_dbet_#{street}", "sb").should be_nil
1666
- @stats.send("call_dbet_#{street}", "bb").should be_nil
1667
- @stats.send("call_dbet_#{street}", "button").should be_false
1668
- @stats.send("fold_to_dbet_#{street}", "sb").should be_nil
1669
- @stats.send("fold_to_dbet_#{street}", "bb").should be_nil
1670
- @stats.send("fold_to_dbet_#{street}", "button").should be_false
1680
+ @stats.send("#{street}_dbet", "sb").should be_false
1681
+ @stats.send("#{street}_dbet", "bb").should be_true
1682
+ @stats.send("#{street}_dbet", "button").should be_nil
1683
+ @stats.send("c_#{street}_dbet", "sb").should be_nil
1684
+ @stats.send("c_#{street}_dbet", "bb").should be_nil
1685
+ @stats.send("c_#{street}_dbet", "button").should be_false
1686
+ @stats.send("f2_#{street}_dbet", "sb").should be_nil
1687
+ @stats.send("f2_#{street}_dbet", "bb").should be_nil
1688
+ @stats.send("f2_#{street}_dbet", "button").should be_false
1671
1689
  @stats.should have_consistent_street_bet_statistics
1672
1690
  end
1673
1691
  end
@@ -1691,22 +1709,22 @@ describe HandStatistics do
1691
1709
  end
1692
1710
  end
1693
1711
  it "should correctly compute cbet stats" do
1694
- [:flop, :turn, :river].each do |street|
1695
- @stats.send("cbet_#{street}", "sb").should be_nil
1696
- @stats.send("cbet_#{street}", "bb").should be_true
1697
- @stats.send("cbet_#{street}", "button").should be_nil
1698
- @stats.send("call_cbet_#{street}", "sb").should be_false
1699
- @stats.send("call_cbet_#{street}", "bb").should be_nil
1700
- @stats.send("call_cbet_#{street}", "button").should be_true
1701
- @stats.send("fold_to_cbet_#{street}", "sb").should be_true
1702
- @stats.send("fold_to_cbet_#{street}", "bb").should be_nil
1703
- @stats.send("fold_to_cbet_#{street}", "button").should be_false
1704
- @stats.send("dbet_#{street}", "sb").should be_false
1705
- @stats.send("dbet_#{street}", "bb").should be_nil
1706
- @stats.send("dbet_#{street}", "button").should be_nil
1712
+ [:f, :t, :r].each do |street|
1713
+ @stats.send("#{street}_cbet", "sb").should be_nil
1714
+ @stats.send("#{street}_cbet", "bb").should be_true
1715
+ @stats.send("#{street}_cbet", "button").should be_nil
1716
+ @stats.send("c_#{street}_cbet", "sb").should be_false
1717
+ @stats.send("c_#{street}_cbet", "bb").should be_nil
1718
+ @stats.send("c_#{street}_cbet", "button").should be_true
1719
+ @stats.send("f2_#{street}_cbet", "sb").should be_true
1720
+ @stats.send("f2_#{street}_cbet", "bb").should be_nil
1721
+ @stats.send("f2_#{street}_cbet", "button").should be_false
1722
+ @stats.send("#{street}_dbet", "sb").should be_false
1723
+ @stats.send("#{street}_dbet", "bb").should be_nil
1724
+ @stats.send("#{street}_dbet", "button").should be_nil
1707
1725
  [:sb, :bb, :button].each do |player|
1708
- @stats.send("call_dbet_#{street}", "sb").should be_nil
1709
- @stats.send("fold_to_dbet_#{street}", "bb").should be_nil
1726
+ @stats.send("c_#{street}_dbet", "sb").should be_nil
1727
+ @stats.send("f2_#{street}_dbet", "bb").should be_nil
1710
1728
  end
1711
1729
  @stats.should have_consistent_street_bet_statistics
1712
1730
  end
@@ -1725,18 +1743,18 @@ describe HandStatistics do
1725
1743
  end
1726
1744
 
1727
1745
  it "correctly compute cbet stats" do
1728
- @stats.cbet_flop("sb").should be_nil
1729
- @stats.cbet_flop("bb").should be_nil
1730
- @stats.cbet_flop("button").should be_false
1746
+ @stats.f_cbet("sb").should be_nil
1747
+ @stats.f_cbet("bb").should be_nil
1748
+ @stats.f_cbet("button").should be_false
1731
1749
  ["sb", "bb", "button"].each do |player|
1732
- @stats.send("call_cbet_flop", player).should be_nil
1733
- @stats.send("fold_to_cbet_flop", player).should be_nil
1750
+ @stats.send("c_f_cbet", player).should be_nil
1751
+ @stats.send("f2_f_cbet", player).should be_nil
1734
1752
  end
1735
- @stats.dbet_flop("sb").should be_false
1736
- @stats.dbet_flop("bb").should be_false
1737
- @stats.dbet_flop("button").should be_nil
1753
+ @stats.f_dbet("sb").should be_false
1754
+ @stats.f_dbet("bb").should be_false
1755
+ @stats.f_dbet("button").should be_nil
1738
1756
  [:sb, :bb, :button].each do |player|
1739
- @stats.dbet_flop(player).should be_nil
1757
+ @stats.f_dbet(player).should be_nil
1740
1758
  end
1741
1759
  @stats.should have_consistent_street_bet_statistics
1742
1760
  end
@@ -1757,18 +1775,18 @@ describe HandStatistics do
1757
1775
  end
1758
1776
 
1759
1777
  it "correctly compute cbet stats" do
1760
- @stats.cbet_turn("sb").should be_nil
1761
- @stats.cbet_turn("bb").should be_nil
1762
- @stats.cbet_turn("button").should be_false
1778
+ @stats.t_cbet("sb").should be_nil
1779
+ @stats.t_cbet("bb").should be_nil
1780
+ @stats.t_cbet("button").should be_false
1763
1781
  ["sb", "bb", "button"].each do |player|
1764
- @stats.send("call_cbet_turn", player).should be_nil
1765
- @stats.send("fold_to_cbet_turn", player).should be_nil
1782
+ @stats.send("c_t_cbet", player).should be_nil
1783
+ @stats.send("f2_t_cbet", player).should be_nil
1766
1784
  end
1767
- @stats.dbet_turn("sb").should be_false
1768
- @stats.dbet_turn("bb").should be_false
1769
- @stats.dbet_turn("button").should be_nil
1785
+ @stats.t_dbet("sb").should be_false
1786
+ @stats.t_dbet("bb").should be_false
1787
+ @stats.t_dbet("button").should be_nil
1770
1788
  [:sb, :bb, :button].each do |player|
1771
- @stats.dbet_turn(player).should be_nil
1789
+ @stats.t_dbet(player).should be_nil
1772
1790
  end
1773
1791
  @stats.should have_consistent_street_bet_statistics
1774
1792
  end
@@ -1789,18 +1807,18 @@ describe HandStatistics do
1789
1807
  end
1790
1808
 
1791
1809
  it "correctly compute cbet stats" do
1792
- @stats.cbet_river("sb").should be_nil
1793
- @stats.cbet_river("bb").should be_nil
1794
- @stats.cbet_river("button").should be_false
1810
+ @stats.r_cbet("sb").should be_nil
1811
+ @stats.r_cbet("bb").should be_nil
1812
+ @stats.r_cbet("button").should be_false
1795
1813
  ["sb", "bb", "button"].each do |player|
1796
- @stats.send("call_cbet_river", player).should be_nil
1797
- @stats.send("fold_to_cbet_river", player).should be_nil
1814
+ @stats.send("c_r_cbet", player).should be_nil
1815
+ @stats.send("f2_r_cbet", player).should be_nil
1798
1816
  end
1799
- @stats.dbet_river("sb").should be_false
1800
- @stats.dbet_river("bb").should be_false
1801
- @stats.dbet_river("button").should be_nil
1817
+ @stats.r_dbet("sb").should be_false
1818
+ @stats.r_dbet("bb").should be_false
1819
+ @stats.r_dbet("button").should be_nil
1802
1820
  [:sb, :bb, :button].each do |player|
1803
- @stats.dbet_river(player).should be_nil
1821
+ @stats.r_dbet(player).should be_nil
1804
1822
  end
1805
1823
  @stats.should have_consistent_street_bet_statistics
1806
1824
  end
@@ -1892,26 +1910,25 @@ describe HandStatistics do
1892
1910
 
1893
1911
  it "should report street bet statistics for each player" do
1894
1912
  report_items = [
1895
- :preflop_2bet, :preflop_3bet, :preflop_4bet,
1896
- :flop_1bet, :flop_2bet, :flop_3bet, :flop_4bet,
1897
- :turn_1bet, :turn_2bet, :turn_3bet, :turn_4bet,
1898
- :river_1bet, :river_2bet, :river_3bet, :river_4bet,
1899
- :call_flop_1bet, :call_flop_2bet, :call_flop_3bet, :call_flop_4bet,
1900
- :call_turn_1bet, :call_turn_2bet, :call_turn_3bet, :call_turn_4bet,
1901
- :call_river_1bet, :call_river_2bet, :call_river_3bet, :call_river_4bet,
1902
- :fold_to_preflop_1bet, :fold_to_preflop_2bet, :fold_to_preflop_3bet, :fold_to_preflop_4bet,
1903
- :fold_to_flop_1bet, :fold_to_flop_2bet, :fold_to_flop_3bet, :fold_to_flop_4bet,
1904
- :fold_to_turn_1bet, :fold_to_turn_2bet, :fold_to_turn_3bet, :fold_to_turn_4bet,
1905
- :fold_to_river_1bet, :fold_to_river_2bet, :fold_to_river_3bet, :fold_to_river_4bet,
1913
+ :p_2bet, :p_2bet_o,:p_3bet, :p_3bet_o,:p_4bet, :p_4bet_o, :p_5bet_o,
1914
+ :f_1bet, :f_1bet_o,:f_2bet, :f_2bet_o,:f_3bet, :f_3bet_o,:f_4bet, :f_4bet_o, :f_5bet_o,
1915
+ :t_1bet, :t_1bet_o,:t_2bet, :t_2bet_o,:t_3bet, :t_3bet_o,:t_4bet, :t_4bet_o, :t_5bet_o,
1916
+ :r_1bet, :r_1bet_o,:r_2bet, :r_2bet_o,:r_3bet, :r_3bet_o,:r_4bet, :r_4bet_o, :r_5bet_o,
1917
+ :c_f_1bet, :c_f_2bet, :c_f_3bet, :c_f_4bet,
1918
+ :c_t_1bet, :c_t_2bet, :c_t_3bet, :c_t_4bet,
1919
+ :c_r_1bet, :c_r_2bet, :c_r_3bet, :c_r_4bet,
1920
+ :f2_p_1bet, :f2_p_2bet, :f2_p_3bet, :f2_p_4bet,
1921
+ :f2_f_1bet, :f2_f_2bet, :f2_f_3bet, :f2_f_4bet,
1922
+ :f2_t_1bet, :f2_t_2bet, :f2_t_3bet, :f2_t_4bet,
1923
+ :f2_r_1bet, :f2_r_2bet, :f2_r_3bet, :f2_r_4bet,
1906
1924
  :last_aggr_preflop, :last_aggr_flop, :last_aggr_turn, :last_aggr_river,
1907
- :cbet_flop, :cbet_turn, :cbet_river,
1908
- :call_cbet_flop, :call_cbet_turn, :call_cbet_river,
1909
- :fold_to_cbet_flop, :fold_to_cbet_turn, :fold_to_cbet_river,
1910
- :dbet_flop, :dbet_turn, :dbet_river,
1911
- :call_dbet_flop, :call_dbet_turn, :call_dbet_river,
1912
- :fold_to_dbet_flop, :fold_to_dbet_turn, :fold_to_dbet_river
1925
+ :f_cbet, :f_cbet_o,:t_cbet, :t_cbet_o,:r_cbet,
1926
+ :c_f_cbet, :c_f_cbet_o,:c_t_cbet, :c_t_cbet_o,:c_r_cbet,
1927
+ :f2_f_cbet, :f2_f_cbet_o,:f2_t_cbet, :f2_t_cbet_o,:f2_r_cbet,
1928
+ :f_dbet, :f_dbet_o,:t_dbet, :t_dbet_o,:r_dbet,
1929
+ :c_f_dbet, :c_f_dbet_o,:c_t_dbet, :c_t_dbet_o,:c_r_dbet,
1930
+ :f2_f_dbet, :f2_f_dbet_o,:f2_t_dbet, :f2_t_dbet_o,:f2_r_dbet,:f2_r_dbet_o
1913
1931
  ]
1914
- report_items.each{|report_item| @street_bet_plugin.should_receive(report_item).exactly(@stats.players.size)}
1915
1932
  @reports = @stats.reports
1916
1933
  report_items.each{|report_item|@stats.players.each{|each| @reports[each].should include(report_item)}}
1917
1934
  end
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'
2
- require 'activesupport'
2
+ require 'active_support'
3
3
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
4
4
  require File.expand_path(File.dirname(__FILE__) + '/../lib/pokerstats/hand_statistics')
5
5
  require File.expand_path(File.dirname(__FILE__) + '/../lib/pokerstats/player_statistics')
@@ -7,54 +7,44 @@ include Pokerstats
7
7
 
8
8
  TEST = [
9
9
  {"andy" => {
10
- :is_blind_attack_opportunity => false,
11
- :is_blind_attack_opportunity_taken => nil,
12
- :is_blind_defense_opportunity => false,
13
- :is_blind_defense_opportunity_taken => nil,
14
- :is_cbet_opportunity => true,
15
- :is_cbet_opportunity_taken => true,
16
- :posted => 1,
17
- :paid => 2,
18
- :won => 3,
19
- :cards => nil,
20
- :preflop_passive => 1,
21
- :preflop_aggressive => 2,
22
- :postflop_passive => 3,
23
- :postflop_aggressive => 4,
24
- :is_pfr_opportunity => true,
25
- :is_pfr_opportunity_taken => true,
26
- :cbet_flop => true,
27
- :preflop_3bet => true,
28
- :call_cbet_flop => true,
29
- :fold_to_cbet_flop => true,
30
- :preflop_3bet => true,
31
- :call_preflop_3bet => true,
32
- :fold_to_preflop_3bet => true
10
+ :is_blind_attack_opportunity => false,
11
+ :is_blind_attack_opportunity_taken => nil,
12
+ :is_blind_defense_opportunity => false,
13
+ :is_blind_defense_opportunity_taken => nil,
14
+ :posted => 1,
15
+ :paid => 2,
16
+ :won => 3,
17
+ :cards => nil,
18
+ :preflop_passive => 1,
19
+ :preflop_aggressive => 2,
20
+ :postflop_passive => 3,
21
+ :postflop_aggressive => 4,
22
+ :is_pfr_opportunity => true,
23
+ :is_pfr_opportunity_taken => true,
24
+ :f_cbet => true,
25
+ :f_cbet_o => true,
26
+ :p_3bet => true,
27
+ :p_3bet_o => true
33
28
  },
34
29
  "judi" => {
35
- :is_blind_attack_opportunity => true,
36
- :is_blind_attack_opportunity_taken => false,
37
- :is_blind_defense_opportunity => true,
38
- :is_blind_defense_opportunity_taken => true,
39
- :is_cbet_opportunity => true,
40
- :is_cbet_opportunity_taken => false,
41
- :posted => 10,
42
- :paid => 20,
43
- :won => 30,
44
- :cards => nil,
45
- :preflop_passive => 10,
46
- :preflop_aggressive => 20,
47
- :postflop_passive => 30,
48
- :postflop_aggressive => 40,
49
- :is_pfr_opportunity => true,
50
- :is_pfr_opportunity_taken => false,
51
- :cbet_flop => false,
52
- :preflop_3bet => false,
53
- :call_cbet_flop => true,
54
- :fold_to_cbet_flop => true,
55
- :preflop_3bet => true,
56
- :call_preflop_3bet => true,
57
- :fold_to_preflop_3bet => true
30
+ :is_blind_attack_opportunity => true,
31
+ :is_blind_attack_opportunity_taken => false,
32
+ :is_blind_defense_opportunity => true,
33
+ :is_blind_defense_opportunity_taken => true,
34
+ :posted => 10,
35
+ :paid => 20,
36
+ :won => 30,
37
+ :cards => nil,
38
+ :preflop_passive => 10,
39
+ :preflop_aggressive => 20,
40
+ :postflop_passive => 30,
41
+ :postflop_aggressive => 40,
42
+ :is_pfr_opportunity => true,
43
+ :is_pfr_opportunity_taken => false,
44
+ :f_cbet => false,
45
+ :f_cbet_o => true,
46
+ :p_3bet => false,
47
+ :p_3bet_o => true
58
48
  }
59
49
  },
60
50
  {"andy" => {
@@ -62,8 +52,6 @@ TEST = [
62
52
  :is_blind_attack_opportunity_taken => nil,
63
53
  :is_blind_defense_opportunity => false,
64
54
  :is_blind_defense_opportunity_taken => nil,
65
- :is_cbet_opportunity => true,
66
- :is_cbet_opportunity_taken => false,
67
55
  :posted => 2,
68
56
  :paid => 4,
69
57
  :won => 6,
@@ -74,89 +62,71 @@ TEST = [
74
62
  :postflop_aggressive => 8,
75
63
  :is_pfr_opportunity => true,
76
64
  :is_pfr_opportunity_taken => true,
77
- :cbet_flop => false,
78
- :preflop_3bet => true,
79
- :call_cbet_flop => true,
80
- :fold_to_cbet_flop => true,
81
- :preflop_3bet => true,
82
- :call_preflop_3bet => true,
83
- :fold_to_preflop_3bet => true
65
+ :f_cbet => false,
66
+ :f_cbet_o => true,
67
+ :p_3bet => true,
68
+ :p_3bet_o => true
84
69
  },
85
70
  "judi" => {
86
- :is_blind_attack_opportunity => true,
87
- :is_blind_attack_opportunity_taken => false,
88
- :is_blind_defense_opportunity => true,
89
- :is_blind_defense_opportunity_taken => true,
90
- :is_cbet_opportunity => false,
91
- :is_cbet_opportunity_taken => nil,
92
- :posted => 20,
93
- :paid => 30,
94
- :won => 40,
95
- :cards => nil,
96
- :preflop_passive => 20,
97
- :preflop_aggressive => 40,
98
- :postflop_passive => 60,
99
- :postflop_aggressive => 80,
100
- :is_pfr_opportunity => true,
101
- :is_pfr_opportunity_taken => false,
102
- :cbet_flop => nil,
103
- :preflop_3bet => false,
104
- :call_cbet_flop => true,
105
- :fold_to_cbet_flop => true,
106
- :preflop_3bet => true,
107
- :call_preflop_3bet => true,
108
- :fold_to_preflop_3bet => true
71
+ :is_blind_attack_opportunity => true,
72
+ :is_blind_attack_opportunity_taken => false,
73
+ :is_blind_defense_opportunity => true,
74
+ :is_blind_defense_opportunity_taken => true,
75
+ :posted => 20,
76
+ :paid => 30,
77
+ :won => 40,
78
+ :cards => nil,
79
+ :preflop_passive => 20,
80
+ :preflop_aggressive => 40,
81
+ :postflop_passive => 60,
82
+ :postflop_aggressive => 80,
83
+ :is_pfr_opportunity => true,
84
+ :is_pfr_opportunity_taken => false,
85
+ :f_cbet => false,
86
+ :f_cbet_o => false,
87
+ :p_3bet => false,
88
+ :p_3bet_o => true
109
89
  }
110
90
  },
111
91
  {"andy" => {
112
- :is_blind_attack_opportunity => false,
113
- :is_blind_attack_opportunity_taken => nil,
114
- :is_blind_defense_opportunity => true,
115
- :is_blind_defense_opportunity_taken => false,
116
- :is_cbet_opportunity => false,
117
- :is_cbet_opportunity_taken => nil,
118
- :posted => 3,
119
- :paid => 6,
120
- :won => 9,
121
- :cards => nil,
122
- :preflop_passive => 3,
123
- :preflop_aggressive => 6,
124
- :postflop_passive => 9,
125
- :postflop_aggressive => 12,
126
- :is_pfr_opportunity => true,
127
- :is_pfr_opportunity_taken => true,
128
- :cbet_flop => nil,
129
- :preflop_3bet => true,
130
- :call_cbet_flop => true,
131
- :fold_to_cbet_flop => true,
132
- :preflop_3bet => true,
133
- :call_preflop_3bet => true,
134
- :fold_to_preflop_3bet => true
92
+ :is_blind_attack_opportunity => false,
93
+ :is_blind_attack_opportunity_taken => nil,
94
+ :is_blind_defense_opportunity => true,
95
+ :is_blind_defense_opportunity_taken => false,
96
+ :posted => 3,
97
+ :paid => 6,
98
+ :won => 9,
99
+ :cards => nil,
100
+ :preflop_passive => 3,
101
+ :preflop_aggressive => 6,
102
+ :postflop_passive => 9,
103
+ :postflop_aggressive => 12,
104
+ :is_pfr_opportunity => true,
105
+ :is_pfr_opportunity_taken => true,
106
+ :f_cbet => false,
107
+ :f_cbet_o => false,
108
+ :p_3bet => true,
109
+ :p_3bet_o => true
135
110
  },
136
111
  "judi" => {
137
- :is_blind_attack_opportunity => true,
138
- :is_blind_attack_opportunity_taken => true,
139
- :is_blind_defense_opportunity => true,
140
- :is_blind_defense_opportunity_taken => true,
141
- :is_cbet_opportunity => false,
142
- :is_cbet_opportunity_taken => nil,
143
- :posted => 30,
144
- :paid => 0,
145
- :won => 0,
146
- :cards => nil,
147
- :preflop_passive => 30,
148
- :preflop_aggressive => 60,
149
- :postflop_passive => 90,
150
- :postflop_aggressive => 120,
151
- :is_pfr_opportunity => true,
152
- :is_pfr_opportunity_taken => false,
153
- :cbet_flop => nil,
154
- :preflop_3bet => false,
155
- :call_cbet_flop => true,
156
- :fold_to_cbet_flop => true,
157
- :preflop_3bet => true,
158
- :call_preflop_3bet => true,
159
- :fold_to_preflop_3bet => true
112
+ :is_blind_attack_opportunity => true,
113
+ :is_blind_attack_opportunity_taken => true,
114
+ :is_blind_defense_opportunity => true,
115
+ :is_blind_defense_opportunity_taken => true,
116
+ :posted => 30,
117
+ :paid => 0,
118
+ :won => 0,
119
+ :cards => nil,
120
+ :preflop_passive => 30,
121
+ :preflop_aggressive => 60,
122
+ :postflop_passive => 90,
123
+ :postflop_aggressive => 120,
124
+ :is_pfr_opportunity => true,
125
+ :is_pfr_opportunity_taken => false,
126
+ :f_cbet => false,
127
+ :f_cbet_o => false,
128
+ :p_3bet => false,
129
+ :p_3bet_o => true
160
130
  }
161
131
  }
162
132
  ]
@@ -172,18 +142,16 @@ PS_RESULT = {
172
142
  :t_blind_attack_opportunity_taken => 0,
173
143
  :t_blind_defense_opportunity => 1,
174
144
  :t_blind_defense_opportunity_taken => 0,
175
- :t_cbet_opportunity => 2,
176
- :t_cbet_opportunity_taken => 1,
177
145
  :t_preflop_passive => 6,
178
146
  :t_preflop_aggressive => 12,
179
147
  :t_postflop_passive => 18,
180
148
  :t_postflop_aggressive => 24,
181
149
  :t_pfr_opportunity => 3,
182
150
  :t_pfr_opportunity_taken => 3,
183
- :t_preflop_3bet_opportunity => 3,
184
- :t_preflop_3bet_opportunity_taken => 3,
185
- :t_flop_cbet_opportunity => 2,
186
- :t_flop_cbet_opportunity_taken => 1
151
+ :t_p_3bet => 3,
152
+ :t_p_3bet_o => 3,
153
+ :t_f_cbet => 1,
154
+ :t_f_cbet_o => 2
187
155
  },
188
156
  "judi" => {
189
157
  :t_hands => 3,
@@ -195,18 +163,16 @@ PS_RESULT = {
195
163
  :t_blind_attack_opportunity_taken => 1,
196
164
  :t_blind_defense_opportunity => 3,
197
165
  :t_blind_defense_opportunity_taken => 3,
198
- :t_cbet_opportunity => 1,
199
- :t_cbet_opportunity_taken => 0,
200
166
  :t_preflop_passive => 60,
201
167
  :t_preflop_aggressive => 120,
202
168
  :t_postflop_passive => 180,
203
169
  :t_postflop_aggressive => 240,
204
170
  :t_pfr_opportunity => 3,
205
171
  :t_pfr_opportunity_taken => 0,
206
- :t_preflop_3bet_opportunity => 3,
207
- :t_preflop_3bet_opportunity_taken => 0,
208
- :t_cbet_opportunity => 1,
209
- :t_cbet_opportunity_taken => 0
172
+ :t_p_3bet => 0,
173
+ :t_p_3bet_o => 3,
174
+ :t_f_cbet => 0,
175
+ :t_f_cbet_o => 1
210
176
  }
211
177
  }
212
178
 
@@ -219,12 +185,18 @@ class AggregateTo
219
185
 
220
186
  def matches?(hash)
221
187
  @actual = hash[@player][@stat]
188
+ @hash = hash
222
189
  # Satisfy expectation here. Return false or raise an error if it's not met.
223
- return @actual == @expected
190
+ # puts "trying to match #{@stat}[#{@player}] expected #{@expected.inspect}, got #{@actual.inspect}"
191
+ return hash[@player].keys.include?(@stat) && @actual == @expected
224
192
  end
225
193
 
226
194
  def failure_message
227
- "expected report[#{@player.inspect}][#{@stat.inspect}] to aggregate to #{@expected.inspect}, got #{@actual.inspect}"
195
+ if @hash[@player].keys.include?(@stat)
196
+ "expected report[#{@player.inspect}][#{@stat.inspect}] to aggregate to #{@expected.inspect}, got #{@actual.inspect}"
197
+ else
198
+ "expected report to include #{@stat}"
199
+ end
228
200
  end
229
201
 
230
202
  def negative_failure_message
@@ -271,13 +243,10 @@ describe PlayerStatistics, "when aggregating statistics" do
271
243
  it 'should correctly aggregate cash statistics' do
272
244
  should_correctly_aggregate @reports, [:t_hands, :t_vpip, :t_posted, :t_paid, :t_won]
273
245
  end
274
- it 'should correctly aggregate continuation bet statistics' do
275
- should_correctly_aggregate @reports, [:t_cbet_opportunity, :t_cbet_opportunity_taken]
276
- end
277
246
  it 'should correctly aggregate preflop raise statistics' do
278
247
  should_correctly_aggregate @reports, [:t_pfr_opportunity, :t_pfr_opportunity_taken]
279
248
  end
280
249
  it 'should correctly aggregate ternary statistics' do
281
- should_correctly_aggregate @reports, [:t_preflop_3bet, :t_cbet_flop]
250
+ should_correctly_aggregate @reports, [:t_p_3bet, :t_p_3bet_o, :t_f_cbet, :t_f_cbet_o]
282
251
  end
283
252
  end