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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f33148cb5695cca1690278ba5acc735404dc15f
4
- data.tar.gz: 7007a378e311daa494788d1c5d2355b965ec00b9
3
+ metadata.gz: 6f24714536d94582ffb4a4928f906807a9f25d78
4
+ data.tar.gz: 2982a1f06ee0b343448a8983d0c1a9bf6c083ad6
5
5
  SHA512:
6
- metadata.gz: 39b67ec1ac2532478e08cf4c26c8e51e990302b22b6c2826d428b4776ff0d6237b25463b11972044c566c108f449994cc0c447d6b4889809d7ca46ce0228c144
7
- data.tar.gz: 2c2ccfc8eaba441ef3bc615005dd3f5c2d30cd69680eda6f0b071582706b6bec9be3aa572b5015e3951b2cdc2d1dd37a5f77327a1a715fb3d07511a30ca42be3
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 => 'limit',
80
- :nolimit => '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 << BETTING_TYPES[@betting_type] if @betting_type
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 = 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 wager will be returned in the list.
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
- l_actions << if (
89
- (contributions.length > in_round) &&
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[in_round] > 0 ||
92
- amount_to_call.to_r > 0
97
+ contributions.length > in_round &&
98
+ contributions[in_round] > 0
93
99
  )
94
100
  )
95
- PokerAction.new(PokerAction::RAISE, cost: stack - amount_to_call.to_r)
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: stack - amount_to_call.to_r)
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, max_num_wagers)
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) >= max_num_wagers
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
@@ -328,7 +328,8 @@ class MatchState < DelegateClass(String)
328
328
  players(game_def).legal_actions(
329
329
  next_to_act(game_def),
330
330
  round,
331
- game_def.max_number_of_wagers[round]
331
+ game_def,
332
+ min_wager_by(game_def)
332
333
  )
333
334
  end
334
335
 
@@ -1,3 +1,3 @@
1
1
  module AcpcPokerTypes
2
- VERSION = '7.1.5'
2
+ VERSION = '7.2.0'
3
3
  end
@@ -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
- 10
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
- MatchState.parse("MATCHSTATE:0:3:crc/rrrr:Qh9s|/KdQc7c").legal_actions(
886
+
887
+ patient = MatchState.parse("MATCHSTATE:0:3:crc/rrrr:Qh9s|/KdQc7c").legal_actions(
887
888
  game_definition
888
- ).must_equal [
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
- MatchState.parse("MATCHSTATE:0:1:rrc/:Qh3c|/Js4c9d").legal_actions(
902
+
903
+ patient = MatchState.parse("MATCHSTATE:0:1:rrc/:Qh3c|/Js4c9d").legal_actions(
896
904
  game_definition
897
- ).must_equal [
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
- ).must_equal [
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 = 10
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,
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: 7.1.5
4
+ version: 7.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dustin Morrill