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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4356bae466a6937d427c1addffe9b4b56a56752
4
- data.tar.gz: 53d930d856434f2e99229eba50d53bb9c49c0777
3
+ metadata.gz: 70397088ba5bed572b116c5ce0e00da950bb8ae6
4
+ data.tar.gz: 08709982a9186277f5e59c4f2c7682eb42ba4905
5
5
  SHA512:
6
- metadata.gz: 445658f326cc4a00cfe5dee77be60bf2b88c5d59cb341a7ea7d7d7bbc1656ae49ec5d4fa00829fa1d234391521eddd86b9c896e1bc7c7e9897f9248a2d7e8164
7
- data.tar.gz: a5ac949dddab857a288f1b641b91627760d70c4c09e041c8865f5854ea0561d319c0d55a100d551e938758f9d3e681a1cb6eda94e9209d77237481f07bbbc19c
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, round = @actions.length - 1)
97
+ def append_action!(action, round_num = round)
98
98
  raise Inactive if inactive?
99
99
 
100
- @actions[round] ||= []
101
- @actions[round] << action
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
@@ -1,3 +1,3 @@
1
1
  module AcpcPokerTypes
2
- VERSION = '6.0.2'
2
+ VERSION = '6.1.0'
3
3
  end
@@ -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).sort.must_equal [
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
- patient.legal_actions(0, amount_to_call: INITIAL_CHIP_STACK - (ANTE + 100))
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acpc_poker_types
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.2
4
+ version: 6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dustin Morrill