acpc_poker_types 7.2.0 → 7.2.1

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: 6f24714536d94582ffb4a4928f906807a9f25d78
4
- data.tar.gz: 2982a1f06ee0b343448a8983d0c1a9bf6c083ad6
3
+ metadata.gz: 0e7db77dcac1bb6a8abf691890b233c4989f3a3e
4
+ data.tar.gz: 7c5962907fc4347379e80c716207efb468db404c
5
5
  SHA512:
6
- metadata.gz: 70a557cd1d3932d9dee54c9184dce445b701e3ac46633f7f9d48cd3d1424c4ee8c8acf8ee5dffa3a6b37ea54e1859ed90de534b18884df33571bfa28bc0b7ee5
7
- data.tar.gz: dd2ca29159f8330e67a9bbbed5a4bc4ad1a0ac731116b1bca7793b885db1e638d16ae8b1f7ff92c7483d04f894f6cbc2aa8e1ba6992901c5d9607849f6045416
6
+ metadata.gz: cbf955f892695ed3ef36e87b61cb374e01869429decd6b0c78611269f21c5a6a12e668ef91542460a185668edea981ad81da7b8c86bf77add96f77322ebba389
7
+ data.tar.gz: d284cf1b711a6ea1d4100a9903cf949a6f62a85b9121d701b0d43935dbe3a187b336636ff060fd10b44d60bfcaa02999037d98e10d1fe8802a7faa59636933a4
@@ -87,26 +87,22 @@ class HandPlayer
87
87
  else
88
88
  l_actions << PokerAction.new(PokerAction::CHECK)
89
89
  end
90
- if !wager_illegal && stack > amount_to_call.to_r
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
90
+ if !wager_illegal && wager_allowed_by_stack?(amount_to_call)
91
+ min_wager_by_cost = [min_wager_by + amount_to_call.to_r, stack].min
92
+
93
+ add_wager_actions = ->(wager_character) do
94
+ l_actions << PokerAction.new(wager_character, cost: min_wager_by_cost)
95
+ if all_in_allowed?(betting_type, min_wager_by_cost)
96
+ l_actions << PokerAction.new(wager_character, cost: stack)
97
+ end
98
+ end
93
99
 
94
100
  if (
95
- amount_to_call.to_r > 0 ||
96
- (
97
- contributions.length > in_round &&
98
- contributions[in_round] > 0
99
- )
101
+ amount_to_call.to_r > 0 || contributions[in_round].to_i > 0
100
102
  )
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
103
+ add_wager_actions.call(PokerAction::RAISE)
105
104
  else
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
105
+ add_wager_actions.call(PokerAction::BET)
110
106
  end
111
107
  end
112
108
 
@@ -141,5 +137,13 @@ class HandPlayer
141
137
  def round
142
138
  @actions.length - 1
143
139
  end
140
+
141
+ def wager_allowed_by_stack?(amount_to_call)
142
+ stack > amount_to_call.to_r
143
+ end
144
+
145
+ def all_in_allowed?(betting_type, min_wager_by_cost)
146
+ betting_type != GameDefinition::BETTING_TYPES[:limit] && min_wager_by_cost < stack
147
+ end
144
148
  end
145
149
  end
@@ -81,7 +81,10 @@ class HandPlayerGroup < DelegateClass(Array)
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) >= game_def.max_number_of_wagers[round],
84
+ wager_illegal: (
85
+ game_def.max_number_of_wagers[round] &&
86
+ num_wagers(round) >= game_def.max_number_of_wagers[round]
87
+ ),
85
88
  betting_type: game_def.betting_type,
86
89
  min_wager_by: min_wager_by
87
90
  )
@@ -1,3 +1,3 @@
1
1
  module AcpcPokerTypes
2
- VERSION = '7.2.0'
2
+ VERSION = '7.2.1'
3
3
  end
@@ -944,6 +944,48 @@ describe MatchState do
944
944
 
945
945
  patient.must_equal x_actions
946
946
 
947
+ patient.map { |action| action.cost }.must_equal x_actions.map { |action| action.cost }
948
+ end
949
+ it 'should work properly in no-limit after an opponent has bet' do
950
+ game_definition = GameDefinition.parse_file(AcpcDealer::GAME_DEFINITION_FILE_PATHS[2][:nolimit])
951
+
952
+ patient = MatchState.parse("MATCHSTATE:0:0:r9550:Jh7d|").legal_actions(
953
+ game_definition
954
+ )
955
+
956
+ blind = 100
957
+ to_call = 9550 - blind
958
+ to_all_in = game_definition.chip_stacks[0] - blind
959
+
960
+ x_actions = [
961
+ PokerAction.new(PokerAction::CALL, cost: to_call),
962
+ PokerAction.new(PokerAction::FOLD, cost: 0),
963
+ PokerAction.new(PokerAction::RAISE, cost: 2 * to_call),
964
+ PokerAction.new(PokerAction::RAISE, cost: to_all_in)
965
+ ]
966
+
967
+ patient.must_equal x_actions
968
+
969
+ patient.map { |action| action.cost }.must_equal x_actions.map { |action| action.cost }
970
+ end
971
+ it 'should not error' do
972
+ game_definition = GameDefinition.parse_file(AcpcDealer::GAME_DEFINITION_FILE_PATHS[2][:nolimit])
973
+
974
+ patient = MatchState.parse("MATCHSTATE:0:0:r9550c/:Jh7d|/QhQsJs").legal_actions(
975
+ game_definition
976
+ )
977
+
978
+ blind = 100
979
+ to_all_in = game_definition.chip_stacks[0] - 9550
980
+
981
+ x_actions = [
982
+ PokerAction.new(PokerAction::CHECK, cost: 0),
983
+ PokerAction.new(PokerAction::BET, cost: game_definition.min_wagers[1]),
984
+ PokerAction.new(PokerAction::BET, cost: to_all_in)
985
+ ]
986
+
987
+ patient.must_equal x_actions
988
+
947
989
  patient.map { |action| action.cost }.must_equal x_actions.map { |action| action.cost }
948
990
  end
949
991
  end
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.2.0
4
+ version: 7.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dustin Morrill