acpc_poker_types 7.2.1 → 7.2.2
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.
- checksums.yaml +4 -4
- data/lib/acpc_poker_types/game_definition.rb +14 -11
- data/lib/acpc_poker_types/match_state.rb +15 -5
- data/lib/acpc_poker_types/version.rb +1 -1
- data/spec/match_state_spec.rb +36 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d88ee4899d3a352a88bc92a6add13b04bcff7c4e
|
4
|
+
data.tar.gz: 03d3de874c31a5c45e6d53bcd025d889d061ace9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 309d18632e6b28b1d850dac0e88809c98bc8c1c1d004a97bd091026c1ec4830759ff7b72b545a425e9b8478273cbb86cfd258852c885ee910b6a19bc057ca6b8
|
7
|
+
data.tar.gz: 7a33b1e92659f5b660670c267f6ad5250d752af4da132a5c2231bef6938aa2eb6c010cb4aac06bfa25346c2e58be0ab31b1823dfb325d4949b87c848e0805712
|
@@ -97,6 +97,14 @@ module AcpcPokerTypes
|
|
97
97
|
:@number_of_board_cards => 'numBoardCards'
|
98
98
|
}
|
99
99
|
|
100
|
+
ALL_PLAYER_ALL_ROUND_DEFS = [
|
101
|
+
DEFINITIONS[:@number_of_players],
|
102
|
+
DEFINITIONS[:@number_of_rounds],
|
103
|
+
DEFINITIONS[:@number_of_suits],
|
104
|
+
DEFINITIONS[:@number_of_ranks],
|
105
|
+
DEFINITIONS[:@number_of_hole_cards]
|
106
|
+
]
|
107
|
+
|
100
108
|
def self.default_first_player_positions(number_of_rounds)
|
101
109
|
number_of_rounds.to_i.times.inject([]) do |list, i|
|
102
110
|
list << 0
|
@@ -118,12 +126,6 @@ module AcpcPokerTypes
|
|
118
126
|
end
|
119
127
|
end
|
120
128
|
|
121
|
-
# @param [Array] array The array to flatten into a single element.
|
122
|
-
# @return +array+ if +array+ has more than one element, the single element in +array+ otherwise.
|
123
|
-
def self.flatten_if_single_element_array(array)
|
124
|
-
if 1 == array.length then array[0] else array end
|
125
|
-
end
|
126
|
-
|
127
129
|
# Checks if the given line is a comment beginning with '#' or ';', or empty.
|
128
130
|
#
|
129
131
|
# @param [String] line
|
@@ -132,7 +134,7 @@ module AcpcPokerTypes
|
|
132
134
|
line.nil? || line.match(/^\s*[#;]/) || line.empty?
|
133
135
|
end
|
134
136
|
|
135
|
-
# Checks a given line
|
137
|
+
# Checks a given line frcom a game definition file for a game
|
136
138
|
# definition name and returns the given default value unless there is a match.
|
137
139
|
#
|
138
140
|
# @param [String, #match] line A line from a game definition file.
|
@@ -142,11 +144,12 @@ module AcpcPokerTypes
|
|
142
144
|
# referred to by +definition_name+, +nil+ otherwise.
|
143
145
|
def self.check_game_def_line_for_definition(line, definition_name)
|
144
146
|
if line.match(/^\s*#{definition_name}\s*=\s*([\d\s]+)/i)
|
145
|
-
|
146
|
-
|
147
|
-
|
147
|
+
value = $1.chomp.split(/\s+/).map{ |elem| elem.to_i }
|
148
|
+
if ALL_PLAYER_ALL_ROUND_DEFS.include? definition_name
|
149
|
+
value.shift
|
150
|
+
else
|
151
|
+
value
|
148
152
|
end
|
149
|
-
flatten_if_single_element_array values
|
150
153
|
end
|
151
154
|
end
|
152
155
|
|
@@ -143,8 +143,16 @@ class MatchState < DelegateClass(String)
|
|
143
143
|
end.call
|
144
144
|
end
|
145
145
|
|
146
|
+
# @param game_def [GameDefinition] A game definition by which the actions can be interpreted
|
147
|
+
# and made more precise (bets marked by 'r' are converted into 'b' and checks marked by 'c'
|
148
|
+
# are converted to 'k').
|
146
149
|
# @return [Array<Array<PokerAction>>] The sequence of betting actions.
|
147
|
-
def betting_sequence
|
150
|
+
def betting_sequence(game_def=nil)
|
151
|
+
if game_def
|
152
|
+
every_action(game_def) unless @precise_betting_sequence
|
153
|
+
return @precise_betting_sequence
|
154
|
+
end
|
155
|
+
|
148
156
|
@betting_sequence ||= if @betting_sequence_string.empty?
|
149
157
|
[[]]
|
150
158
|
else
|
@@ -270,6 +278,7 @@ class MatchState < DelegateClass(String)
|
|
270
278
|
|
271
279
|
@next_to_act = game_def.first_player_positions.first
|
272
280
|
@player_acting_sequence = []
|
281
|
+
@precise_betting_sequence = []
|
273
282
|
@min_wager_by = game_def.min_wagers.first
|
274
283
|
|
275
284
|
walk_over_betting_sequence!(game_def)
|
@@ -344,6 +353,7 @@ class MatchState < DelegateClass(String)
|
|
344
353
|
game_def.first_player_positions[current_round]
|
345
354
|
)
|
346
355
|
@player_acting_sequence << []
|
356
|
+
@precise_betting_sequence << []
|
347
357
|
last_round = current_round
|
348
358
|
|
349
359
|
walk_over_actions!(actions_per_round, game_def, last_round, current_round)
|
@@ -365,7 +375,7 @@ class MatchState < DelegateClass(String)
|
|
365
375
|
game_def.min_wagers[current_round]
|
366
376
|
)
|
367
377
|
|
368
|
-
|
378
|
+
@precise_betting_sequence.last << PokerAction.new(
|
369
379
|
action.to_s(
|
370
380
|
pot_gained_chips: @players.inject(0) { |sum, player| sum += player.contributions[current_round].to_i } > 0,
|
371
381
|
player_sees_wager: @players.amount_to_call(acting_player_position) > 0
|
@@ -373,11 +383,11 @@ class MatchState < DelegateClass(String)
|
|
373
383
|
cost: cost
|
374
384
|
)
|
375
385
|
|
376
|
-
adjust_min_wager!(
|
386
|
+
adjust_min_wager!(@precise_betting_sequence.last.last, acting_player_position)
|
377
387
|
|
378
|
-
@players[acting_player_position].append_action!(
|
388
|
+
@players[acting_player_position].append_action!(@precise_betting_sequence.last.last, current_round)
|
379
389
|
|
380
|
-
yield
|
390
|
+
yield @precise_betting_sequence.last.last, current_round, acting_player_position if block_given?
|
381
391
|
end
|
382
392
|
|
383
393
|
self
|
data/spec/match_state_spec.rb
CHANGED
@@ -295,6 +295,42 @@ describe MatchState do
|
|
295
295
|
)
|
296
296
|
end
|
297
297
|
end
|
298
|
+
it 'works with a game definition and provides more a precise result' do
|
299
|
+
MatchState.parse(
|
300
|
+
"#{MatchState::LABEL}:0:0:ccr20cc/r50fr100c/cc/cc:AhKs||"
|
301
|
+
).betting_sequence(
|
302
|
+
GameDefinition.new(
|
303
|
+
first_player_positions: [3, 2, 2, 2],
|
304
|
+
chip_stacks: [200, 200, 200],
|
305
|
+
blinds: [10, 0, 5],
|
306
|
+
raise_sizes: [10]*4,
|
307
|
+
number_of_ranks: 3
|
308
|
+
)
|
309
|
+
).must_equal [
|
310
|
+
[
|
311
|
+
PokerAction.new(PokerAction::CALL),
|
312
|
+
PokerAction.new(PokerAction::CHECK),
|
313
|
+
PokerAction.new("#{PokerAction::RAISE}20"),
|
314
|
+
PokerAction.new(PokerAction::CALL),
|
315
|
+
PokerAction.new(PokerAction::CALL)
|
316
|
+
],
|
317
|
+
[
|
318
|
+
PokerAction.new("#{PokerAction::BET}50"),
|
319
|
+
PokerAction.new(PokerAction::FOLD),
|
320
|
+
PokerAction.new("#{PokerAction::RAISE}100"),
|
321
|
+
PokerAction.new(PokerAction::CALL)
|
322
|
+
|
323
|
+
],
|
324
|
+
[
|
325
|
+
PokerAction.new(PokerAction::CHECK),
|
326
|
+
PokerAction.new(PokerAction::CHECK)
|
327
|
+
],
|
328
|
+
[
|
329
|
+
PokerAction.new(PokerAction::CHECK),
|
330
|
+
PokerAction.new(PokerAction::CHECK)
|
331
|
+
]
|
332
|
+
]
|
333
|
+
end
|
298
334
|
end
|
299
335
|
describe '#players_at_hand_start' do
|
300
336
|
it 'returns HandPlayers with states set at the beginning of the hand' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acpc_poker_types
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.2.
|
4
|
+
version: 7.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin Morrill
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: process_runner
|