rora 0.0.6 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +59 -15
- data/Rakefile +0 -1
- data/lib/rora.rb +4 -0
- data/lib/rora/{hands.csv → 5-card-hands.csv} +0 -0
- data/lib/rora/7-card-hands.csv +323765 -0
- data/lib/rora/cards.csv +52 -0
- data/lib/rora/flushes.csv +40 -0
- data/lib/rora/model/board.rb +2 -2
- data/lib/rora/model/card.rb +17 -14
- data/lib/rora/model/deck.rb +23 -0
- data/lib/rora/model/equity.rb +18 -0
- data/lib/rora/model/hand.rb +12 -27
- data/lib/rora/model/hand_type.rb +1 -1
- data/lib/rora/model/pot.rb +1 -1
- data/lib/rora/model/rank.rb +34 -16
- data/lib/rora/model/starting_hand.rb +22 -18
- data/lib/rora/model/suit.rb +26 -11
- data/lib/rora/model/table.rb +0 -3
- data/lib/rora/repository/card_repository.rb +17 -0
- data/lib/rora/repository/hand_repository.rb +60 -20
- data/lib/rora/repository/starting_hand_repository.rb +2 -1
- data/lib/rora/utils/equity_calculator.rb +47 -0
- data/lib/rora/utils/hand_ranking_generator.rb +135 -0
- data/test/rora/model/board_test.rb +19 -20
- data/test/rora/model/card_test.rb +45 -15
- data/test/rora/model/deck_test.rb +24 -0
- data/test/rora/model/hand_test.rb +5 -29
- data/test/rora/model/hand_type_test.rb +3 -3
- data/test/rora/model/pot_test.rb +2 -2
- data/test/rora/model/rank_test.rb +10 -2
- data/test/rora/model/seat_test.rb +1 -1
- data/test/rora/model/starting_hand_test.rb +8 -16
- data/test/rora/model/suit_test.rb +3 -3
- data/test/rora/model/table_test.rb +8 -8
- data/test/rora/repository/hand_repository_test.rb +14 -16
- data/test/rora/utils/equity_calculator_test.rb +53 -0
- data/test/rora_test.rb +1 -1
- metadata +13 -6
- data/test/rora/model/game_test.rb +0 -23
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.expand_path("../../rora_test", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class EquityCalculatorTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@board = Board.new("3CASKS")
|
7
|
+
@calculator = EquityCalculator.new
|
8
|
+
end
|
9
|
+
|
10
|
+
test "should return equity calculations for a heads up game" do
|
11
|
+
starting_hands = [StartingHand.new("2H2S"), StartingHand.new("3H3S")]
|
12
|
+
|
13
|
+
#puts "#{DateTime.now.strftime('%Y-%m-%d %H:%M:%S')}"
|
14
|
+
equities = @calculator.calculate_equity(starting_hands, @board)
|
15
|
+
#puts "#{DateTime.now.strftime('%Y-%m-%d %H:%M:%S')}"
|
16
|
+
|
17
|
+
assert_equity_value "1.62", "2H2S", equities
|
18
|
+
assert_equity_value "98.38", "3H3S", equities
|
19
|
+
end
|
20
|
+
|
21
|
+
test "should raise an error when there are no starting hands to compare" do
|
22
|
+
starting_hands = []
|
23
|
+
assert_raise_message "Must have at least two starting hands for equity comparison", ArgumentError do
|
24
|
+
@calculator.calculate_equity(starting_hands, Board.new)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
test "should raise an error when there is only one starting hand to compare" do
|
29
|
+
starting_hands = [StartingHand.new("2H2S")]
|
30
|
+
assert_raise_message "Must have at least two starting hands for equity comparison", ArgumentError do
|
31
|
+
@calculator.calculate_equity(starting_hands, Board.new)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
test "should raise an error when there there are duplicate cards across starting hands" do
|
36
|
+
starting_hands = [StartingHand.new("2H2S"), StartingHand.new("5H6H"), StartingHand.new("3S2S")]
|
37
|
+
assert_raise_message "There are duplicate cards", ArgumentError do
|
38
|
+
@calculator.calculate_equity(starting_hands, @board)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
test "should raise an error when there there are duplicate cards on the board" do
|
43
|
+
starting_hands = [StartingHand.new("ASKD"), StartingHand.new("5H6H"), StartingHand.new("3D2D")]
|
44
|
+
assert_raise_message "There are duplicate cards", ArgumentError do
|
45
|
+
@calculator.calculate_equity(starting_hands, Board.new("AS2D7C"))
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def assert_equity_value(value, starting_hand, equities)
|
50
|
+
assert_equal value, sprintf("%.02f", equities[StartingHand.new(starting_hand)].value)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
data/test/rora_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -76,15 +76,19 @@ dependencies:
|
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 2.4.8
|
78
78
|
description: A Ruby library for conducting poker experiments and simulations
|
79
|
-
email: brandon@moralesce.com
|
79
|
+
email: brandon.john.grenier@moralesce.com
|
80
80
|
executables: []
|
81
81
|
extensions: []
|
82
82
|
extra_rdoc_files: []
|
83
83
|
files:
|
84
|
-
- lib/rora/hands.csv
|
84
|
+
- lib/rora/5-card-hands.csv
|
85
|
+
- lib/rora/7-card-hands.csv
|
86
|
+
- lib/rora/cards.csv
|
87
|
+
- lib/rora/flushes.csv
|
85
88
|
- lib/rora/model/board.rb
|
86
89
|
- lib/rora/model/card.rb
|
87
90
|
- lib/rora/model/deck.rb
|
91
|
+
- lib/rora/model/equity.rb
|
88
92
|
- lib/rora/model/game.rb
|
89
93
|
- lib/rora/model/hand.rb
|
90
94
|
- lib/rora/model/hand_type.rb
|
@@ -95,9 +99,12 @@ files:
|
|
95
99
|
- lib/rora/model/starting_hand.rb
|
96
100
|
- lib/rora/model/suit.rb
|
97
101
|
- lib/rora/model/table.rb
|
102
|
+
- lib/rora/repository/card_repository.rb
|
98
103
|
- lib/rora/repository/hand_repository.rb
|
99
104
|
- lib/rora/repository/starting_hand_repository.rb
|
105
|
+
- lib/rora/utils/equity_calculator.rb
|
100
106
|
- lib/rora/utils/game_logger.rb
|
107
|
+
- lib/rora/utils/hand_ranking_generator.rb
|
101
108
|
- lib/rora.rb
|
102
109
|
- LICENSE
|
103
110
|
- README.md
|
@@ -105,7 +112,6 @@ files:
|
|
105
112
|
- test/rora/model/board_test.rb
|
106
113
|
- test/rora/model/card_test.rb
|
107
114
|
- test/rora/model/deck_test.rb
|
108
|
-
- test/rora/model/game_test.rb
|
109
115
|
- test/rora/model/hand_test.rb
|
110
116
|
- test/rora/model/hand_type_test.rb
|
111
117
|
- test/rora/model/player_test.rb
|
@@ -117,6 +123,7 @@ files:
|
|
117
123
|
- test/rora/model/table_test.rb
|
118
124
|
- test/rora/repository/hand_repository_test.rb
|
119
125
|
- test/rora/repository/starting_hand_repository_test.rb
|
126
|
+
- test/rora/utils/equity_calculator_test.rb
|
120
127
|
- test/rora_test.rb
|
121
128
|
homepage: http://www.moralesce.com
|
122
129
|
licenses: []
|
@@ -146,7 +153,6 @@ test_files:
|
|
146
153
|
- test/rora/model/board_test.rb
|
147
154
|
- test/rora/model/card_test.rb
|
148
155
|
- test/rora/model/deck_test.rb
|
149
|
-
- test/rora/model/game_test.rb
|
150
156
|
- test/rora/model/hand_test.rb
|
151
157
|
- test/rora/model/hand_type_test.rb
|
152
158
|
- test/rora/model/player_test.rb
|
@@ -158,4 +164,5 @@ test_files:
|
|
158
164
|
- test/rora/model/table_test.rb
|
159
165
|
- test/rora/repository/hand_repository_test.rb
|
160
166
|
- test/rora/repository/starting_hand_repository_test.rb
|
167
|
+
- test/rora/utils/equity_calculator_test.rb
|
161
168
|
- test/rora_test.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require File.expand_path("../../rora_test", File.dirname(__FILE__))
|
2
|
-
|
3
|
-
class GameTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@game = Game.new
|
7
|
-
end
|
8
|
-
|
9
|
-
test "play the game" do
|
10
|
-
for i in 0..5 do
|
11
|
-
player = Player.new("Player #{i}", 100000)
|
12
|
-
@game.add player
|
13
|
-
player.start_session
|
14
|
-
end
|
15
|
-
|
16
|
-
@game.shuffle_deck
|
17
|
-
@game.assign_button
|
18
|
-
@game.post_small_blind
|
19
|
-
@game.post_big_blind
|
20
|
-
@game.deal_pocket_cards
|
21
|
-
@game.run_preflop_betting_round
|
22
|
-
end
|
23
|
-
end
|