acpc_poker_types 7.1.5 → 7.2.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.
- checksums.yaml +4 -4
- data/lib/acpc_poker_types/game_definition.rb +7 -4
- data/lib/acpc_poker_types/hand_player.rb +20 -8
- data/lib/acpc_poker_types/hand_player_group.rb +4 -2
- data/lib/acpc_poker_types/match_state.rb +2 -1
- data/lib/acpc_poker_types/version.rb +1 -1
- data/spec/match_state_spec.rb +44 -7
- data/spec/players_at_the_table_spec.rb +1 -1
- 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: 6f24714536d94582ffb4a4928f906807a9f25d78
|
4
|
+
data.tar.gz: 2982a1f06ee0b343448a8983d0c1a9bf6c083ad6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70a557cd1d3932d9dee54c9184dce445b701e3ac46633f7f9d48cd3d1424c4ee8c8acf8ee5dffa3a6b37ea54e1859ed90de534b18884df33571bfa28bc0b7ee5
|
7
|
+
data.tar.gz: dd2ca29159f8330e67a9bbbed5a4bc4ad1a0ac731116b1bca7793b885db1e638d16ae8b1f7ff92c7483d04f894f6cbc2aa8e1ba6992901c5d9607849f6045416
|
@@ -74,10 +74,13 @@ module AcpcPokerTypes
|
|
74
74
|
:@number_of_ranks => AcpcPokerTypes::Rank::DOMAIN.length
|
75
75
|
}
|
76
76
|
|
77
|
+
LIMIT = 'limit'
|
78
|
+
NO_LIMIT = 'nolimit'
|
79
|
+
|
77
80
|
# @return [Hash] Betting types understood by this class.
|
78
81
|
BETTING_TYPES = {
|
79
|
-
:limit =>
|
80
|
-
:nolimit =>
|
82
|
+
:limit => LIMIT,
|
83
|
+
:nolimit => NO_LIMIT
|
81
84
|
}
|
82
85
|
|
83
86
|
DEFINITIONS = {
|
@@ -198,7 +201,7 @@ module AcpcPokerTypes
|
|
198
201
|
def to_a
|
199
202
|
@array ||= -> do
|
200
203
|
list_of_lines = []
|
201
|
-
list_of_lines <<
|
204
|
+
list_of_lines << @betting_type if @betting_type
|
202
205
|
list_of_lines << "stack = #{@chip_stacks.join(' ')}" unless @chip_stacks.empty?
|
203
206
|
list_of_lines << "numPlayers = #{@number_of_players}" if @number_of_players
|
204
207
|
list_of_lines << "blind = #{@blinds.join(' ')}" unless @blinds.empty?
|
@@ -272,7 +275,7 @@ module AcpcPokerTypes
|
|
272
275
|
type = type_and_name.first
|
273
276
|
name = type_and_name[1]
|
274
277
|
if line.match(/\b#{name}\b/i)
|
275
|
-
@betting_type =
|
278
|
+
@betting_type = name
|
276
279
|
true
|
277
280
|
else
|
278
281
|
false
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'acpc_poker_types/chip_stack'
|
2
2
|
require 'acpc_poker_types/hand'
|
3
3
|
require 'acpc_poker_types/poker_action'
|
4
|
+
require 'acpc_poker_types/game_definition'
|
4
5
|
|
5
6
|
require 'contextual_exceptions'
|
6
7
|
using ContextualExceptions::ClassRefinement
|
@@ -69,11 +70,13 @@ class HandPlayer
|
|
69
70
|
# @param amount_to_call [#to_r] The amount to call for this player
|
70
71
|
# @param wager_illegal [Boolean]
|
71
72
|
# @return [Array<PokerAction>] The list of legal actions for this player. If a wager is legal,
|
72
|
-
# the largest possible
|
73
|
+
# the smallest and largest possible wagers will be returned in the list.
|
73
74
|
def legal_actions(
|
74
75
|
in_round: round,
|
75
76
|
amount_to_call: ChipStack.new(0),
|
76
|
-
wager_illegal: false
|
77
|
+
wager_illegal: false,
|
78
|
+
betting_type: GameDefinition::BETTING_TYPES[:limit],
|
79
|
+
min_wager_by: ChipStack.new(1)
|
77
80
|
)
|
78
81
|
l_actions = []
|
79
82
|
return l_actions if inactive?
|
@@ -85,16 +88,25 @@ class HandPlayer
|
|
85
88
|
l_actions << PokerAction.new(PokerAction::CHECK)
|
86
89
|
end
|
87
90
|
if !wager_illegal && stack > amount_to_call.to_r
|
88
|
-
|
89
|
-
|
91
|
+
max_wager_by = stack - amount_to_call.to_r
|
92
|
+
min_wager_by_adjusted = [min_wager_by + amount_to_call.to_r, max_wager_by].min
|
93
|
+
|
94
|
+
if (
|
95
|
+
amount_to_call.to_r > 0 ||
|
90
96
|
(
|
91
|
-
contributions
|
92
|
-
|
97
|
+
contributions.length > in_round &&
|
98
|
+
contributions[in_round] > 0
|
93
99
|
)
|
94
100
|
)
|
95
|
-
PokerAction.new(PokerAction::RAISE, cost:
|
101
|
+
l_actions << PokerAction.new(PokerAction::RAISE, cost: min_wager_by_adjusted)
|
102
|
+
unless betting_type == GameDefinition::BETTING_TYPES[:limit] || min_wager_by_adjusted == max_wager_by
|
103
|
+
l_actions << PokerAction.new(PokerAction::RAISE, cost: max_wager_by)
|
104
|
+
end
|
96
105
|
else
|
97
|
-
PokerAction.new(PokerAction::BET, cost:
|
106
|
+
l_actions << PokerAction.new(PokerAction::BET, cost: min_wager_by_adjusted)
|
107
|
+
unless betting_type == GameDefinition::BETTING_TYPES[:limit] || min_wager_by_adjusted == max_wager_by
|
108
|
+
l_actions << PokerAction.new(PokerAction::BET, cost: max_wager_by)
|
109
|
+
end
|
98
110
|
end
|
99
111
|
end
|
100
112
|
|
@@ -77,11 +77,13 @@ class HandPlayerGroup < DelegateClass(Array)
|
|
77
77
|
end
|
78
78
|
|
79
79
|
# @return [Array<PokerAction>] The legal actions for the next player to act.
|
80
|
-
def legal_actions(acting_player_position, round,
|
80
|
+
def legal_actions(acting_player_position, round, game_def, min_wager_by)
|
81
81
|
@players[acting_player_position].legal_actions(
|
82
82
|
in_round: round,
|
83
83
|
amount_to_call: amount_to_call(acting_player_position),
|
84
|
-
wager_illegal: num_wagers(round) >=
|
84
|
+
wager_illegal: num_wagers(round) >= game_def.max_number_of_wagers[round],
|
85
|
+
betting_type: game_def.betting_type,
|
86
|
+
min_wager_by: min_wager_by
|
85
87
|
)
|
86
88
|
end
|
87
89
|
end
|
data/spec/match_state_spec.rb
CHANGED
@@ -222,7 +222,7 @@ describe MatchState do
|
|
222
222
|
log_description.results_file_path,
|
223
223
|
log_description.player_names,
|
224
224
|
AcpcDealer::DEALER_DIRECTORY,
|
225
|
-
|
225
|
+
5
|
226
226
|
)
|
227
227
|
match.for_every_seat! do |seat|
|
228
228
|
match.for_every_hand! do
|
@@ -883,31 +883,68 @@ describe MatchState do
|
|
883
883
|
describe '#legal_actions' do
|
884
884
|
it 'should work properly when facing a wager' do
|
885
885
|
game_definition = GameDefinition.parse_file(AcpcDealer::GAME_DEFINITION_FILE_PATHS[2][:limit])
|
886
|
-
|
886
|
+
|
887
|
+
patient = MatchState.parse("MATCHSTATE:0:3:crc/rrrr:Qh9s|/KdQc7c").legal_actions(
|
887
888
|
game_definition
|
888
|
-
)
|
889
|
+
)
|
890
|
+
|
891
|
+
x_actions = [
|
889
892
|
PokerAction.new(PokerAction::CALL, cost: game_definition.min_wagers[1]),
|
890
893
|
PokerAction.new(PokerAction::FOLD)
|
891
894
|
]
|
895
|
+
|
896
|
+
patient.must_equal x_actions
|
897
|
+
|
898
|
+
patient.map { |action| action.cost }.must_equal x_actions.map { |action| action.cost }
|
892
899
|
end
|
893
900
|
it 'should work properly when a new round begins' do
|
894
901
|
game_definition = GameDefinition.parse_file(AcpcDealer::GAME_DEFINITION_FILE_PATHS[2][:limit])
|
895
|
-
|
902
|
+
|
903
|
+
patient = MatchState.parse("MATCHSTATE:0:1:rrc/:Qh3c|/Js4c9d").legal_actions(
|
896
904
|
game_definition
|
897
|
-
)
|
905
|
+
)
|
906
|
+
|
907
|
+
x_actions = [
|
898
908
|
PokerAction.new(PokerAction::CHECK, cost: 0),
|
899
909
|
PokerAction.new(PokerAction::BET, cost: game_definition.min_wagers[1])
|
900
910
|
]
|
911
|
+
|
912
|
+
patient.must_equal x_actions
|
913
|
+
|
914
|
+
patient.map { |action| action.cost }.must_equal x_actions.map { |action| action.cost }
|
901
915
|
end
|
902
916
|
it 'should work properly when a new round begins and the other players check' do
|
903
917
|
game_definition = GameDefinition.parse_file(AcpcDealer::GAME_DEFINITION_FILE_PATHS[2][:limit])
|
904
918
|
|
905
|
-
MatchState.parse("MATCHSTATE:1:0:cc/rrrrc/rrc/c:|2hQc/QhQsJs/2s/Kh").legal_actions(
|
919
|
+
patient = MatchState.parse("MATCHSTATE:1:0:cc/rrrrc/rrc/c:|2hQc/QhQsJs/2s/Kh").legal_actions(
|
906
920
|
game_definition
|
907
|
-
)
|
921
|
+
)
|
922
|
+
|
923
|
+
x_actions = [
|
908
924
|
PokerAction.new(PokerAction::CHECK, cost: 0),
|
909
925
|
PokerAction.new(PokerAction::BET, cost: game_definition.min_wagers[3])
|
910
926
|
]
|
927
|
+
|
928
|
+
patient.must_equal x_actions
|
929
|
+
|
930
|
+
patient.map { |action| action.cost }.must_equal x_actions.map { |action| action.cost }
|
931
|
+
end
|
932
|
+
it 'should work properly after an opponent has bet in a new round' do
|
933
|
+
game_definition = GameDefinition.parse_file(AcpcDealer::GAME_DEFINITION_FILE_PATHS[2][:limit])
|
934
|
+
|
935
|
+
patient = MatchState.parse("MATCHSTATE:1:0:cc/crrrc/r:|2hQc/QhQsJs/2s").legal_actions(
|
936
|
+
game_definition
|
937
|
+
)
|
938
|
+
|
939
|
+
x_actions = [
|
940
|
+
PokerAction.new(PokerAction::CALL, cost: game_definition.min_wagers[2]),
|
941
|
+
PokerAction.new(PokerAction::FOLD, cost: 0),
|
942
|
+
PokerAction.new(PokerAction::RAISE, cost: 2 * game_definition.min_wagers[2])
|
943
|
+
]
|
944
|
+
|
945
|
+
patient.must_equal x_actions
|
946
|
+
|
947
|
+
patient.map { |action| action.cost }.must_equal x_actions.map { |action| action.cost }
|
911
948
|
end
|
912
949
|
end
|
913
950
|
end
|
@@ -17,7 +17,7 @@ describe PlayersAtTheTable do
|
|
17
17
|
# Careful though, even 10 hands takes about three seconds,
|
18
18
|
# and it scales slightly less than linearly. 120 takes
|
19
19
|
# about 30 seconds.
|
20
|
-
num_hands =
|
20
|
+
num_hands = 5
|
21
21
|
MatchLog.all.each do |log_description|
|
22
22
|
@match = DealerData::PokerMatchData.parse_files(
|
23
23
|
log_description.actions_file_path,
|