acpc_poker_types 6.2.1 → 6.2.2
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/match_state.rb +44 -39
- data/lib/acpc_poker_types/player_group.rb +1 -1
- data/lib/acpc_poker_types/version.rb +1 -1
- data/spec/match_state_spec.rb +20 -0
- 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: 61dde71cbe5078bb8420f94dc3205f3c5068d207
|
4
|
+
data.tar.gz: 539221fc8a9eded8eb4f67e3665f1c249d5d20fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edcd59b6a50857689d793352d1ac4ce92d0940527e051ca1bb2d96cde5341f56e63a1a1390e1c264e56044fb9d514783e6a262a7df6067abbb466271b140411e
|
7
|
+
data.tar.gz: 3d645d72f22c5fdd38df91f9ae8c99b39c4b4584e99f02d9a21fd6c5dd0021ff268421f83ff6c4105df354be332f14d59b6053b55ad99f861ae3926919a8a83b
|
@@ -162,8 +162,8 @@ class MatchState
|
|
162
162
|
def community_cards
|
163
163
|
@community_cards ||= -> do
|
164
164
|
lcl_community_cards = BoardCards.new(
|
165
|
-
all_sets_of_community_cards(@community_cards_string).map do |
|
166
|
-
Card.cards(
|
165
|
+
all_sets_of_community_cards(@community_cards_string).map do |cards_per_round|
|
166
|
+
Card.cards(cards_per_round)
|
167
167
|
end
|
168
168
|
)
|
169
169
|
if lcl_community_cards.round < @community_cards_string.count(COMMUNITY_CARD_SEPARATOR)
|
@@ -262,39 +262,11 @@ class MatchState
|
|
262
262
|
def every_action(game_def)
|
263
263
|
@players = players_at_hand_start game_def.chip_stacks, game_def.blinds
|
264
264
|
|
265
|
-
last_round = -1
|
266
265
|
@next_to_act = game_def.first_player_positions.first
|
267
266
|
@player_acting_sequence = []
|
268
267
|
@min_wager_by = game_def.min_wagers.first
|
269
|
-
every_action_token do |action, round|
|
270
|
-
if round != last_round
|
271
|
-
@min_wager_by = game_def.min_wagers[round]
|
272
|
-
@next_to_act = @players.position_of_first_active_player(
|
273
|
-
game_def.first_player_positions[round]
|
274
|
-
)
|
275
|
-
@player_acting_sequence << []
|
276
|
-
last_round = round
|
277
|
-
end
|
278
|
-
|
279
|
-
@player_acting_sequence.last << @next_to_act
|
280
|
-
acting_player_position = @player_acting_sequence.last.last
|
281
|
-
|
282
|
-
@next_to_act = @players.next_to_act(@next_to_act)
|
283
268
|
|
284
|
-
|
285
|
-
acting_player_position,
|
286
|
-
action,
|
287
|
-
game_def.min_wagers[round]
|
288
|
-
)
|
289
|
-
|
290
|
-
action = PokerAction.new(action.to_s, cost: cost) if cost > 0
|
291
|
-
|
292
|
-
adjust_min_wager!(action, acting_player_position)
|
293
|
-
|
294
|
-
@players[acting_player_position].append_action!(action, round)
|
295
|
-
|
296
|
-
yield action, round, acting_player_position, @players if block_given?
|
297
|
-
end
|
269
|
+
walk_over_betting_sequence!(game_def)
|
298
270
|
|
299
271
|
distribute_chips!(game_def) if hand_ended?(game_def)
|
300
272
|
|
@@ -347,6 +319,47 @@ class MatchState
|
|
347
319
|
|
348
320
|
private
|
349
321
|
|
322
|
+
def walk_over_betting_sequence!(game_def)
|
323
|
+
last_round = -1
|
324
|
+
betting_sequence.each_with_index do |actions_per_round, current_round|
|
325
|
+
@min_wager_by = game_def.min_wagers[current_round]
|
326
|
+
@next_to_act = @players.position_of_first_active_player(
|
327
|
+
game_def.first_player_positions[current_round]
|
328
|
+
)
|
329
|
+
@player_acting_sequence << []
|
330
|
+
last_round = current_round
|
331
|
+
|
332
|
+
walk_over_actions!(actions_per_round, game_def, last_round, current_round)
|
333
|
+
end
|
334
|
+
|
335
|
+
self
|
336
|
+
end
|
337
|
+
|
338
|
+
def walk_over_actions!(actions_per_round, game_def, last_round, current_round)
|
339
|
+
actions_per_round.each do |action|
|
340
|
+
@player_acting_sequence.last << @next_to_act
|
341
|
+
acting_player_position = @player_acting_sequence.last.last
|
342
|
+
|
343
|
+
@next_to_act = @players.next_to_act(@next_to_act)
|
344
|
+
|
345
|
+
cost = @players.action_cost(
|
346
|
+
acting_player_position,
|
347
|
+
action,
|
348
|
+
game_def.min_wagers[current_round]
|
349
|
+
)
|
350
|
+
|
351
|
+
action = PokerAction.new(action.to_s, cost: cost) if cost > 0
|
352
|
+
|
353
|
+
adjust_min_wager!(action, acting_player_position)
|
354
|
+
|
355
|
+
@players[acting_player_position].append_action!(action, current_round)
|
356
|
+
|
357
|
+
yield action, current_round, acting_player_position if block_given?
|
358
|
+
end
|
359
|
+
|
360
|
+
self
|
361
|
+
end
|
362
|
+
|
350
363
|
# Distribute chips to all winning players
|
351
364
|
def distribute_chips!(game_def)
|
352
365
|
return self if pot(game_def) <= 0
|
@@ -373,14 +386,6 @@ class MatchState
|
|
373
386
|
self
|
374
387
|
end
|
375
388
|
|
376
|
-
def every_action_token
|
377
|
-
betting_sequence.each_with_index do |actions_per_round, round|
|
378
|
-
actions_per_round.each do |action|
|
379
|
-
yield action, round if block_given?
|
380
|
-
end
|
381
|
-
end
|
382
|
-
end
|
383
|
-
|
384
389
|
def all_string_hands(string_of_card_sets)
|
385
390
|
all_sets_of_cards(string_of_card_sets, HAND_SEPARATOR)
|
386
391
|
end
|
@@ -22,7 +22,7 @@ class PlayerGroup < DelegateClass(Array)
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def position_of_first_active_player(acting_player_position=0)
|
25
|
-
|
25
|
+
return nil if all? { |player| player.inactive? }
|
26
26
|
|
27
27
|
# This must eventually exit because of the above assertion
|
28
28
|
while @players[acting_player_position].inactive?
|
data/spec/match_state_spec.rb
CHANGED
@@ -816,6 +816,26 @@ describe MatchState do
|
|
816
816
|
end
|
817
817
|
end
|
818
818
|
end
|
819
|
+
describe '#next_to_act' do
|
820
|
+
it 'works at the start of new rounds' do
|
821
|
+
wager_size = 10
|
822
|
+
x_game_def = GameDefinition.new(
|
823
|
+
first_player_positions: [1, 0, 0],
|
824
|
+
chip_stacks: [100, 200],
|
825
|
+
blinds: [0, 10],
|
826
|
+
raise_sizes: [wager_size]*3,
|
827
|
+
number_of_ranks: 3
|
828
|
+
)
|
829
|
+
|
830
|
+
(0..x_game_def.number_of_players-1).each do |position|
|
831
|
+
x_next_to_act = [0, 0]
|
832
|
+
patient = MatchState.new("#{MatchState::LABEL}:#{position}:0:cc/:5d5c|/8dAs8s")
|
833
|
+
patient.every_action(x_game_def) do
|
834
|
+
patient.next_to_act(x_game_def).must_equal x_next_to_act.shift
|
835
|
+
end
|
836
|
+
end
|
837
|
+
end
|
838
|
+
end
|
819
839
|
end
|
820
840
|
|
821
841
|
def for_every_card
|