acpc_poker_match_state 0.0.2 → 0.0.3

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.
Files changed (102) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +7 -11
  3. data/acpc_poker_match_state.gemspec +5 -4
  4. data/lib/acpc_poker_match_state/players_at_the_table.rb +3 -6
  5. data/lib/acpc_poker_match_state/version.rb +1 -1
  6. data/spec/match_state_transition_spec.rb +38 -38
  7. data/spec/players_at_the_table_spec.rb +155 -584
  8. data/spec/support/spec_helper.rb +27 -8
  9. metadata +43 -239
  10. data/spec/coverage/assets/0.5.3/app.js +0 -88
  11. data/spec/coverage/assets/0.5.3/fancybox/blank.gif +0 -0
  12. data/spec/coverage/assets/0.5.3/fancybox/fancy_close.png +0 -0
  13. data/spec/coverage/assets/0.5.3/fancybox/fancy_loading.png +0 -0
  14. data/spec/coverage/assets/0.5.3/fancybox/fancy_nav_left.png +0 -0
  15. data/spec/coverage/assets/0.5.3/fancybox/fancy_nav_right.png +0 -0
  16. data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_e.png +0 -0
  17. data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_n.png +0 -0
  18. data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_ne.png +0 -0
  19. data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_nw.png +0 -0
  20. data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_s.png +0 -0
  21. data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_se.png +0 -0
  22. data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_sw.png +0 -0
  23. data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_w.png +0 -0
  24. data/spec/coverage/assets/0.5.3/fancybox/fancy_title_left.png +0 -0
  25. data/spec/coverage/assets/0.5.3/fancybox/fancy_title_main.png +0 -0
  26. data/spec/coverage/assets/0.5.3/fancybox/fancy_title_over.png +0 -0
  27. data/spec/coverage/assets/0.5.3/fancybox/fancy_title_right.png +0 -0
  28. data/spec/coverage/assets/0.5.3/fancybox/fancybox-x.png +0 -0
  29. data/spec/coverage/assets/0.5.3/fancybox/fancybox-y.png +0 -0
  30. data/spec/coverage/assets/0.5.3/fancybox/fancybox.png +0 -0
  31. data/spec/coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.css +0 -363
  32. data/spec/coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.pack.js +0 -44
  33. data/spec/coverage/assets/0.5.3/favicon_green.png +0 -0
  34. data/spec/coverage/assets/0.5.3/favicon_red.png +0 -0
  35. data/spec/coverage/assets/0.5.3/favicon_yellow.png +0 -0
  36. data/spec/coverage/assets/0.5.3/highlight.css +0 -129
  37. data/spec/coverage/assets/0.5.3/highlight.pack.js +0 -1
  38. data/spec/coverage/assets/0.5.3/jquery-1.6.2.min.js +0 -18
  39. data/spec/coverage/assets/0.5.3/jquery.dataTables.min.js +0 -152
  40. data/spec/coverage/assets/0.5.3/jquery.timeago.js +0 -141
  41. data/spec/coverage/assets/0.5.3/jquery.url.js +0 -174
  42. data/spec/coverage/assets/0.5.3/loading.gif +0 -0
  43. data/spec/coverage/assets/0.5.3/magnify.png +0 -0
  44. data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  45. data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  46. data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  47. data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  48. data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  49. data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  50. data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  51. data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  52. data/spec/coverage/assets/0.5.3/smoothness/images/ui-icons_222222_256x240.png +0 -0
  53. data/spec/coverage/assets/0.5.3/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  54. data/spec/coverage/assets/0.5.3/smoothness/images/ui-icons_454545_256x240.png +0 -0
  55. data/spec/coverage/assets/0.5.3/smoothness/images/ui-icons_888888_256x240.png +0 -0
  56. data/spec/coverage/assets/0.5.3/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  57. data/spec/coverage/assets/0.5.3/smoothness/jquery-ui-1.8.4.custom.css +0 -295
  58. data/spec/coverage/assets/0.5.3/stylesheet.css +0 -383
  59. data/spec/coverage/assets/0.7.1/application.css +0 -1110
  60. data/spec/coverage/assets/0.7.1/application.js +0 -626
  61. data/spec/coverage/assets/0.7.1/fancybox/blank.gif +0 -0
  62. data/spec/coverage/assets/0.7.1/fancybox/fancy_close.png +0 -0
  63. data/spec/coverage/assets/0.7.1/fancybox/fancy_loading.png +0 -0
  64. data/spec/coverage/assets/0.7.1/fancybox/fancy_nav_left.png +0 -0
  65. data/spec/coverage/assets/0.7.1/fancybox/fancy_nav_right.png +0 -0
  66. data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_e.png +0 -0
  67. data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_n.png +0 -0
  68. data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_ne.png +0 -0
  69. data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_nw.png +0 -0
  70. data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_s.png +0 -0
  71. data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_se.png +0 -0
  72. data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_sw.png +0 -0
  73. data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_w.png +0 -0
  74. data/spec/coverage/assets/0.7.1/fancybox/fancy_title_left.png +0 -0
  75. data/spec/coverage/assets/0.7.1/fancybox/fancy_title_main.png +0 -0
  76. data/spec/coverage/assets/0.7.1/fancybox/fancy_title_over.png +0 -0
  77. data/spec/coverage/assets/0.7.1/fancybox/fancy_title_right.png +0 -0
  78. data/spec/coverage/assets/0.7.1/fancybox/fancybox-x.png +0 -0
  79. data/spec/coverage/assets/0.7.1/fancybox/fancybox-y.png +0 -0
  80. data/spec/coverage/assets/0.7.1/fancybox/fancybox.png +0 -0
  81. data/spec/coverage/assets/0.7.1/favicon_green.png +0 -0
  82. data/spec/coverage/assets/0.7.1/favicon_red.png +0 -0
  83. data/spec/coverage/assets/0.7.1/favicon_yellow.png +0 -0
  84. data/spec/coverage/assets/0.7.1/loading.gif +0 -0
  85. data/spec/coverage/assets/0.7.1/magnify.png +0 -0
  86. data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  87. data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  88. data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  89. data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  90. data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  91. data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  92. data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  93. data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  94. data/spec/coverage/assets/0.7.1/smoothness/images/ui-icons_222222_256x240.png +0 -0
  95. data/spec/coverage/assets/0.7.1/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  96. data/spec/coverage/assets/0.7.1/smoothness/images/ui-icons_454545_256x240.png +0 -0
  97. data/spec/coverage/assets/0.7.1/smoothness/images/ui-icons_888888_256x240.png +0 -0
  98. data/spec/coverage/assets/0.7.1/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  99. data/spec/coverage/index.html +0 -553
  100. data/spec/players_at_the_table_integ_spec.rb +0 -240
  101. data/spec/support/model_test_helper.rb +0 -56
  102. data/spec/support/test_example.rb +0 -74
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6618d28c4865bcd57c7e77e4ee6b6d11fb5dad90
4
+ data.tar.gz: 35417f8b38e6a3ceeb9d0c33439a7f2188c73f47
5
+ SHA512:
6
+ metadata.gz: 1ecdb73fb76a72af30fcdfd3bd4a4268244ba555f9b9f034a80cef88da3c552bd5fef4da43c9a36aba8f2f7404b06f1b994af93edd85dfa9adcae35f44741269
7
+ data.tar.gz: a759861ac7d87f384dcf1087baa2b15cf28bb49d245444aaf0e37d5dd9739f7f4a76a83b9deceff73fc632f7b7483e8217dd12e36763073a780991ba63ea2829
data/Rakefile CHANGED
@@ -1,20 +1,16 @@
1
+ #!/usr/bin/env rake
1
2
  require 'bundler/gem_tasks'
2
3
  require 'rake'
3
- require 'rspec/core/rake_task'
4
+ require 'rake/testtask'
4
5
 
5
6
  require File.expand_path('../lib/acpc_poker_match_state/version', __FILE__)
6
7
  require File.expand_path('../tasks', __FILE__)
7
8
 
8
9
  include Tasks
9
10
 
10
- RSpec::Core::RakeTask.new(:spec) do |t|
11
- ruby_opts = "-w"
12
- end
13
-
14
- task :build => :spec do
15
- system "gem build acpc_poker_match_state.gemspec"
16
- end
17
-
18
- task :tag => :build do
19
- tag_gem_version AcpcPokerMatchState::VERSION
11
+ Rake::TestTask.new do |t|
12
+ t.libs << "lib" << 'spec/support'
13
+ t.test_files = FileList['spec/**/*_spec.rb']
14
+ t.verbose = true
15
+ t.warning = true
20
16
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.homepage = "https://github.com/dmorrill10/acpc_poker_match_state"
10
10
  s.summary = %q{ACPC Poker Match State}
11
11
  s.description = %q{Match state data manager.}
12
-
12
+
13
13
  s.add_dependency 'acpc_poker_types'
14
14
  s.add_dependency 'dmorrill10-utils'
15
15
 
@@ -19,10 +19,11 @@ Gem::Specification.new do |s|
19
19
  s.test_files = Dir.glob "spec/**/*"
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_development_dependency 'rspec'
23
- s.add_development_dependency 'mocha'
24
- s.add_development_dependency 'simplecov'
22
+ s.add_development_dependency 'turn'
23
+ s.add_development_dependency 'minitest'
25
24
  s.add_development_dependency 'acpc_dealer_data'
26
25
  s.add_development_dependency 'acpc_dealer'
27
26
  s.add_development_dependency 'awesome_print'
27
+ s.add_development_dependency 'pry'
28
+ s.add_development_dependency 'pry-rescue'
28
29
  end
@@ -83,7 +83,7 @@ class PlayersAtTheTable
83
83
 
84
84
  def next_player_to_act(state=@transition.next_state)
85
85
  return nil unless state && !hand_ended? && !active_players.empty?
86
-
86
+
87
87
  reference_position = if state.number_of_actions_this_round > 0
88
88
  position_relative_to_dealer player_who_acted_last
89
89
  else
@@ -386,6 +386,7 @@ class PlayersAtTheTable
386
386
  raise NoChipsToDistribute unless pot > 0
387
387
  raise NoPlayersToTakeChips unless non_folded_players.length > 0
388
388
 
389
+ # @todo This only works for Doyle's game where there are no side-pots.
389
390
  if 1 == non_folded_players.length
390
391
  non_folded_players.first.take_winnings! pot
391
392
  else
@@ -401,17 +402,13 @@ class PlayersAtTheTable
401
402
  hand_strength == strength_of_strongest_hand
402
403
  end.map { |player_with_hand_strength| player_with_hand_strength.first }
403
404
 
404
- amount_each_player_wins = (pot/winning_players.length).floor
405
+ amount_each_player_wins = pot/winning_players.length.to_r
405
406
  winning_players.each do |player|
406
407
  player.take_winnings! amount_each_player_wins
407
408
  end
408
-
409
- # @todo Keep track of chips remaining in the pot after splitting them if multiplayer
410
- #@value -= (amount_each_player_wins * winning_players.length).to_i
411
409
  end
412
410
  end
413
411
 
414
- # @todo This only works for Doyle's game where there are no side-pots.
415
412
  def pot
416
413
  chip_contributions.mapped_sum.sum
417
414
  end
@@ -1,3 +1,3 @@
1
1
  module AcpcPokerMatchState
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,7 +1,7 @@
1
1
 
2
- require File.expand_path('../support/spec_helper', __FILE__)
2
+ require_relative 'support/spec_helper'
3
3
 
4
- require File.expand_path('../../lib/acpc_poker_match_state/match_state_transition', __FILE__)
4
+ require_relative '../lib/acpc_poker_match_state/match_state_transition'
5
5
 
6
6
  describe MatchStateTransition do
7
7
 
@@ -11,92 +11,92 @@ describe MatchStateTransition do
11
11
 
12
12
  describe '#set_next_state!' do
13
13
  it 'assigns the new state to be the next state' do
14
- new_state = mock 'MatchState'
14
+ new_state = 'new match state'
15
15
 
16
16
  @patient.set_next_state! new_state
17
- @patient.next_state.should == new_state
17
+ @patient.next_state.must_equal new_state
18
18
  end
19
19
  it 'replaces the last state' do
20
- last_state = mock 'MatchState'
20
+ last_state = 'last match state'
21
21
 
22
22
  @patient.set_next_state! last_state
23
- @patient.last_state.should == nil
24
- @patient.next_state.should == last_state
23
+ @patient.last_state.must_equal nil
24
+ @patient.next_state.must_equal last_state
25
25
 
26
- next_state = mock 'MatchState'
26
+ next_state = 'new match state'
27
27
 
28
28
  @patient.set_next_state! next_state
29
- @patient.last_state.should == last_state
30
- @patient.next_state.should == next_state
31
- @patient.last_state.should_not be next_state
29
+ @patient.last_state.must_equal last_state
30
+ @patient.next_state.must_equal next_state
31
+ @patient.last_state.wont_be_same_as next_state
32
32
  end
33
33
  end
34
34
  describe '#new_round?' do
35
35
  it 'raises an exception if it is called before #next_state!' do
36
- expect do
36
+ -> do
37
37
  @patient.new_round?
38
- end.to raise_exception(MatchStateTransition::NoStateGiven)
38
+ end.must_raise(MatchStateTransition::NoStateGiven)
39
39
  end
40
40
  describe 'reports true' do
41
41
  it 'when given an initial state' do
42
- new_state = mock 'MatchState'
42
+ new_state = 'new match state'
43
43
 
44
- @patient.set_next_state!(new_state).new_round?.should == true
44
+ @patient.set_next_state!(new_state).new_round?.must_equal true
45
45
  end
46
46
  it 'when subsequently given a state with a later round' do
47
- initial_state = mock 'MatchState'
48
- initial_state.stubs(:round).returns(0)
47
+ initial_state = MiniTest::Mock.new
48
+ initial_state.expect :round, 0
49
49
 
50
50
  @patient.set_next_state! initial_state
51
51
 
52
- new_state = mock 'MatchState'
53
- new_state.stubs(:round).returns(1)
52
+ new_state = MiniTest::Mock.new
53
+ new_state.expect :round, 1
54
54
 
55
- @patient.set_next_state!(new_state).new_round?.should == true
55
+ @patient.set_next_state!(new_state).new_round?.must_equal true
56
56
  end
57
57
  it 'when subsequently given a state with an earlier round' do
58
- initial_state = mock 'MatchState'
59
- initial_state.stubs(:round).returns(1)
58
+ initial_state = MiniTest::Mock.new
59
+ initial_state.expect :round, 1
60
60
 
61
61
  @patient.set_next_state! initial_state
62
62
 
63
- new_state = mock 'MatchState'
64
- new_state.stubs(:round).returns(0)
63
+ new_state = MiniTest::Mock.new
64
+ new_state.expect :round, 0
65
65
 
66
- @patient.set_next_state!(new_state).new_round?.should == true
66
+ @patient.set_next_state!(new_state).new_round?.must_equal true
67
67
  end
68
68
  end
69
69
  it 'reports false when subsequently given a state with the same round' do
70
- initial_state = mock 'MatchState'
71
- initial_state.stubs(:round).returns(0)
70
+ initial_state = MiniTest::Mock.new
71
+ initial_state.expect :round, 0
72
72
 
73
73
  @patient.set_next_state! initial_state
74
74
 
75
- new_state = mock 'MatchState'
76
- new_state.stubs(:round).returns(0)
75
+ new_state = MiniTest::Mock.new
76
+ new_state.expect :round, 0
77
77
 
78
- @patient.set_next_state!(new_state).new_round?.should == false
78
+ @patient.set_next_state!(new_state).new_round?.must_equal false
79
79
  end
80
80
  end
81
81
  describe '#initial_state?' do
82
82
  it 'raises an exception if it is called before #next_state!' do
83
- expect do
83
+ -> do
84
84
  @patient.initial_state?
85
- end.to raise_exception(MatchStateTransition::NoStateGiven)
85
+ end.must_raise(MatchStateTransition::NoStateGiven)
86
86
  end
87
87
  it 'reports true when given a state that reports it is the first ' +
88
88
  'state of the first round' do
89
- new_state = mock 'MatchState'
90
- new_state.stubs(:first_state_of_first_round?).returns(true)
89
+ new_state = MiniTest::Mock.new
90
+ new_state.expect :first_state_of_first_round?, true
91
91
 
92
- @patient.set_next_state!(new_state).initial_state?.should == true
92
+ @patient.set_next_state!(new_state).initial_state?.must_equal true
93
93
  end
94
94
  it 'reports false when given a state that reports it is not the ' +
95
95
  'first state of the first round' do
96
- new_state = mock 'MatchState'
97
- new_state.stubs(:first_state_of_first_round?).returns(false)
96
+ new_state = MiniTest::Mock.new
97
+ new_state.expect :first_state_of_first_round?, false
98
98
 
99
- @patient.set_next_state!(new_state).initial_state?.should == false
99
+ @patient.set_next_state!(new_state).initial_state?.must_equal false
100
100
  end
101
101
  end
102
102
  end
@@ -1,128 +1,43 @@
1
1
 
2
2
  require File.expand_path('../support/spec_helper', __FILE__)
3
3
 
4
- require 'acpc_poker_types/game_definition'
4
+ require 'acpc_dealer'
5
+ require 'acpc_dealer_data'
5
6
 
6
7
  require File.expand_path('../../lib/acpc_poker_match_state/players_at_the_table', __FILE__)
7
8
 
8
9
  describe PlayersAtTheTable do
9
-
10
- INITIAL_STACK_SIZE = 2000
11
- SMALL_BET = 100
12
-
13
- describe '::seat_players' do
14
- describe 'raises an exception if it is given' do
15
- describe 'a user seat' do
16
- it 'that is out of bounds' do
17
- [-1, 2].each do |out_of_bounds_seat|
18
- player_list = init_two_player_list
19
- game_def = mock('GameDefinition')
20
- game_def.stubs(:number_of_players).returns(player_list.length)
21
- game_def.stubs(:chip_stacks).returns(player_list.map{|p| p.chip_stack})
22
- game_def.stubs(:min_wagers).returns([0])
23
-
24
- expect do
25
- PlayersAtTheTable.seat_players(
26
- game_def,
27
- player_list.map{|p| p.name},
28
- out_of_bounds_seat,
29
- 1
30
- )
31
- end.to raise_exception(PlayersAtTheTable::UsersSeatOutOfBounds)
32
- end
33
- player_list = init_two_player_list
34
- # Increment each player's seat in order to make sure no player is in seat zero
35
- player_list.map do |player|
36
- old_seat = player.seat
37
- player.stubs(:seat).returns(old_seat + 1)
38
- end
39
-
40
- Player.stubs(:create_players).returns(player_list)
41
-
42
- expect do
43
- PlayersAtTheTable.seat_players(
44
- mock('GameDefinition'),
45
- player_list.map{|p| p.name},
46
- 0,
47
- 1
48
- )
49
- end.to raise_exception(PlayersAtTheTable::UsersSeatOutOfBounds)
50
- end
51
- end
52
- end
53
- it 'works properly' do
54
- various_numbers_of_players do |number_of_players|
55
- player_list = init_vanilla_player_list(number_of_players)
56
-
57
- player_list.length.times do |users_seat|
58
- check_various_valid_creation_configurations(player_list,
59
- users_seat) { |example| }
60
- end
61
- end
62
- end
63
- end
64
10
  describe '#update!' do
65
- describe 'keeps track of player positions and stacks' do
66
- it 'after the initial state, before any actions' do
67
- pending 'This unit test is too complex to be useful or maintain for now'
68
-
69
- various_numbers_of_players do |number_of_players|
70
- number_of_players.times do |users_seat|
71
- player_list = init_vanilla_player_list(number_of_players)
72
-
73
- check_various_valid_initial_update_configurations(player_list,
74
- users_seat) { |example| }
75
- end
76
- end
77
- end
78
- describe 'in two player' do
79
- describe 'limit' do
80
- it 'after a non-terminal sequence of four actions' do
81
-
82
- pending 'This unit test is too complex to be useful or maintain for now'
83
-
84
- check_non_terminal_four_action_sequence { |example| }
85
- end
86
- describe 'after a terminal sequence of five actions the sequence' do
87
- it 'where the second player calls' do
88
-
89
- pending 'This unit test is too complex to be useful or maintain for now'
90
-
91
- check_non_terminal_four_action_sequence do |prev_example|
92
-
93
- match_state = prev_example.given.match_state
94
- players = prev_example.then.players
95
- player_acting_sequence = prev_example.then.player_acting_sequence
96
-
97
- player_who_acted_last = prev_example.then.next_player_to_act
98
- index_of_player_who_acted_last = players.index(player_who_acted_last)
99
-
100
- local_index_of_next_player_to_act = index_of_next_player_to_act(
101
- @initial_example.given.first_positions_relative_to_dealer[match_state.round],
102
- 2, players.length
103
- )
104
- next_player_to_act = players[local_index_of_next_player_to_act]
105
-
106
- player_acting_sequence.last << index_of_player_who_acted_last
107
-
108
- setup_actions_taken_this_hand! players, index_of_player_who_acted_last,
109
- match_state.round, match_state.last_action
110
-
111
- match_state.stubs(:list_of_hole_card_hands).returns(@hands)
112
-
113
- # Cause a showdown
114
-
115
- users_seat = match_state.position_relative_to_dealer
116
- @hands.each_index do |i|
117
- @hands[i].stubs(:empty?).returns(false)
118
-
119
- players[i].expects(:assign_cards!).with(@hands[i]) unless i == users_seat
120
- end
121
-
122
- prev_example = create_and_check_update_example match_state,
123
- players, player_acting_sequence, next_player_to_act,
124
- player_who_acted_last
125
- end
11
+ it "keeps track of state for a sequence of match states and actions in Doyle's game" do
12
+ # Change this number to do more or less thorough tests.
13
+ # Some interesting three player hands occur after 120
14
+ # Careful though, even 10 hands takes about five seconds,
15
+ # and it scales about linearly
16
+ num_hands = 10
17
+ match_logs.each do |log_description|
18
+ @match = PokerMatchData.parse_files(
19
+ log_description.actions_file_path,
20
+ log_description.results_file_path,
21
+ log_description.player_names,
22
+ AcpcDealer::DEALER_DIRECTORY,
23
+ num_hands
24
+ )
25
+ @match.for_every_seat! do |users_seat|
26
+
27
+ @patient = PlayersAtTheTable.seat_players(
28
+ @match.match_def.game_def,
29
+ (@match.players.map{ |player| player.name }),
30
+ users_seat,
31
+ num_hands
32
+ )
33
+
34
+ check_patient
35
+
36
+ @match.for_every_hand! do
37
+ @match.for_every_turn! do
38
+ @patient.update! @match.current_hand.current_match_state
39
+
40
+ check_patient
126
41
  end
127
42
  end
128
43
  end
@@ -130,493 +45,149 @@ describe PlayersAtTheTable do
130
45
  end
131
46
  end
132
47
 
133
- def check_non_terminal_four_action_sequence
134
- player_list = init_two_player_list
135
-
136
- check_various_valid_initial_update_configurations(player_list) do |prev_example|
137
-
138
- init_actions_taken_in_current_round player_list.length
139
-
140
- prev_example = check_initial_call! prev_example
141
-
142
- ###### Next turn, and next round
143
- action = prev_example.given.match_state.last_action
144
- player_acting_sequence = prev_example.then.player_acting_sequence
145
-
146
- # Update the round
147
- match_state = prev_example.given.match_state
148
- last_round = match_state.round
149
- match_state.stubs(:round).returns(1)
150
- match_state.stubs(:in_new_round?).with(last_round).returns(true)
151
-
152
- # Setup player who acted and will act next turn
153
- players = prev_example.then.players
154
-
155
- players.each do |player|
156
- player.expects(:start_next_round!)
48
+ def check_patient(patient=@patient)
49
+ patient.player_acting_sequence.must_equal @match.player_acting_sequence
50
+ patient.number_of_players.must_equal @match.players.length
51
+ check_last_action
52
+ check_next_to_act
53
+ check_last_turn
54
+ patient.opponents_cards_visible?.must_equal @match.opponents_cards_visible?
55
+ patient.reached_showdown?.must_equal @match.opponents_cards_visible?
56
+ patient.less_than_two_non_folded_players?.must_equal @match.non_folded_players.length < 2
57
+
58
+ if @match.current_hand
59
+ patient.hand_ended?.must_equal @match.current_hand.final_turn?
60
+ patient.match_ended?.must_equal (@match.final_hand? && @match.current_hand.final_turn?)
61
+ end
62
+ patient.last_hand?.must_equal (
63
+ if @match.final_hand?.nil?
64
+ false
65
+ else
66
+ @match.final_hand?
157
67
  end
68
+ )
69
+ patient.player_acting_sequence_string.must_equal @match.player_acting_sequence_string
70
+ patient.users_turn_to_act?.must_equal @match.users_turn_to_act?
71
+ check_betting_sequence(patient)
72
+ # @todo Test this eventually
73
+ # patient.min_wager.to_i.must_equal @min_wager.to_i
74
+ end
158
75
 
159
- player_who_acted_last = prev_example.then.next_player_to_act
160
- index_of_player_who_acted_last = players.index(player_who_acted_last)
161
-
162
- local_index_of_next_player_to_act = @initial_example.given.first_positions_relative_to_dealer[match_state.round]
163
- next_player_to_act = players[local_index_of_next_player_to_act]
164
-
165
- player_acting_sequence.last << index_of_player_who_acted_last
166
- player_acting_sequence << []
167
-
168
- # Since this is a new round
169
- @actions_taken_this_hand.each_index do |i|
170
- @actions_taken_this_hand[i] << []
76
+ def check_player_blind_relation(patient)
77
+ expected_player_blind_relation = @match.player_blind_relation
78
+ patient.player_blind_relation.each do |player, blind|
79
+ expected_player_and_blind = expected_player_blind_relation.to_a.find do |player_and_blind|
80
+ player_and_blind.first.seat == player.seat
171
81
  end
172
82
 
173
- setup_actions_taken_this_hand! players, index_of_player_who_acted_last,
174
- last_round, action
175
-
176
- prev_example = create_and_check_update_example match_state, players, player_acting_sequence,
177
- next_player_to_act, player_who_acted_last
178
-
179
- ####### Next turn
180
-
181
- match_state = prev_example.given.match_state
182
- match_state.stubs(:last_action).returns(action)
183
- match_state.stubs(:round).returns(1)
184
- match_state.stubs(:in_new_round?).with(match_state.round).returns(false)
83
+ expected_player = expected_player_and_blind.first
84
+ expected_blind = expected_player_and_blind.last
185
85
 
186
- # Setup player who acted and will act next turn
187
- players = prev_example.then.players
188
-
189
- player_who_acted_last = prev_example.then.next_player_to_act
190
- index_of_player_who_acted_last = players.index(player_who_acted_last)
191
-
192
- local_index_of_next_player_to_act = index_of_next_player_to_act(
193
- @initial_example.given.first_positions_relative_to_dealer[match_state.round],
194
- 1, players.length
195
- )
196
- next_player_to_act = players[local_index_of_next_player_to_act]
197
-
198
- player_acting_sequence.last << index_of_player_who_acted_last
199
-
200
- setup_actions_taken_this_hand! players, index_of_player_who_acted_last,
201
- match_state.round, action
202
-
203
- # Check result. Actions taken so far should be: cc/r
204
- prev_example = create_and_check_update_example match_state, players, player_acting_sequence,
205
- next_player_to_act, player_who_acted_last
206
-
207
- yield prev_example
86
+ player.close_enough?(expected_player).must_equal true
87
+ blind.must_equal expected_blind
208
88
  end
209
89
  end
210
- def check_initial_call!(prev_example)
211
- action = init_vanilla_action
212
-
213
- # Setup match state
214
- match_state = prev_example.given.match_state
215
- match_state.stubs(:last_action).returns(action)
216
- match_state.stubs(:in_new_round?).with(match_state.round).returns(false)
217
- match_state.stubs(:number_of_actions_this_round).returns(1)
218
- match_state.stubs(:number_of_actions_this_hand).returns(1)
219
-
220
- # Ensure players are active and have cards
221
- players = prev_example.then.players
222
- players.each_index do |i|
223
- player = players[i]
224
-
225
- player.stubs(:active?).returns(true)
226
- player.stubs(:folded?).returns(false)
227
- player.stubs(:hole_cards).returns(@hands[i])
90
+ def check_betting_sequence(patient)
91
+ patient_betting_sequence = patient.betting_sequence.map do |actions|
92
+ actions.map { |action| action.to_low_res_acpc }
228
93
  end
94
+ expected_betting_sequence = @match.betting_sequence.map do |actions|
95
+ actions.map { |action| action.to_low_res_acpc }
96
+ end
97
+ patient_betting_sequence.must_equal expected_betting_sequence
229
98
 
230
- # Setup player who acted and will act next turn
231
- player_who_acted_last = prev_example.then.next_player_to_act
232
- index_of_player_who_acted_last = players.index(player_who_acted_last)
233
-
234
- player_acting_sequence = [[index_of_player_who_acted_last]]
235
-
236
- setup_actions_taken_this_hand! players, index_of_player_who_acted_last,
237
- match_state.round, action
238
-
239
- next_player_to_act = players[index_of_next_player_to_act(
240
- @initial_example.given.first_positions_relative_to_dealer[0], 1,
241
- players.length
242
- )]
243
-
244
- # Check result. Actions taken so far should be: c
245
- create_and_check_update_example match_state, players,
246
- player_acting_sequence, next_player_to_act, player_who_acted_last
247
- end
248
- def check_various_valid_initial_update_configurations(player_list, users_seat=0)
249
- check_various_valid_creation_configurations(player_list,
250
- users_seat) do |prev_example|
251
- match_state = initial_vanilla_match_state prev_example.then.players,
252
- prev_example.given.users_seat
253
-
254
- opponent_hand = init_vanilla_hand
255
- @hands = [].fill opponent_hand, 0..(prev_example.then.number_of_players - 1)
256
- Hand.stubs(:new).returns(opponent_hand)
257
-
258
- @hands[@initial_example.given.users_seat] = match_state.users_hole_cards
259
-
260
- prev_example.then.players.each_index do |i|
261
- player = prev_example.then.players[i]
262
-
263
- player.stubs(:active?).returns(true)
264
-
265
- player.expects(:start_new_hand!).with(@initial_example.given.blinds[i],
266
- INITIAL_STACK_SIZE,
267
- @hands[i])
99
+ patient.betting_sequence_string.scan(/([a-z]\d*|\/)/).flatten.map do |action|
100
+ if action.match(/\//)
101
+ action
102
+ else
103
+ PokerAction.new(action).to_low_res_acpc
268
104
  end
269
-
270
- example = update_example match_state, prev_example.then.players, [[]],
271
- prev_example.then.players[prev_example.given.first_positions_relative_to_dealer[0]]
272
-
273
- @patient.update! example.given.match_state
274
-
275
- check_patient example.then
276
-
277
- yield example
105
+ end.join('').must_equal @match.betting_sequence_string
106
+ end
107
+ def check_last_action(patient=@patient)
108
+ if @match.current_hand && @match.current_hand.last_action
109
+ patient.player_who_acted_last.seat.must_equal @match.current_hand.last_action.seat
110
+ else
111
+ patient.player_who_acted_last.must_be_nil
278
112
  end
279
113
  end
280
- def check_various_valid_creation_configurations(player_list, users_seat=0)
281
- number_of_players = player_list.length
282
-
283
- example_first_positions = first_positions_relative_to_dealer(number_of_players)
284
-
285
- @initial_example = creation_example player_list, users_seat,
286
- example_first_positions
287
-
288
- game_def = mock 'GameDefinition'
289
- game_def.stubs(:first_positions_relative_to_dealer).returns(@initial_example.given.first_positions_relative_to_dealer)
290
- game_def.stubs(:blinds).returns(@initial_example.given.blinds)
291
- game_def.stubs(:min_wagers).returns([0])
292
-
293
- Player.stubs(:create_players).returns(@initial_example.given.players)
294
-
295
- @patient = PlayersAtTheTable.seat_players(
296
- game_def,
297
- @initial_example.given.players.map{|p| p.name},
298
- @initial_example.given.users_seat,
299
- 1
300
- )
301
-
302
- check_patient @initial_example.then
303
-
304
- yield @initial_example
114
+ def check_next_to_act(patient=@patient)
115
+ if @match.current_hand && @match.current_hand.next_action
116
+ patient.next_player_to_act.seat.must_equal @match.current_hand.next_action.seat
117
+ else
118
+ patient.next_player_to_act.must_be_nil
119
+ end
305
120
  end
306
- def index_of_next_player_to_act(first_position_relative_to_dealer_in_current_round,
307
- number_of_actions_in_current_round, number_of_players)
308
- (first_position_relative_to_dealer_in_current_round + number_of_actions_in_current_round) % number_of_players
121
+ def check_last_turn(patient=@patient)
122
+ return unless @match.current_hand && @match.current_hand.final_turn?
123
+ patient.players.players_close_enough?(@match.players).must_equal true
124
+ patient.user_player.close_enough?(@match.player).must_equal true
125
+ patient.opponents.players_close_enough?(@match.opponents).must_equal true
126
+ patient.non_folded_players.players_close_enough?(@match.non_folded_players).must_equal true
127
+ patient.active_players.players_close_enough?(@match.active_players).must_equal true
128
+ patient.player_with_dealer_button.close_enough?(@match.player_with_dealer_button).must_equal true
129
+ check_player_blind_relation(patient)
130
+ patient.chip_stacks.must_equal @match.chip_stacks
131
+ patient.chip_balances.must_equal @match.chip_balances
132
+ patient.chip_contributions.sum.must_equal @match.chip_contributions.sum
309
133
  end
310
- def create_and_check_update_example(match_state, players, player_acting_sequence, next_player_to_act,
311
- player_who_acted_last)
312
- example = update_example match_state, players, player_acting_sequence,
313
- next_player_to_act, player_who_acted_last
314
-
315
- # Initiate test
316
- @patient.update! example.given.match_state
317
-
318
- check_patient example.then
134
+ end
319
135
 
320
- example
136
+ class Array
137
+ def players_close_enough?(other_players)
138
+ return false if other_players.length != length
139
+ each_with_index do |player, index|
140
+ return false unless player.close_enough?(other_players[index])
141
+ end
142
+ true
321
143
  end
322
- def update_example(match_state, expected_players,
323
- expected_player_acting_sequence,
324
- next_player_to_act, player_who_acted_last=nil)
325
- example = init_players_at_the_table_example(
326
- "check update! when given matchstate #{match_state}",
327
- [:match_state])
328
-
329
- example.given.match_state = match_state
330
-
331
- example.then.players = expected_players
332
- example.then.round = match_state.round
333
- example.then.player_acting_sequence = expected_player_acting_sequence
334
- example.then.number_of_players = expected_players.length
335
- example.then.player_who_acted_last = player_who_acted_last
336
- example.then.next_player_to_act = next_player_to_act
337
-
338
- example
144
+ def reject_empty_elements
145
+ reject do |elem|
146
+ elem.empty?
147
+ end
339
148
  end
340
- def creation_example(player_list, users_seat, example_first_positions)
341
- example = init_players_at_the_table_example(
342
- "check creation for #{player_list.length}, where the user's " +
343
- "seat is #{users_seat}, and the first positions relative to " +
344
- "the dealer in each round are #{example_first_positions}",
345
- [:players, :users_seat, :first_positions_relative_to_dealer, :blinds])
346
-
347
- example.given.players = player_list
348
- example.given.users_seat = users_seat
349
- example.given.first_positions_relative_to_dealer = example_first_positions
350
- example.given.blinds = reverse_blinds player_list.length
149
+ end
351
150
 
352
- example.then.players = player_list
353
- example.then.round = nil
354
- example.then.player_acting_sequence = [[]]
355
- example.then.number_of_players = player_list.length
356
- example.then.player_who_acted_last = nil
357
- example.then.next_player_to_act = nil
151
+ class PokerAction
152
+ # @return [Hash] Map of specific to general actions to more specific actions (e.g. check to call and bet to raise).
153
+ LOW_RESOLUTION_ACTION_CONVERSION = {call: :call, raise: :raise, fold: :fold, check: :call, bet: :raise}
358
154
 
359
- example
155
+ def to_low_res_acpc
156
+ LEGAL_ACTIONS[LOW_RESOLUTION_ACTION_CONVERSION[@symbol]] + @modifier.to_s
157
+ end
158
+ end
159
+ class Player
160
+ def acpc_actions_taken_this_hand
161
+ acpc_actions = @actions_taken_this_hand.map do |actions_per_turn|
162
+ actions_per_turn.map { |action| action.to_low_res_acpc }
163
+ end
164
+ if acpc_actions.first.empty?
165
+ acpc_actions
166
+ else
167
+ acpc_actions.reject_empty_elements
168
+ end
360
169
  end
361
- def init_players_at_the_table_example(description, given_parameters)
362
- TestExample.new(
363
- description, {given: given_parameters,
364
- then: [:players, :round, :player_acting_sequence,
365
- :number_of_players, :player_who_acted_last,
366
- :next_player_to_act]})
367
- end
368
- def initial_vanilla_match_state(player_list, users_seat=0)
369
- match_state = mock 'MatchState'
370
-
371
- match_state.stubs(:number_of_actions_this_round).returns(0)
372
- match_state.stubs(:number_of_actions_this_hand).returns(0)
373
- match_state.stubs(:first_state_of_first_round?).returns(true)
374
- match_state.stubs(:position_relative_to_dealer).returns(users_seat)
375
- match_state.stubs(:round).returns(0)
376
-
377
- player_list.each do |player|
378
- player.stubs(:equals?).returns(false)
379
- player.stubs(:equals?).with(player).returns(true)
380
- end
381
-
382
- users_hand = init_vanilla_hand
383
- users_hand.stubs(:empty?).returns(false)
384
-
385
- match_state.stubs(:users_hole_cards).returns(users_hand)
386
-
387
- match_state
388
- end
389
- def init_vanilla_hand
390
- hand = mock 'Hand'
391
- hand.stubs(:empty?).returns(true)
392
-
393
- hand
394
- end
395
- def init_vanilla_action
396
- action = mock 'PokerAction'
397
- action.stubs(:to_acpc_character)
398
-
399
- action
400
- end
401
- def various_numbers_of_players
402
- 10.times do |i|
403
- yield i+2
404
- end
405
- end
406
- def init_vanilla_player_list(number_of_players)
407
- player_list = []
408
- number_of_players.times do |seat|
409
- player_list << init_vanilla_player(seat)
410
- end
411
-
412
- player_list
413
- end
414
- def init_two_player_list
415
- init_vanilla_player_list(2)
416
- end
417
- def init_vanilla_player(seat)
418
- player = mock('Player')
419
- player.stubs(:actions_taken_this_hand).returns([[]])
420
- player.stubs(:seat).returns(seat)
421
- player.stubs(:chip_stack).returns(INITIAL_STACK_SIZE)
422
- player.stubs(:active?).returns(true)
423
- player.stubs(:name).returns('player')
424
-
425
- player
426
- end
427
- def init_actions_taken_in_current_round(number_of_players)
428
- @actions_taken_this_hand = []
429
- number_of_players.times do |i|
430
- player_list = []
431
- @actions_taken_this_hand << [player_list]
432
- end
433
- end
434
- def blinds(number_of_players)
435
- hash = zero_blinds number_of_players
436
- hash[0] = SMALL_BET/2
437
- hash[1] = SMALL_BET
438
-
439
- hash
440
- end
441
- def reverse_blinds(number_of_players)
442
- hash = zero_blinds number_of_players
443
- hash[0] = SMALL_BET
444
- hash[1] = SMALL_BET/2
445
-
446
- hash
447
- end
448
- def zero_blinds(number_of_players)
449
- hash = {}
450
- number_of_players.times do |i|
451
- hash[i] = 0
452
- end
453
-
454
- hash
455
- end
456
- def first_positions_relative_to_dealer(number_of_rounds)
457
- [].fill 0, 0..(number_of_rounds - 1)
458
- end
459
- def setup_actions_taken_this_hand!(players, index_of_player_who_acted_last,
460
- round, action)
461
- actions_taken_this_hand_before_action_is_taken = []
462
- @actions_taken_this_hand.each_index do |i|
463
- actions_taken_this_hand_before_action_is_taken << []
464
- @actions_taken_this_hand[i].each do |current_action|
465
- actions_taken_this_hand_before_action_is_taken[i] << current_action.dup
466
- end
467
-
468
- players[i].stubs(:actions_taken_this_hand).returns(actions_taken_this_hand_before_action_is_taken[i])
469
- end
470
-
471
- @actions_taken_this_hand[index_of_player_who_acted_last][round] << action
472
-
473
- action_appended = states('action_appended').starts_as('no')
474
- players[index_of_player_who_acted_last].expects(:take_action!).with(action).then(action_appended.is('yes'))
475
- players.each_index do |i|
476
- players[i].stubs(:actions_taken_this_hand).returns(
477
- @actions_taken_this_hand[i]
478
- ).when(action_appended.is('yes'))
479
- end
480
- end
481
- def check_patient(then_values)
482
- @patient.players.should == then_values.players
483
- @patient.player_acting_sequence.should == then_values.player_acting_sequence
484
- @patient.number_of_players.should == then_values.number_of_players
485
- @patient.player_who_acted_last.should == then_values.player_who_acted_last
486
- @patient.next_player_to_act.should == then_values.next_player_to_act
487
- end
488
-
489
- # @todo Move to MatchState #######
490
-
491
- #describe '::seat_players' do
492
- # it 'creates players with names and starting stack amounts as given' do
493
- # various_numbers_of_players_names_and_stack_sizes do |player_names_to_stack_map|
494
- # match_state_methods_and_return_values =
495
- # {number_of_players: player_names_to_stack_map.keys.length}
496
- #
497
- # init_match_state(match_state_methods_and_return_values) do |match_state|
498
- # player_names_to_stack_map.keys.length.times do |seat|
499
- # # Easy case: the user is always the dealer
500
- # match_state.stubs(:position_relative_to_dealer).with(seat).returns(seat)
501
- # end
502
- # patient = PlayersAtTheTable.seat_players player_names_to_stack_map,
503
- # match_state
504
- #
505
- # player_names = patient.players.map { |player| player.name }
506
- # player_stacks = patient.players.map { |player| player.chip_stack.to_i }
507
- #
508
- # player_names.should be == player_names_to_stack_map.keys
509
- # player_stacks.should be == player_names_to_stack_map.values
510
- # end
511
- # end
512
- # end
513
- # it 'assigns zero as a stack amount if none is given' do
514
- # pending 'Updates to MatchState'
515
- # end
516
- # describe 'raises an exception if' do
517
- # it 'was not given an incorrect number of player names' do
518
- # incorrect_number_of_player_configurations do |player_names_to_stack_map, match_state|
519
- # expect{PlayersAtTheTable.seat_players(player_names_to_stack_map, match_state)}.to
520
- # raise_exception(PlayersAtTheTable::IncorrectNumberOfPlayerNamesGiven)
521
- # end
522
- # end
523
- # end
524
- #end
525
- #
526
- #def incorrect_number_of_player_configurations
527
- # too_many_player_names do |player_names_to_stack_map, match_state|
528
- # yield player_names_to_stack_map, match_state
529
- # end
530
- # too_few_player_names do |player_names_to_stack_map, match_state|
531
- # yield player_names_to_stack_map, match_state
532
- # end
533
- #end
534
- #
535
- #def too_many_player_names
536
- # various_numbers_of_players_names_and_stack_sizes do |player_names_to_stack_map|
537
- # init_match_state({number_of_players: player_names_to_stack_map.keys.length+1}) do |match_state|
538
- # yield player_names_to_stack_map, match_state
539
- # end
540
- # end
541
- #end
542
- #
543
- #def too_few_player_names
544
- # various_numbers_of_players_names_and_stack_sizes do |player_names_to_stack_map|
545
- # init_match_state({number_of_players: player_names_to_stack_map.keys.length-1}) do |match_state|
546
- # yield player_names_to_stack_map, match_state
547
- # end
548
- # end
549
- #end
550
- #
551
- #def init_match_state(stubbed_methods_return_value_map={})
552
- # match_state = mock('MatchState')
553
- # stubbed_methods_return_value_map.each do |method_to_stub, return_value|
554
- # match_state.stubs(method_to_stub).returns(return_value)
555
- # end
556
- # yield match_state
557
- #end
558
- #
559
- #def various_numbers_of_players_names_and_stack_sizes
560
- # [{'only_player_0' => 0}, {'only_player_1' => 1},
561
- # {'p1' => 100, 'p2' => 200},
562
- # {'p1' => 10, 'p2' => 10, 'p3' => 100}].each do |player_names_to_stack_map|
563
- # yield player_names_to_stack_map
564
- # end
565
- #end
566
170
 
567
- #describe 'the list of first seats' do
568
- # it 'is shorter than the round number' do
569
- # lists_of_first_seats_shorter_than_round_number do |list_of_first_seats, match_state|
570
- # expect{MatchState.parse(match_state, list_of_first_seats)}.to raise_exception(MatchState::UnknownFirstSeat)
571
- # end
572
- # end
573
- # it 'contains a seat that is not occupied by a player' do
574
- # first_seat_in_each_round_with_one_not_occupied do |first_seat_in_each_round, match_state|
575
- # expect{MatchState.parse(match_state, first_seat_in_each_round)}.to raise_exception(MatchState::FirstSeatIsUnoccupied)
576
- # end
577
- # end
578
- #end
579
- #it 'reports the correct first player in each round' do
580
- # reports_correct_first_player do |first_seat_in_each_round|
581
- # match_state = MATCH_STATE_LABEL + ':1:1::' + arbitrary_hole_card_hand + '|'
582
- # first_seat_in_each_round.length.times do |i|
583
- # match_state += '/Ah'
584
- # patient = test_match_state_success match_state
585
- # patient.first_player_in_current_round.seat.should == first_seat_in_current_round[i]
586
- # end
587
- # end
588
- #end
171
+ def close_enough?(other)
172
+
173
+ unless (@name == other.name &&
174
+ @seat == other.seat &&
175
+ @chip_stack == other.chip_stack &&
176
+ @chip_balance == other.chip_balance &&
177
+ acpc_actions_taken_this_hand == other.acpc_actions_taken_this_hand)
178
+ puts "name: #{name == other.name}"
179
+ puts "seat: #{seat == other.seat}"
180
+ puts "chip_stack: #{chip_stack}, other: #{other.chip_stack}"
181
+ puts "chip balances: #{chip_balance}, other: #{other.chip_balance}"
182
+ puts "actions_taken_this_hand: #{acpc_actions_taken_this_hand}, other: #{other.acpc_actions_taken_this_hand}"
183
+ puts "all_in: #{all_in?}, other: #{other.all_in?}"
184
+ end
589
185
 
590
186
 
591
- # @todo From MatchState
592
- #:unknown_first_seat, :first_seat_is_unoccupied
593
- #@first_seat_in_each_round = validate_first_seats list_of_first_seats
594
- # @param [Array<Integer>] first_player_position_in_each_round The seat of the first player in each round.
595
- #
596
- #def lists_of_first_seats_shorter_than_round_number
597
- # [[], [0], [0, 1]].each do |list_of_first_seats|
598
- # match_state = MATCH_STATE_LABEL + ':0:0:'
599
- # (list_of_first_seats.length).times do |i|
600
- # match_state += 'c/'
601
- # end
602
- # match_state += ":#{arbitrary_hole_card_hand}|"
603
- # yield list_of_first_seats, match_state
604
- # end
605
- #end
606
- #
607
- #def first_seat_in_each_round_with_one_not_occupied
608
- # [[-3], [2], [0, 1, 2], [0, 2, 1], [2, 1, 0]].each do |first_seat_in_each_round|
609
- # match_state = MATCH_STATE_LABEL + ':0:0::'
610
- # [first_seat_in_each_round.min.abs-2, first_seat_in_each_round.max-1].max.times do |i|
611
- # match_state += arbitrary_hole_card_hand.to_s + '|'
612
- # end
613
- # yield first_seat_in_each_round, match_state
614
- # end
615
- #end
616
- #
617
- #def reports_correct_first_player
618
- # [[0], [0, 0], [0, 1], [0, 1, 0, 1]].each do |first_seat_in_current_round|
619
- # yield first_seat_in_current_round
620
- # end
621
- #end
622
- end
187
+ @name == other.name &&
188
+ @seat == other.seat &&
189
+ @chip_stack == other.chip_stack &&
190
+ @chip_balance == other.chip_balance &&
191
+ acpc_actions_taken_this_hand == other.acpc_actions_taken_this_hand
192
+ end
193
+ end