acpc_poker_types 6.0.2 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/acpc_poker_types/hand_player.rb +8 -5
- data/lib/acpc_poker_types/version.rb +1 -1
- data/spec/hand_player_spec.rb +25 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70397088ba5bed572b116c5ce0e00da950bb8ae6
|
4
|
+
data.tar.gz: 08709982a9186277f5e59c4f2c7682eb42ba4905
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a99cbdd394535446c908314814f56f1eee0e00f772dfcdcefafbe5ab6328f58621c4bd4f3f01ffc66164e2422027a7c59401b5c447d9cae27155279bde2a711f
|
7
|
+
data.tar.gz: 6a3b0269873e0d55bf9712e2869edbbdc7ef568baa4534e67a830d9c4232d61c3ff953ab73c63bf51f779c6aedadb7b451c7203c879334eb8085821a169bba41
|
@@ -63,7 +63,7 @@ class HandPlayer
|
|
63
63
|
# @return [Array<PokerAction>] The list of legal actions for this player. If a wager is legal,
|
64
64
|
# the largest possible wager will be returned in the list.
|
65
65
|
def legal_actions(
|
66
|
-
round,
|
66
|
+
round: round,
|
67
67
|
amount_to_call: ChipStack.new(0),
|
68
68
|
wager_illegal: false
|
69
69
|
)
|
@@ -94,11 +94,11 @@ class HandPlayer
|
|
94
94
|
# @todo
|
95
95
|
# end
|
96
96
|
|
97
|
-
def append_action!(action,
|
97
|
+
def append_action!(action, round_num = round)
|
98
98
|
raise Inactive if inactive?
|
99
99
|
|
100
|
-
@actions[
|
101
|
-
@actions[
|
100
|
+
@actions[round_num] ||= []
|
101
|
+
@actions[round_num] << action
|
102
102
|
|
103
103
|
self
|
104
104
|
end
|
@@ -114,6 +114,9 @@ class HandPlayer
|
|
114
114
|
def folded?
|
115
115
|
@actions.flatten.last == PokerAction::FOLD
|
116
116
|
end
|
117
|
-
end
|
118
117
|
|
118
|
+
def round
|
119
|
+
@actions.length - 1
|
120
|
+
end
|
121
|
+
end
|
119
122
|
end
|
data/spec/hand_player_spec.rb
CHANGED
@@ -17,6 +17,10 @@ describe HandPlayer do
|
|
17
17
|
ANTE = 100
|
18
18
|
HAND = Hand.from_acpc('AhKs')
|
19
19
|
|
20
|
+
before do
|
21
|
+
@patient = nil
|
22
|
+
end
|
23
|
+
|
20
24
|
def patient
|
21
25
|
@patient ||= HandPlayer.new HAND, INITIAL_CHIP_STACK, ANTE
|
22
26
|
end
|
@@ -200,40 +204,40 @@ describe HandPlayer do
|
|
200
204
|
|
201
205
|
describe '#legal_actions' do
|
202
206
|
it 'works with fold' do
|
203
|
-
patient.legal_actions(0, amount_to_call: 100).sort.must_equal [
|
207
|
+
patient.legal_actions(round: 0, amount_to_call: 100).sort.must_equal [
|
204
208
|
PokerAction.new(PokerAction::CALL),
|
205
209
|
PokerAction.new(PokerAction::RAISE, cost: INITIAL_CHIP_STACK - (ANTE + 100)),
|
206
210
|
PokerAction.new(PokerAction::FOLD)
|
207
211
|
].sort
|
208
212
|
patient.append_action!(PokerAction.new('c', cost: 100))
|
209
|
-
.legal_actions(0, amount_to_call: 200).sort.must_equal [
|
213
|
+
.legal_actions(round: 0, amount_to_call: 200).sort.must_equal [
|
210
214
|
PokerAction.new(PokerAction::CALL),
|
211
215
|
PokerAction.new(PokerAction::RAISE, cost: INITIAL_CHIP_STACK - (ANTE + 200)),
|
212
216
|
PokerAction.new(PokerAction::FOLD)
|
213
217
|
].sort
|
214
218
|
patient.append_action!(PokerAction.new('f'))
|
215
|
-
.legal_actions(0).empty?.must_equal true
|
219
|
+
.legal_actions(round: 0).empty?.must_equal true
|
216
220
|
end
|
217
221
|
it 'works with all in' do
|
218
|
-
patient.legal_actions(0).sort.must_equal [
|
222
|
+
patient.legal_actions(round: 0).sort.must_equal [
|
219
223
|
PokerAction.new(PokerAction::CHECK),
|
220
224
|
PokerAction.new(PokerAction::BET, cost: INITIAL_CHIP_STACK - ANTE),
|
221
225
|
].sort
|
222
226
|
patient.append_action!(PokerAction.new('c', cost: 100))
|
223
|
-
.legal_actions(0).sort.must_equal [
|
227
|
+
.legal_actions(round: 0).sort.must_equal [
|
224
228
|
PokerAction.new(PokerAction::CHECK),
|
225
229
|
PokerAction.new(PokerAction::BET, cost: INITIAL_CHIP_STACK - (ANTE + 100)),
|
226
230
|
].sort
|
227
231
|
patient.append_action!(PokerAction.new('c', cost: INITIAL_CHIP_STACK - (ANTE + 100)))
|
228
|
-
.legal_actions(0).empty?.must_equal true
|
232
|
+
.legal_actions(round: 0).empty?.must_equal true
|
229
233
|
end
|
230
234
|
it 'works when an opponent is all in' do
|
231
235
|
patient.append_action!(PokerAction.new('c', cost: 100))
|
232
|
-
.legal_actions(0).sort.must_equal [
|
236
|
+
.legal_actions(round: 0).sort.must_equal [
|
233
237
|
PokerAction.new(PokerAction::CHECK),
|
234
238
|
PokerAction.new(PokerAction::RAISE, cost: INITIAL_CHIP_STACK - (ANTE + 100))
|
235
239
|
].sort
|
236
|
-
patient.legal_actions(0, amount_to_call: INITIAL_CHIP_STACK - (ANTE + 100))
|
240
|
+
patient.legal_actions(round: 0, amount_to_call: INITIAL_CHIP_STACK - (ANTE + 100))
|
237
241
|
.sort.must_equal [
|
238
242
|
PokerAction.new(PokerAction::CALL),
|
239
243
|
PokerAction.new(PokerAction::FOLD)
|
@@ -241,10 +245,21 @@ describe HandPlayer do
|
|
241
245
|
end
|
242
246
|
it 'works when no more raises are allowed' do
|
243
247
|
patient.append_action!(PokerAction.new('c', cost: 100))
|
244
|
-
.legal_actions(0, wager_illegal: true).
|
248
|
+
.legal_actions(round: 0, wager_illegal: true).must_equal [
|
245
249
|
PokerAction.new(PokerAction::CHECK)
|
250
|
+
]
|
251
|
+
patient.legal_actions(round: 0, amount_to_call: INITIAL_CHIP_STACK - (ANTE + 100))
|
252
|
+
.sort.must_equal [
|
253
|
+
PokerAction.new(PokerAction::CALL),
|
254
|
+
PokerAction.new(PokerAction::FOLD)
|
246
255
|
].sort
|
247
|
-
|
256
|
+
end
|
257
|
+
it 'works without round argument' do
|
258
|
+
patient.append_action!(PokerAction.new('c', cost: 100))
|
259
|
+
.legal_actions(wager_illegal: true).must_equal [
|
260
|
+
PokerAction.new(PokerAction::CHECK)
|
261
|
+
]
|
262
|
+
patient.legal_actions(amount_to_call: INITIAL_CHIP_STACK - (ANTE + 100))
|
248
263
|
.sort.must_equal [
|
249
264
|
PokerAction.new(PokerAction::CALL),
|
250
265
|
PokerAction.new(PokerAction::FOLD)
|