pokerstats 2.0.14 → 2.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/pokerstats/hand_classification.rb +42 -38
- data/lib/pokerstats/hand_history.rb +1 -0
- data/lib/pokerstats/hand_statistics.rb +1 -1
- data/lib/pokerstats/plugins/cash_statistics.rb +2 -1
- data/lib/pokerstats/pokerstars_hand_history_parser.rb +16 -2
- data/pokerstats.gemspec +4 -2
- data/spec/hand_classification_spec.rb +80 -81
- data/spec/hand_history_spec.rb +86 -0
- data/spec/hand_statistics_spec.rb +0 -1
- data/spec/pokerstars_hand_history_parser_spec.rb +49 -1
- data/spec/spec_helper.rb +19 -0
- metadata +4 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.16
|
@@ -1,22 +1,22 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/hand_constants")
|
2
2
|
module Pokerstats
|
3
|
-
|
3
|
+
def class_index_from_hand_string(hand_string)
|
4
4
|
return class_index_from_hand_string!(hand_string)
|
5
|
-
|
5
|
+
rescue ArgumentError
|
6
6
|
nil
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
end
|
8
|
+
|
9
|
+
def class_index_from_hand_string!(hand_string)
|
10
10
|
class_index_from_class_string!(class_string_from_hand_string!(hand_string))
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
end
|
12
|
+
|
13
|
+
def class_string_from_hand_string(hand_string)
|
14
14
|
class_string_from_hand_string!(hand_string)
|
15
|
-
|
15
|
+
rescue
|
16
16
|
nil
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
end
|
18
|
+
|
19
|
+
def class_string_from_hand_string!(hand_string)
|
20
20
|
raise ArgumentError, "hand_string '#{hand_string}' must be a String" unless hand_string.kind_of?(String)
|
21
21
|
hand_string = hand_string.gsub(/ /,'')
|
22
22
|
hand_string = hand_string.upcase
|
@@ -39,15 +39,15 @@ module Pokerstats
|
|
39
39
|
end
|
40
40
|
result
|
41
41
|
end
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
end
|
43
|
+
|
44
|
+
def class_index_from_class_string(class_string)
|
45
45
|
class_index_from_class_string!(class_string)
|
46
|
-
|
46
|
+
rescue
|
47
47
|
nil
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
end
|
49
|
+
|
50
|
+
def class_index_from_class_string!(class_string)
|
51
51
|
raise ArgumentError, "class_string #{class_string.inspect} must be a String" unless class_string.kind_of?(String)
|
52
52
|
class_string.upcase!
|
53
53
|
first = Pokerstats::HandConstants::CARDS.index(class_string[0..0])
|
@@ -61,16 +61,16 @@ module Pokerstats
|
|
61
61
|
13*second+first
|
62
62
|
else raise ArgumentError, "class_string is malformed"
|
63
63
|
end
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
end
|
65
|
+
|
66
|
+
def class_string_from_class_index(class_index)
|
67
67
|
class_string_from_class_index!(class_index)
|
68
|
-
|
68
|
+
rescue ArgumentError
|
69
69
|
nil
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
raise ArgumentError, "class_index must be an integer" unless class_index.kind_of? Integer
|
70
|
+
end
|
71
|
+
|
72
|
+
def class_string_from_class_index!(class_index)
|
73
|
+
raise ArgumentError, "class_index (#{class_index.inspect}) must be an integer between 0 and 168" unless class_index.kind_of? Integer and class_index.between?(0,168)
|
74
74
|
row, col = row_from_class_index(class_index), col_from_class_index(class_index)
|
75
75
|
case row <=> col
|
76
76
|
when 1
|
@@ -80,17 +80,21 @@ module Pokerstats
|
|
80
80
|
when -1
|
81
81
|
Pokerstats::HandConstants::CARDS[row..row] + Pokerstats::HandConstants::CARDS[col..col] + "s"
|
82
82
|
end
|
83
|
-
|
84
|
-
|
85
|
-
|
83
|
+
end
|
84
|
+
|
85
|
+
def row_from_class_index(classIndex)
|
86
86
|
classIndex / 13
|
87
|
-
|
88
|
-
|
89
|
-
|
87
|
+
end
|
88
|
+
|
89
|
+
def col_from_class_index(classIndex)
|
90
90
|
classIndex % 13
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
91
|
+
end
|
92
|
+
|
93
|
+
def class_index_from_row_and_col(row, col)
|
94
|
+
row*13 + col
|
95
|
+
end
|
96
|
+
|
97
|
+
class HandClass
|
98
|
+
extend Pokerstats
|
99
|
+
end
|
96
100
|
end
|
@@ -241,6 +241,6 @@ module Pokerstats
|
|
241
241
|
Dir[File.dirname(__FILE__) + "/plugins/*_statistics.rb"].each {|filename| require File.expand_path(filename)}
|
242
242
|
HandStatistics.delegate_plugin_public_methods_except HandStatisticsAPI.public_methods
|
243
243
|
end
|
244
|
-
# Load Plugins and Delegate non-api public methods to plugins
|
244
|
+
# Load Plugins and Delegate non-api public methods to plugins#
|
245
245
|
# puts Pokerstats::HandStatistics.hand_statistics_migration_data
|
246
246
|
# puts Pokerstats::HandStatistics.player_statistics_migration_data
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../hand_classification")
|
1
2
|
module Pokerstats
|
2
3
|
class CashStatistics < HandStatistics::Plugin
|
3
4
|
def initialize handstatistics
|
@@ -107,7 +108,7 @@ module Pokerstats
|
|
107
108
|
end
|
108
109
|
|
109
110
|
def card_category_index(player)
|
110
|
-
Pokerstats::class_index_from_hand_string(cards(player))
|
111
|
+
Pokerstats::HandClass.class_index_from_hand_string(cards(player))
|
111
112
|
end
|
112
113
|
|
113
114
|
def self.report_specification
|
@@ -66,6 +66,7 @@ module Pokerstats
|
|
66
66
|
|
67
67
|
def self.game(lines)
|
68
68
|
lines.lstrip!
|
69
|
+
return nil if lines.empty?
|
69
70
|
case lines[/[^\n]+/].chomp
|
70
71
|
when /PokerStars Game #([0-9]+): Tournament #([0-9]+), (\$[0-9+$]+) ([^\-]*) - Level ([IVXL]+) \((#{CASH})\/(#{CASH})\) - (.*)$/
|
71
72
|
"PS#{$1}"
|
@@ -113,7 +114,19 @@ module Pokerstats
|
|
113
114
|
:sb=> $6.to_d, :bb=> $7.to_d, :ante => "0.0".to_d,
|
114
115
|
:played_at=> PokerstarsTimeStringConverter.new($8).as_utc_datetime,
|
115
116
|
:street => :prelude, :board => "", :max_players => 0, :number_players => 0, :table_name => "",
|
116
|
-
:game_type => "Hold'em", :limit_type => "No Limit", :stakes_type => cash_to_d($3)
|
117
|
+
:game_type => "Hold'em", :limit_type => "No Limit", :stakes_type => cash_to_d($3)
|
118
|
+
# when /PokerStars Game #([0-9]+): Tournament #([0-9]+), (#{CASH})\+(#{CASH}) USD Hold'em No Limit - Level ([IVXL]+) \((#{CASH})\/(#{CASH})\) - (.*)$/
|
119
|
+
# @stats.update_hand :name => "PS#{$1}", :description=> "#{$2}, #{$3}+#{$4} Hold'em No Limit", :tournament=> $2,
|
120
|
+
# :sb=> $6.to_d, :bb=> $7.to_d, :ante => "0.0".to_d,
|
121
|
+
# :played_at=> PokerstarsTimeStringConverter.new($8).as_utc_datetime,
|
122
|
+
# :street => :prelude, :board => "", :max_players => 0, :number_players => 0, :table_name => "",
|
123
|
+
# :game_type => "Hold'em", :limit_type => "No Limit", :stakes_type => cash_to_d($3)
|
124
|
+
when /PokerStars Game #([0-9]+): Tournament #([0-9]+), (Freeroll|(#{CASH})\+(#{CASH}) *(USD)?) +Hold'em No Limit - Level ([IVXL]+) \((#{CASH})\/(#{CASH})\) - (.*)$/
|
125
|
+
@stats.update_hand :name => "PS#{$1}", :description=> "#{$2}, #{$3} Hold'em No Limit", :tournament=> $2,
|
126
|
+
:sb=> $8.to_d, :bb=> $9.to_d, :ante => "0.0".to_d,
|
127
|
+
:played_at=> PokerstarsTimeStringConverter.new($10).as_utc_datetime,
|
128
|
+
:street => :prelude, :board => "", :max_players => 0, :number_players => 0, :table_name => "",
|
129
|
+
:game_type => "Hold'em", :limit_type => "No Limit", :stakes_type => cash_to_d($4)
|
117
130
|
when /PokerStars Game #([0-9]+): +([^(]*)Hold'em No Limit \((#{CASH})\/(#{CASH})\) - (.*)$/
|
118
131
|
@stats.update_hand :name => "PS#{$1}", :description=> "#{$2}Hold'em No Limit (#{$3}/#{$4})", :tournament=> nil,
|
119
132
|
:sb=> cash_to_d($3), :bb=> cash_to_d($4), :ante => "0.0".to_d,
|
@@ -173,7 +186,7 @@ module Pokerstats
|
|
173
186
|
@stats.register_action($1, 'raises', :result => :pay_to, :amount => cash_to_d($3))
|
174
187
|
when /(.*) collected (.*) from ((side )|(main ))?pot/
|
175
188
|
@stats.register_action($1, "wins", :result => :win, :amount => cash_to_d($2))
|
176
|
-
when /(.*) mucks hand/
|
189
|
+
when /(.*): mucks hand/
|
177
190
|
@stats.register_action($1, 'mucks', :result => :neutral)
|
178
191
|
when /Seat [0-9]+: (.*) (\((small blind)|(big blind)|(button)\) )?showed \[([^\]]+)\] and ((won) \(#{CASH}\)|(lost)) with (.*)/
|
179
192
|
when /Seat [0-9]+: (.*) mucked \[([^\]]+)\]/
|
@@ -185,6 +198,7 @@ module Pokerstats
|
|
185
198
|
private
|
186
199
|
|
187
200
|
def cash_to_d(string)
|
201
|
+
return "0".to_d if string.nil? || string.empty?
|
188
202
|
string.gsub!(/[$, ]/,"")
|
189
203
|
string.to_d
|
190
204
|
end
|
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.0.
|
8
|
+
s.version = "2.0.16"
|
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-
|
12
|
+
s.date = %q{2009-11-20}
|
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}
|
@@ -53,6 +53,7 @@ Gem::Specification.new do |s|
|
|
53
53
|
"spec/file_many_hands.txt",
|
54
54
|
"spec/file_one_hand.txt",
|
55
55
|
"spec/hand_classification_spec.rb",
|
56
|
+
"spec/hand_history_spec.rb",
|
56
57
|
"spec/hand_statistics_spec.rb",
|
57
58
|
"spec/hand_statistics_spec_helper.rb",
|
58
59
|
"spec/player_statistics_spec.rb",
|
@@ -69,6 +70,7 @@ Gem::Specification.new do |s|
|
|
69
70
|
s.summary = %q{poker hand history statistics library}
|
70
71
|
s.test_files = [
|
71
72
|
"spec/hand_classification_spec.rb",
|
73
|
+
"spec/hand_history_spec.rb",
|
72
74
|
"spec/hand_statistics_spec.rb",
|
73
75
|
"spec/hand_statistics_spec_helper.rb",
|
74
76
|
"spec/player_statistics_spec.rb",
|
@@ -1,136 +1,135 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
require File.expand_path(File.dirname(__FILE__) + '/../lib/pokerstats/hand_classification')
|
3
3
|
|
4
|
-
include Pokerstats
|
5
4
|
describe "class_index_from_hand_string" do
|
6
5
|
it "should recognize pairs" do
|
7
|
-
Pokerstats::class_index_from_hand_string("AS AH").should == 0
|
8
|
-
Pokerstats::class_index_from_hand_string("kd kc").should == 14
|
9
|
-
Pokerstats::class_index_from_hand_string("2H 2D").should == 168
|
10
|
-
Pokerstats::class_index_from_hand_string("KdkC").should == 14
|
11
|
-
Pokerstats::class_index_from_hand_string(" Kd kC").should == 14
|
12
|
-
Pokerstats::class_index_from_hand_string(" Kd kC ").should == 14
|
6
|
+
Pokerstats::HandClass.class_index_from_hand_string("AS AH").should == 0
|
7
|
+
Pokerstats::HandClass.class_index_from_hand_string("kd kc").should == 14
|
8
|
+
Pokerstats::HandClass.class_index_from_hand_string("2H 2D").should == 168
|
9
|
+
Pokerstats::HandClass.class_index_from_hand_string("KdkC").should == 14
|
10
|
+
Pokerstats::HandClass.class_index_from_hand_string(" Kd kC").should == 14
|
11
|
+
Pokerstats::HandClass.class_index_from_hand_string(" Kd kC ").should == 14
|
13
12
|
end
|
14
13
|
it "should recognize suited hands" do
|
15
|
-
Pokerstats::class_index_from_hand_string("AS KS").should == 1
|
16
|
-
Pokerstats::class_index_from_hand_string("AS 2S").should == 12
|
17
|
-
Pokerstats::class_index_from_hand_string("3S 2S").should == 155
|
18
|
-
Pokerstats::class_index_from_hand_string("AS 2s").should == 12
|
19
|
-
Pokerstats::class_index_from_hand_string("aS 2S").should == 12
|
20
|
-
Pokerstats::class_index_from_hand_string("As 2s").should == 12
|
14
|
+
Pokerstats::HandClass.class_index_from_hand_string("AS KS").should == 1
|
15
|
+
Pokerstats::HandClass.class_index_from_hand_string("AS 2S").should == 12
|
16
|
+
Pokerstats::HandClass.class_index_from_hand_string("3S 2S").should == 155
|
17
|
+
Pokerstats::HandClass.class_index_from_hand_string("AS 2s").should == 12
|
18
|
+
Pokerstats::HandClass.class_index_from_hand_string("aS 2S").should == 12
|
19
|
+
Pokerstats::HandClass.class_index_from_hand_string("As 2s").should == 12
|
21
20
|
end
|
22
21
|
it "should recognize unsuited hands" do
|
23
|
-
Pokerstats::class_index_from_hand_string("AS Kh").should == 13
|
24
|
-
Pokerstats::class_index_from_hand_string("Ad 2c").should == 156
|
25
|
-
Pokerstats::class_index_from_hand_string("3c 2S").should == 167
|
26
|
-
Pokerstats::class_index_from_hand_string("AS 2h").should == 156
|
27
|
-
Pokerstats::class_index_from_hand_string("aS 2d").should == 156
|
28
|
-
Pokerstats::class_index_from_hand_string("As 2c").should == 156
|
22
|
+
Pokerstats::HandClass.class_index_from_hand_string("AS Kh").should == 13
|
23
|
+
Pokerstats::HandClass.class_index_from_hand_string("Ad 2c").should == 156
|
24
|
+
Pokerstats::HandClass.class_index_from_hand_string("3c 2S").should == 167
|
25
|
+
Pokerstats::HandClass.class_index_from_hand_string("AS 2h").should == 156
|
26
|
+
Pokerstats::HandClass.class_index_from_hand_string("aS 2d").should == 156
|
27
|
+
Pokerstats::HandClass.class_index_from_hand_string("As 2c").should == 156
|
29
28
|
end
|
30
29
|
it "should not recognize malformed hands" do
|
31
|
-
Pokerstats::class_index_from_hand_string("AS AS").should be_nil
|
32
|
-
Pokerstats::class_index_from_hand_string("XS AH").should be_nil
|
33
|
-
Pokerstats::class_index_from_hand_string("AS XH").should be_nil
|
34
|
-
Pokerstats::class_index_from_hand_string("AX AS").should be_nil
|
35
|
-
Pokerstats::class_index_from_hand_string("AX AX").should be_nil
|
36
|
-
lambda{Pokerstats::class_index_from_hand_string!("AS AS")}.should raise_error(ArgumentError)
|
37
|
-
lambda{Pokerstats::class_index_from_hand_string!("XS AH")}.should raise_error(ArgumentError)
|
38
|
-
lambda{Pokerstats::class_index_from_hand_string!("AS XH")}.should raise_error(ArgumentError)
|
39
|
-
lambda{Pokerstats::class_index_from_hand_string!("AX AS")}.should raise_error(ArgumentError)
|
40
|
-
lambda{Pokerstats::class_index_from_hand_string!("AX AX")}.should raise_error(ArgumentError)
|
30
|
+
Pokerstats::HandClass.class_index_from_hand_string("AS AS").should be_nil
|
31
|
+
Pokerstats::HandClass.class_index_from_hand_string("XS AH").should be_nil
|
32
|
+
Pokerstats::HandClass.class_index_from_hand_string("AS XH").should be_nil
|
33
|
+
Pokerstats::HandClass.class_index_from_hand_string("AX AS").should be_nil
|
34
|
+
Pokerstats::HandClass.class_index_from_hand_string("AX AX").should be_nil
|
35
|
+
lambda{Pokerstats::HandClass.class_index_from_hand_string!("AS AS")}.should raise_error(ArgumentError)
|
36
|
+
lambda{Pokerstats::HandClass.class_index_from_hand_string!("XS AH")}.should raise_error(ArgumentError)
|
37
|
+
lambda{Pokerstats::HandClass.class_index_from_hand_string!("AS XH")}.should raise_error(ArgumentError)
|
38
|
+
lambda{Pokerstats::HandClass.class_index_from_hand_string!("AX AS")}.should raise_error(ArgumentError)
|
39
|
+
lambda{Pokerstats::HandClass.class_index_from_hand_string!("AX AX")}.should raise_error(ArgumentError)
|
41
40
|
end
|
42
41
|
end
|
43
42
|
describe "class_index_from_class_string" do
|
44
43
|
it "should recognize pairs" do
|
45
|
-
Pokerstats::class_index_from_class_string("AA").should == 0
|
46
|
-
Pokerstats::class_index_from_class_string("KK").should == 14
|
47
|
-
Pokerstats::class_index_from_class_string("22").should == 168
|
48
|
-
Pokerstats::class_index_from_class_string("KKp").should == 14
|
49
|
-
Pokerstats::class_index_from_class_string("KKP").should == 14
|
44
|
+
Pokerstats::HandClass.class_index_from_class_string("AA").should == 0
|
45
|
+
Pokerstats::HandClass.class_index_from_class_string("KK").should == 14
|
46
|
+
Pokerstats::HandClass.class_index_from_class_string("22").should == 168
|
47
|
+
Pokerstats::HandClass.class_index_from_class_string("KKp").should == 14
|
48
|
+
Pokerstats::HandClass.class_index_from_class_string("KKP").should == 14
|
50
49
|
end
|
51
50
|
it "should recognize suited hands" do
|
52
|
-
Pokerstats::class_index_from_class_string("AKs").should == 1
|
53
|
-
Pokerstats::class_index_from_class_string("A2s").should == 12
|
54
|
-
Pokerstats::class_index_from_class_string("32s").should == 155
|
55
|
-
Pokerstats::class_index_from_class_string("A2S").should == 12
|
56
|
-
Pokerstats::class_index_from_class_string("2As").should == 12
|
51
|
+
Pokerstats::HandClass.class_index_from_class_string("AKs").should == 1
|
52
|
+
Pokerstats::HandClass.class_index_from_class_string("A2s").should == 12
|
53
|
+
Pokerstats::HandClass.class_index_from_class_string("32s").should == 155
|
54
|
+
Pokerstats::HandClass.class_index_from_class_string("A2S").should == 12
|
55
|
+
Pokerstats::HandClass.class_index_from_class_string("2As").should == 12
|
57
56
|
end
|
58
57
|
it "should recognize unsuited hands" do
|
59
|
-
Pokerstats::class_index_from_class_string("AKo").should == 13
|
60
|
-
Pokerstats::class_index_from_class_string("A2o").should == 156
|
61
|
-
Pokerstats::class_index_from_class_string("32o").should == 167
|
62
|
-
Pokerstats::class_index_from_class_string("A2O").should == 156
|
63
|
-
Pokerstats::class_index_from_class_string("A2").should == 156
|
64
|
-
Pokerstats::class_index_from_class_string("2AO").should == 156
|
58
|
+
Pokerstats::HandClass.class_index_from_class_string("AKo").should == 13
|
59
|
+
Pokerstats::HandClass.class_index_from_class_string("A2o").should == 156
|
60
|
+
Pokerstats::HandClass.class_index_from_class_string("32o").should == 167
|
61
|
+
Pokerstats::HandClass.class_index_from_class_string("A2O").should == 156
|
62
|
+
Pokerstats::HandClass.class_index_from_class_string("A2").should == 156
|
63
|
+
Pokerstats::HandClass.class_index_from_class_string("2AO").should == 156
|
65
64
|
end
|
66
65
|
end
|
67
66
|
describe "class_string_from_class_index" do
|
68
67
|
it "should recognize pairs" do
|
69
|
-
Pokerstats::class_string_from_class_index(0).should == "AA"
|
70
|
-
Pokerstats::class_string_from_class_index(14).should == "KK"
|
71
|
-
Pokerstats::class_string_from_class_index(168).should == "22"
|
68
|
+
Pokerstats::HandClass.class_string_from_class_index(0).should == "AA"
|
69
|
+
Pokerstats::HandClass.class_string_from_class_index(14).should == "KK"
|
70
|
+
Pokerstats::HandClass.class_string_from_class_index(168).should == "22"
|
72
71
|
end
|
73
72
|
it "should recognize suited hands" do
|
74
|
-
Pokerstats::class_string_from_class_index(1).should == "AKs"
|
75
|
-
Pokerstats::class_string_from_class_index(12).should == "A2s"
|
76
|
-
Pokerstats::class_string_from_class_index(155).should == "32s"
|
73
|
+
Pokerstats::HandClass.class_string_from_class_index(1).should == "AKs"
|
74
|
+
Pokerstats::HandClass.class_string_from_class_index(12).should == "A2s"
|
75
|
+
Pokerstats::HandClass.class_string_from_class_index(155).should == "32s"
|
77
76
|
end
|
78
77
|
it "should recognize unsuited hands" do
|
79
|
-
Pokerstats::class_string_from_class_index(13).should == "AKo"
|
80
|
-
Pokerstats::class_string_from_class_index(156).should == "A2o"
|
81
|
-
Pokerstats::class_string_from_class_index(167).should == "32o"
|
78
|
+
Pokerstats::HandClass.class_string_from_class_index(13).should == "AKo"
|
79
|
+
Pokerstats::HandClass.class_string_from_class_index(156).should == "A2o"
|
80
|
+
Pokerstats::HandClass.class_string_from_class_index(167).should == "32o"
|
82
81
|
end
|
83
82
|
end
|
84
83
|
describe "row_from_class_index" do
|
85
84
|
it "should recognize first row indices" do
|
86
|
-
Pokerstats::row_from_class_index(0).should == 0
|
87
|
-
Pokerstats::row_from_class_index(7).should == 0
|
88
|
-
Pokerstats::row_from_class_index(12).should == 0
|
85
|
+
Pokerstats::HandClass.row_from_class_index(0).should == 0
|
86
|
+
Pokerstats::HandClass.row_from_class_index(7).should == 0
|
87
|
+
Pokerstats::HandClass.row_from_class_index(12).should == 0
|
89
88
|
end
|
90
89
|
it "should recognize middle row indices" do
|
91
|
-
Pokerstats::row_from_class_index(78).should == 6
|
92
|
-
Pokerstats::row_from_class_index(88).should == 6
|
93
|
-
Pokerstats::row_from_class_index(90).should == 6
|
90
|
+
Pokerstats::HandClass.row_from_class_index(78).should == 6
|
91
|
+
Pokerstats::HandClass.row_from_class_index(88).should == 6
|
92
|
+
Pokerstats::HandClass.row_from_class_index(90).should == 6
|
94
93
|
end
|
95
94
|
it "should recognize last row indices" do
|
96
|
-
Pokerstats::row_from_class_index(156).should == 12
|
97
|
-
Pokerstats::row_from_class_index(165).should == 12
|
98
|
-
Pokerstats::row_from_class_index(168).should == 12
|
95
|
+
Pokerstats::HandClass.row_from_class_index(156).should == 12
|
96
|
+
Pokerstats::HandClass.row_from_class_index(165).should == 12
|
97
|
+
Pokerstats::HandClass.row_from_class_index(168).should == 12
|
99
98
|
end
|
100
99
|
end
|
101
100
|
describe "col_from_class_index" do
|
102
101
|
it "should recognize first col indices" do
|
103
|
-
Pokerstats::col_from_class_index(0).should == 0
|
104
|
-
Pokerstats::col_from_class_index(78).should == 0
|
105
|
-
Pokerstats::col_from_class_index(156).should == 0
|
102
|
+
Pokerstats::HandClass.col_from_class_index(0).should == 0
|
103
|
+
Pokerstats::HandClass.col_from_class_index(78).should == 0
|
104
|
+
Pokerstats::HandClass.col_from_class_index(156).should == 0
|
106
105
|
|
107
106
|
end
|
108
107
|
it "should recognize middle col indices" do
|
109
|
-
Pokerstats::col_from_class_index(7).should == 7
|
110
|
-
Pokerstats::col_from_class_index(85).should == 7
|
111
|
-
Pokerstats::col_from_class_index(163).should == 7
|
108
|
+
Pokerstats::HandClass.col_from_class_index(7).should == 7
|
109
|
+
Pokerstats::HandClass.col_from_class_index(85).should == 7
|
110
|
+
Pokerstats::HandClass.col_from_class_index(163).should == 7
|
112
111
|
|
113
112
|
end
|
114
113
|
it "should recognize last col indices" do
|
115
|
-
Pokerstats::col_from_class_index(12).should == 12
|
116
|
-
Pokerstats::col_from_class_index(90).should == 12
|
117
|
-
Pokerstats::col_from_class_index(168).should == 12
|
114
|
+
Pokerstats::HandClass.col_from_class_index(12).should == 12
|
115
|
+
Pokerstats::HandClass.col_from_class_index(90).should == 12
|
116
|
+
Pokerstats::HandClass.col_from_class_index(168).should == 12
|
118
117
|
end
|
119
118
|
end
|
120
119
|
describe "class_index_from_row_and_col" do
|
121
120
|
it "should recognize top row" do
|
122
|
-
Pokerstats::class_index_from_row_and_col(0,0) == 0
|
123
|
-
Pokerstats::class_index_from_row_and_col(0,7) == 7
|
124
|
-
Pokerstats::class_index_from_row_and_col(0,12) == 12
|
121
|
+
Pokerstats::HandClass.class_index_from_row_and_col(0,0) == 0
|
122
|
+
Pokerstats::HandClass.class_index_from_row_and_col(0,7) == 7
|
123
|
+
Pokerstats::HandClass.class_index_from_row_and_col(0,12) == 12
|
125
124
|
end
|
126
125
|
it "should recognize middle row pairs" do
|
127
|
-
Pokerstats::class_index_from_row_and_col(7,0) == 84
|
128
|
-
Pokerstats::class_index_from_row_and_col(7,7) == 91
|
129
|
-
Pokerstats::class_index_from_row_and_col(7,12) == 96
|
126
|
+
Pokerstats::HandClass.class_index_from_row_and_col(7,0) == 84
|
127
|
+
Pokerstats::HandClass.class_index_from_row_and_col(7,7) == 91
|
128
|
+
Pokerstats::HandClass.class_index_from_row_and_col(7,12) == 96
|
130
129
|
end
|
131
130
|
it "should recognize last row pairs" do
|
132
|
-
Pokerstats::class_index_from_row_and_col(12,0) == 156
|
133
|
-
Pokerstats::class_index_from_row_and_col(12,7) == 163
|
134
|
-
Pokerstats::class_index_from_row_and_col(12,12) == 168
|
131
|
+
Pokerstats::HandClass.class_index_from_row_and_col(12,0) == 156
|
132
|
+
Pokerstats::HandClass.class_index_from_row_and_col(12,7) == 163
|
133
|
+
Pokerstats::HandClass.class_index_from_row_and_col(12,12) == 168
|
135
134
|
end
|
136
135
|
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'activesupport'
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/pokerstats/hand_history')
|
5
|
+
|
6
|
+
describe Pokerstats::HandHistory do
|
7
|
+
context "when created on an empty string" do
|
8
|
+
before(:each) do
|
9
|
+
@hand_history = Pokerstats::HandHistory.new([], "", 0)
|
10
|
+
end
|
11
|
+
|
12
|
+
it {@hand_history.should be_kind_of(Pokerstats::HandHistory)}
|
13
|
+
it {@hand_history.should_not be_parsed}
|
14
|
+
it "should not find a game" do
|
15
|
+
@hand_history.game.should be_nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "when created on a hand record" do
|
20
|
+
before(:each) do
|
21
|
+
lines = <<-HAND_HISTORY
|
22
|
+
PokerStars Game #24759011305: Tournament #139359808, $10+$1 Hold'em No Limit - Level I (10/20) - 2009/02/09 14:02:39 ET
|
23
|
+
Table '139359808 122' 9-max Seat #5 is the button
|
24
|
+
Seat 2: wizardwerdna (3000 in chips)
|
25
|
+
Seat 3: EEYORE_Q6 (3000 in chips)
|
26
|
+
Seat 4: bimbi76 (3020 in chips)
|
27
|
+
Seat 5: izibi (2970 in chips)
|
28
|
+
Seat 6: Spidar (2980 in chips) is sitting out
|
29
|
+
Seat 7: Little Dee (2900 in chips)
|
30
|
+
Seat 8: Gwünni (3000 in chips)
|
31
|
+
Seat 9: MartinBOF84 (3130 in chips)
|
32
|
+
Spidar: posts small blind 10
|
33
|
+
Little Dee: posts big blind 20
|
34
|
+
*** HOLE CARDS ***
|
35
|
+
Dealt to wizardwerdna [Qc 4d]
|
36
|
+
Gwünni: folds
|
37
|
+
MartinBOF84: folds
|
38
|
+
wizardwerdna: folds
|
39
|
+
EEYORE_Q6: calls 20
|
40
|
+
bimbi76: folds
|
41
|
+
izibi: calls 20
|
42
|
+
Spidar: folds
|
43
|
+
Little Dee: checks ""
|
44
|
+
*** FLOP *** [Ac Qs Ks]
|
45
|
+
Little Dee: checks
|
46
|
+
EEYORE_Q6: bets 20
|
47
|
+
izibi: raises 60 to 80
|
48
|
+
Little Dee: folds
|
49
|
+
EEYORE_Q6: calls 60
|
50
|
+
*** TURN *** [Ac Qs Ks] [Js]
|
51
|
+
EEYORE_Q6: checks
|
52
|
+
izibi: checks
|
53
|
+
*** RIVER *** [Ac Qs Ks Js] [8d]
|
54
|
+
EEYORE_Q6: bets 60
|
55
|
+
izibi: calls 60
|
56
|
+
*** SHOW DOWN ***
|
57
|
+
EEYORE_Q6: shows [2s Ah] (a pair of Aces)
|
58
|
+
izibi: shows [Ad 6d] (a pair of Aces)
|
59
|
+
EEYORE_Q6 collected 175 from pot
|
60
|
+
izibi collected 175 from pot
|
61
|
+
*** SUMMARY ***
|
62
|
+
Total pot 350 | Rake 0
|
63
|
+
Board [Ac Qs Ks Js 8d]
|
64
|
+
Seat 2: wizardwerdna folded before Flop (didn't bet)
|
65
|
+
Seat 3: EEYORE_Q6 showed [2s Ah] and won (175) with a pair of Aces
|
66
|
+
Seat 4: bimbi76 folded before Flop (didn't bet)
|
67
|
+
Seat 5: izibi (button) showed [Ad 6d] and won (175) with a pair of Aces
|
68
|
+
Seat 6: Spidar (small blind) folded before Flop
|
69
|
+
Seat 7: Little Dee (big blind) folded on the Flop
|
70
|
+
Seat 8: Gwünni folded before Flop (didn't bet)
|
71
|
+
Seat 9: MartinBOF84 folded before Flop (didn't bet)
|
72
|
+
HAND_HISTORY
|
73
|
+
@hand_history = Pokerstats::HandHistory.new(lines.split("\n"),"",0)
|
74
|
+
end
|
75
|
+
it "should have a game" do
|
76
|
+
@hand_history.game.should == "PS24759011305"
|
77
|
+
end
|
78
|
+
it "should have a parse" do
|
79
|
+
@hand_history.parse
|
80
|
+
@hand_history.should be_parsed
|
81
|
+
end
|
82
|
+
it "should have a report" do
|
83
|
+
lambda{@hand_history.reports}.should_not raise_error
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -1531,7 +1531,6 @@ describe HandStatistics do
|
|
1531
1531
|
register_check @sb
|
1532
1532
|
register_check @bb
|
1533
1533
|
register_bet @button, 2
|
1534
|
-
puts "last_aggr_player = #{@stats.last_aggr_player.inspect}"
|
1535
1534
|
["sb", "bb", "button"].each do |player|
|
1536
1535
|
@stats.cbet_flop(player).should be_nil
|
1537
1536
|
@stats.call_cbet_flop(player).should be_nil
|
@@ -54,6 +54,12 @@ describe PokerstarsHandHistoryParser, "recognizes valid hand history" do
|
|
54
54
|
first_line = "PokerStars Game #21650436825: Tournament #117620218, $10+$1 Hold'em No Limit - Level I (10/20) - 2008/10/31 17:25:42 ET"
|
55
55
|
PokerstarsHandHistoryParser.game(first_line).should == "PS21650436825"
|
56
56
|
end
|
57
|
+
|
58
|
+
it "should recognize a valid tournament hand history" do
|
59
|
+
first_line = "PokerStars Game #33566683789: Tournament #199550385, $10+$1 USD Hold'em No Limit - Level XVIII (2000/4000) - 2009/10/02 22:00:29 ET"
|
60
|
+
PokerstarsHandHistoryParser.game(first_line).should == "PS33566683789"
|
61
|
+
end
|
62
|
+
|
57
63
|
it "should recognize a valid cash game hand history" do
|
58
64
|
first_line = "PokerStars Game #21650146783: Hold'em No Limit ($0.25/$0.50) - 2008/10/31 17:14:44 ET"
|
59
65
|
PokerstarsHandHistoryParser.game(first_line).should == "PS21650146783"
|
@@ -89,6 +95,48 @@ describe PokerstarsHandHistoryParser, "when parsing structural matter" do
|
|
89
95
|
)
|
90
96
|
@parser.parse("PokerStars Game #21650436825: Tournament #117620218, $10+$1 Hold'em No Limit - Level I (10/20) - 2008/10/31 17:25:42 ET")
|
91
97
|
end
|
98
|
+
|
99
|
+
it "should recognize a valid tournament hand history" do
|
100
|
+
@stats.should_receive(:update_hand).with(
|
101
|
+
:name => "PS33566683789",
|
102
|
+
:description => "199550385, $10+$1 USD Hold'em No Limit",
|
103
|
+
:ante => "0.0".to_d,
|
104
|
+
:table_name => "",
|
105
|
+
:max_players => 0,
|
106
|
+
:number_players => 0,
|
107
|
+
:sb => "2000".to_d,
|
108
|
+
:bb => "4000".to_d,
|
109
|
+
:played_at => DateTime.parse("2009/10/03 02:00:29 UDT"),
|
110
|
+
:tournament => "199550385",
|
111
|
+
:street => :prelude,
|
112
|
+
:board => "",
|
113
|
+
:game_type => "Hold'em",
|
114
|
+
:stakes_type => "10".to_d,
|
115
|
+
:limit_type => "No Limit"
|
116
|
+
)
|
117
|
+
@parser.parse("PokerStars Game #33566683789: Tournament #199550385, $10+$1 USD Hold'em No Limit - Level XVIII (2000/4000) - 2009/10/02 22:00:29 ET")
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should recognize a freeroll tournament hand history" do
|
121
|
+
@stats.should_receive(:update_hand).with(
|
122
|
+
:name => "PS24703545200",
|
123
|
+
:description => "137653257, Freeroll Hold'em No Limit",
|
124
|
+
:ante => "0.0".to_d,
|
125
|
+
:table_name => "",
|
126
|
+
:max_players => 0,
|
127
|
+
:number_players => 0,
|
128
|
+
:sb => "10".to_d,
|
129
|
+
:bb => "20".to_d,
|
130
|
+
:played_at => DateTime.parse("Sun, 08 Feb 2009 00:24:12 +0000"),
|
131
|
+
:tournament => "137653257",
|
132
|
+
:street => :prelude,
|
133
|
+
:board => "",
|
134
|
+
:game_type => "Hold'em",
|
135
|
+
:stakes_type => "0".to_d,
|
136
|
+
:limit_type => "No Limit"
|
137
|
+
)
|
138
|
+
@parser.parse("PokerStars Game #24703545200: Tournament #137653257, Freeroll Hold'em No Limit - Level I (10/20) - 2009/02/07 19:24:12 ET")
|
139
|
+
end
|
92
140
|
|
93
141
|
it "should recognize a tournament header" do
|
94
142
|
PokerstarsHandHistoryParser.should have_valid_header("PokerStars Game #21650436825: Tournament #117620218, $10+$1 Hold'em No Limit - Level I (10/20) - 2008/10/31 17:25:42 ET\nsnuggles\n")
|
@@ -259,6 +307,6 @@ describe PokerstarsHandHistoryParser, "when parsing poker actions" do
|
|
259
307
|
end
|
260
308
|
it "should properly parse and register a muck" do
|
261
309
|
@stats.should_receive(:register_action).with("billy", "mucks", :result => :neutral)
|
262
|
-
@parser.parse("billy mucks hand")
|
310
|
+
@parser.parse("billy: mucks hand")
|
263
311
|
end
|
264
312
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -7,3 +7,22 @@ require 'spec/autorun'
|
|
7
7
|
Spec::Runner.configure do |config|
|
8
8
|
|
9
9
|
end
|
10
|
+
|
11
|
+
Spec::Matchers.define :be_hash_similar_with do |expected|
|
12
|
+
match do |actual|
|
13
|
+
@errors = []
|
14
|
+
for key in (expected.keys + actual.keys).uniq
|
15
|
+
@errors << {:expected => expected[key], :actual => actual[key], :key => key} unless expected[key] == actual[key]
|
16
|
+
end
|
17
|
+
@errors.empty?
|
18
|
+
end
|
19
|
+
failure_message_for_should do |hash|
|
20
|
+
@errors.collect{|each| "expected #{each[:key].inspect} to be #{each[:expected].inspect}, but got #{each[:actual].inspect}"}.join(";\n")
|
21
|
+
end
|
22
|
+
failure_message_for_should_not do |hash|
|
23
|
+
"the two elements are hash_similar"
|
24
|
+
end
|
25
|
+
description do
|
26
|
+
"have the same values for corresponding keys"
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pokerstats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew C. Greenberg
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-20 00:00:00 -08:00
|
13
13
|
default_executable: checkps
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- spec/file_many_hands.txt
|
87
87
|
- spec/file_one_hand.txt
|
88
88
|
- spec/hand_classification_spec.rb
|
89
|
+
- spec/hand_history_spec.rb
|
89
90
|
- spec/hand_statistics_spec.rb
|
90
91
|
- spec/hand_statistics_spec_helper.rb
|
91
92
|
- spec/player_statistics_spec.rb
|
@@ -124,6 +125,7 @@ specification_version: 3
|
|
124
125
|
summary: poker hand history statistics library
|
125
126
|
test_files:
|
126
127
|
- spec/hand_classification_spec.rb
|
128
|
+
- spec/hand_history_spec.rb
|
127
129
|
- spec/hand_statistics_spec.rb
|
128
130
|
- spec/hand_statistics_spec_helper.rb
|
129
131
|
- spec/player_statistics_spec.rb
|