acpc_dealer 2.0.6 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +4 -2
  3. data/lib/acpc_dealer.rb +6 -2
  4. data/lib/acpc_dealer/version.rb +1 -1
  5. data/vendor/project_acpc_server/Makefile +12 -2
  6. data/vendor/project_acpc_server/README +1 -0
  7. data/vendor/project_acpc_server/example_player.limit.2p.sh +2 -1
  8. data/vendor/project_acpc_server/example_player.limit.3p.sh +2 -1
  9. data/vendor/project_acpc_server/example_player.nolimit.2p.sh +2 -1
  10. data/vendor/project_acpc_server/example_player.nolimit.3p.sh +2 -1
  11. data/vendor/project_acpc_server/kuhn.limit.3p.game +14 -0
  12. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player.sf1.sh +3 -0
  13. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player.sf2.sh +3 -0
  14. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player.sf3.sh +3 -0
  15. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/LICENCE +23 -0
  16. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/Makefile +128 -0
  17. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/README.md +35 -0
  18. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/CExceptionConfig.h +12 -0
  19. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/dealer_connection.c +49 -0
  20. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/dealer_connection.h +22 -0
  21. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/kuhn_3p_equilibrium_player.c +483 -0
  22. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/kuhn_3p_equilibrium_player.h +107 -0
  23. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/main.c +84 -0
  24. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/player_config.c +252 -0
  25. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/player_config.h +21 -0
  26. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/support/test_helper.c +45 -0
  27. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/support/test_helper.h +27 -0
  28. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/test_kuhn_3p_equilibrium_player.c +698 -0
  29. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/test_kuhn_3p_equilibrium_player_sub_family_1.c +324 -0
  30. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/test_kuhn_3p_equilibrium_player_sub_family_2.c +262 -0
  31. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/test_kuhn_3p_equilibrium_player_sub_family_3.c +177 -0
  32. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/docs/CExceptionSummary.odt +0 -0
  33. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/docs/CExceptionSummary.pdf +0 -0
  34. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/docs/license.txt +30 -0
  35. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/docs/readme.txt +242 -0
  36. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/lib/CException.c +43 -0
  37. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/lib/CException.h +86 -0
  38. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/release/build.info +2 -0
  39. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/release/version.info +2 -0
  40. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/config/production_environment.rb +14 -0
  41. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/config/test_environment.rb +16 -0
  42. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/docs/CMock Summary.odt +0 -0
  43. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/docs/CMock Summary.pdf +0 -0
  44. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/docs/CMock_Summary.md +356 -0
  45. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/docs/license.txt +31 -0
  46. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/Resource/SAM7_FLASH.mac +71 -0
  47. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/Resource/SAM7_RAM.mac +94 -0
  48. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/Resource/SAM7_SIM.mac +67 -0
  49. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/Resource/at91SAM7X256_FLASH.xcl +185 -0
  50. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/Resource/at91SAM7X256_RAM.xcl +185 -0
  51. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/Resource/ioat91sam7x256.ddf +2259 -0
  52. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/cmock_demo.dep +3691 -0
  53. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/cmock_demo.ewd +1696 -0
  54. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/cmock_demo.ewp +2581 -0
  55. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/cmock_demo.eww +10 -0
  56. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/AT91SAM7X-EK.h +61 -0
  57. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/AT91SAM7X256.inc +2314 -0
  58. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/AT91SAM7X256.rdf +4704 -0
  59. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/AT91SAM7X256.tcl +3407 -0
  60. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/AT91SAM7X256_inc.h +2268 -0
  61. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/ioat91sam7x256.h +4380 -0
  62. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/lib_AT91SAM7X256.h +4211 -0
  63. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/settings/cmock_demo.cspy.bat +32 -0
  64. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/settings/cmock_demo.dbgdt +86 -0
  65. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/settings/cmock_demo.dni +42 -0
  66. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/settings/cmock_demo.wsdt +76 -0
  67. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/srcIAR/Cstartup.s79 +266 -0
  68. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/srcIAR/Cstartup_SAM7.c +98 -0
  69. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/Resource/SAM7_FLASH.mac +71 -0
  70. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/Resource/SAM7_RAM.mac +94 -0
  71. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/Resource/SAM7_SIM.mac +67 -0
  72. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/Resource/at91SAM7X256_FLASH.icf +43 -0
  73. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/Resource/at91SAM7X256_RAM.icf +42 -0
  74. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/cmock_demo.dep +4204 -0
  75. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/cmock_demo.ewd +1906 -0
  76. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/cmock_demo.ewp +2426 -0
  77. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/cmock_demo.eww +26 -0
  78. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/incIAR/AT91SAM7X-EK.h +61 -0
  79. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/incIAR/AT91SAM7X256_inc.h +2268 -0
  80. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/incIAR/lib_AT91SAM7X256.h +4211 -0
  81. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/incIAR/project.h +30 -0
  82. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/BasicInterrupt_SAM7X.cspy.bat +33 -0
  83. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/BasicInterrupt_SAM7X.dbgdt +5 -0
  84. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/BasicInterrupt_SAM7X.dni +18 -0
  85. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/BasicInterrupt_SAM7X.wsdt +74 -0
  86. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/BasicInterrupt_SAM7X_FLASH_Debug.jlink +12 -0
  87. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo.cspy.bat +33 -0
  88. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo.dbgdt +85 -0
  89. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo.dni +44 -0
  90. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo.wsdt +73 -0
  91. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo_Binary.jlink +12 -0
  92. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo_FLASH_Debug.jlink +12 -0
  93. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo_RAM_Debug.jlink +12 -0
  94. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/srcIAR/Cstartup.s +299 -0
  95. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/srcIAR/Cstartup_SAM7.c +98 -0
  96. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock.rb +65 -0
  97. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_config.rb +129 -0
  98. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_file_writer.rb +33 -0
  99. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator.rb +195 -0
  100. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_array.rb +57 -0
  101. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_callback.rb +78 -0
  102. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_cexception.rb +51 -0
  103. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_expect.rb +86 -0
  104. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_ignore.rb +95 -0
  105. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_ignore_arg.rb +44 -0
  106. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_return_thru_ptr.rb +74 -0
  107. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_utils.rb +202 -0
  108. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_header_parser.rb +277 -0
  109. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_plugin_manager.rb +40 -0
  110. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_unityhelper_parser.rb +75 -0
  111. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/release/build.info +2 -0
  112. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/release/version.info +2 -0
  113. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/src/cmock.c +176 -0
  114. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/src/cmock.h +31 -0
  115. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/src/cmock_internals.h +43 -0
  116. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/targets/gcc.yml +53 -0
  117. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/targets/iar_arm_v4.yml +108 -0
  118. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/targets/iar_arm_v5.yml +93 -0
  119. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/History.md +27 -0
  120. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/Makefile +8 -0
  121. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/Readme.md +103 -0
  122. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/package.json +9 -0
  123. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/src/commander.c +250 -0
  124. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/src/commander.h +88 -0
  125. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/test.c +34 -0
  126. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/colour_prompt.rb +94 -0
  127. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/colour_reporter.rb +39 -0
  128. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/generate_config.yml +36 -0
  129. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/generate_module.rb +202 -0
  130. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/generate_test_runner.rb +316 -0
  131. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/test_file_filter.rb +23 -0
  132. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/unity_test_summary.rb +139 -0
  133. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/docs/Unity Summary.odt +0 -0
  134. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/docs/Unity Summary.pdf +0 -0
  135. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/docs/Unity Summary.txt +216 -0
  136. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/docs/license.txt +31 -0
  137. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/release/build.info +2 -0
  138. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/release/version.info +2 -0
  139. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/src/unity.c +1146 -0
  140. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/src/unity.h +245 -0
  141. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/src/unity_internals.h +546 -0
  142. data/vendor/project_acpc_server/net.c +0 -0
  143. data/vendor/project_acpc_server/net.h +1 -0
  144. data/vendor/project_acpc_server/tags +298 -0
  145. metadata +158 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3096d955fa2a03dd769ddd096e776f540e434219
4
- data.tar.gz: 2f3af5943346c1c7f27a693bf4e9ff7a3c9bff8f
3
+ metadata.gz: 84b73326801489cffe4fff1438b8afc890e36d7f
4
+ data.tar.gz: bfd427d17ccbc771a118140a6535d1d7604bca7f
5
5
  SHA512:
6
- metadata.gz: fcb431724d0dcca127e152c42f0f4293b0291435d5e3a4ab46e442fb8839dc15ce656ba4f52e3a89256355efbdb48c33b7707f6cb5bb20fcb4cffb3987c2788f
7
- data.tar.gz: d435b6137168a2e7fb6b01ee7afee56285cca85d7a3e386cccde549d35f76a438f6eb7979a72c87f2237228cdb82bfe9a90b7f775b20f9c94a286ed8fd9e59e9
6
+ metadata.gz: e2f156daf439f1cb7d0993f81ddd173582ab56ef26e34290522f4f148f5028150937a26be240ce91eff5089bc035c2feb4e76b6c3b5df31ea4c51e77633b1bfb
7
+ data.tar.gz: 38133b40d10f1c3613dba9a705a27ab805bbb492694bbaf32ac0fda20a60e5d379ffe52117bde395da4fc0680e2fb7d205168d7045355d0fa028a9d3fd1852e9
data/Rakefile CHANGED
@@ -9,11 +9,13 @@ require 'rubygems/package_task'
9
9
  require File.expand_path('../lib/acpc_dealer/version', __FILE__)
10
10
 
11
11
  desc 'Build gem'
12
- task :default => [:build, :test]
12
+ task :default => [:test]
13
13
 
14
14
  task :compile => ['dealer:clean', 'dealer:compile']
15
15
 
16
- task :build => [:clean, :compile]
16
+ task :test => :compile
17
+
18
+ task :build => :clean
17
19
 
18
20
  Rake::TestTask.new do |t|
19
21
  t.libs << "lib" << 'spec/support'
data/lib/acpc_dealer.rb CHANGED
@@ -14,7 +14,8 @@ module AcpcDealer
14
14
  3 =>
15
15
  {
16
16
  limit: "#{DEALER_DIRECTORY}/holdem.limit.3p.game",
17
- nolimit: "#{DEALER_DIRECTORY}/holdem.nolimit.3p.game"
17
+ nolimit: "#{DEALER_DIRECTORY}/holdem.nolimit.3p.game",
18
+ kuhn: "#{DEALER_DIRECTORY}/kuhn.limit.3p.game"
18
19
  }
19
20
  }
20
21
  DEALER_PATH = "#{DEALER_DIRECTORY}/dealer"
@@ -28,7 +29,10 @@ module AcpcDealer
28
29
  3 =>
29
30
  {
30
31
  limit: "#{DEALER_DIRECTORY}/example_player.limit.3p.sh",
31
- nolimit: "#{DEALER_DIRECTORY}/example_player.nolimit.3p.sh"
32
+ nolimit: "#{DEALER_DIRECTORY}/example_player.nolimit.3p.sh",
33
+ kuhn_sf1: "#{DEALER_DIRECTORY}/kuhn_3p_equilibrium_player.sf1.sh",
34
+ kuhn_sf2: "#{DEALER_DIRECTORY}/kuhn_3p_equilibrium_player.sf2.sh",
35
+ kuhn_sf3: "#{DEALER_DIRECTORY}/kuhn_3p_equilibrium_player.sf3.sh"
32
36
  }
33
37
  }
34
38
 
@@ -1,3 +1,3 @@
1
1
  module AcpcDealer
2
- VERSION = "2.0.6"
2
+ VERSION = "2.1.0"
3
3
  end
@@ -1,12 +1,19 @@
1
+
2
+ THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
3
+
1
4
  CC = gcc
2
5
  CFLAGS = -O3 -Wall
3
6
 
7
+ KUHN_3P_E_BASE = kuhn_3p_equilibrium_player
8
+ KUHN_3P_E_PLAYER := $(KUHN_3P_E_BASE)
9
+ KUHN_3P_E_DIR := $(KUHN_3P_E_BASE)
10
+
4
11
  PROGRAMS = bm_server bm_widget dealer example_player
5
12
 
6
- all: $(PROGRAMS)
13
+ all: $(PROGRAMS) $(KUHN_3P_E_DIR)/$(KUHN_3P_E_PLAYER)
7
14
 
8
15
  clean:
9
- rm -f $(PROGRAMS)
16
+ rm -f $(PROGRAMS) && cd $(KUHN_3P_E_DIR) && make clean
10
17
 
11
18
 
12
19
  bm_server: bm_server.c game.c game.h rng.c rng.h net.c net.h
@@ -20,3 +27,6 @@ dealer: game.c game.h evalHandTables rng.c rng.h dealer.c net.c net.h
20
27
 
21
28
  example_player: game.c game.h evalHandTables rng.c rng.h example_player.c net.c net.h
22
29
  $(CC) $(CFLAGS) -o $@ game.c rng.c example_player.c net.c
30
+
31
+ $(KUHN_3P_E_DIR)/$(KUHN_3P_E_PLAYER):
32
+ cd $(KUHN_3P_E_DIR) && make
@@ -111,3 +111,4 @@ If you are creating your own game definitions, please note that game.h defines
111
111
  some constants for maximums in games (e.g., number of rounds). These may need
112
112
  to be changed for games outside of the what is being run for the Annual
113
113
  Computer Poker Competition.
114
+
@@ -1,2 +1,3 @@
1
1
  #!/bin/bash
2
- ./example_player holdem.limit.2p.reverse_blinds.game $1 $2
2
+ THIS_DIR=$( cd "$( dirname "$0" )" && pwd )
3
+ cd $THIS_DIR && ./example_player holdem.limit.2p.reverse_blinds.game $1 $2
@@ -1,2 +1,3 @@
1
1
  #!/bin/bash
2
- ./example_player holdem.limit.3p.game $1 $2
2
+ THIS_DIR=$( cd "$( dirname "$0" )" && pwd )
3
+ cd $THIS_DIR && ./example_player holdem.limit.3p.game $1 $2
@@ -1,2 +1,3 @@
1
1
  #!/bin/bash
2
- ./example_player holdem.nolimit.2p.reverse_blinds.game $1 $2
2
+ THIS_DIR=$( cd "$( dirname "$0" )" && pwd )
3
+ cd $THIS_DIR && ./example_player holdem.nolimit.2p.reverse_blinds.game $1 $2
@@ -1,2 +1,3 @@
1
1
  #!/bin/bash
2
- ./example_player holdem.nolimit.3p.game $1 $2
2
+ THIS_DIR=$( cd "$( dirname "$0" )" && pwd )
3
+ cd $THIS_DIR && ./example_player holdem.nolimit.3p.game $1 $2
@@ -0,0 +1,14 @@
1
+ GAMEDEF
2
+ limit
3
+ numPlayers = 3
4
+ numRounds = 1
5
+ blind = 1 1 1
6
+ raiseSize = 1
7
+ firstPlayer = 1
8
+ maxRaises = 1
9
+ numSuits = 1
10
+ numRanks = 4
11
+ numHoleCards = 1
12
+ numBoardCards = 0
13
+ stack = 2 2 2
14
+ END GAMEDEF
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+ THIS_DIR=$( cd "$( dirname "$0" )" && pwd )
3
+ cd $THIS_DIR && ./kuhn_3p_equilibrium_player/kuhn_3p_equilibrium_player -n $1 -p $2 --c11 0.0 --b11 0.25 --b21 0.25 --b32 0.9375 --c33 0.0 --c34 1.0 -g kuhn.limit.3p.game
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+ THIS_DIR=$( cd "$( dirname "$0" )" && pwd )
3
+ cd $THIS_DIR && ./kuhn_3p_equilibrium_player/kuhn_3p_equilibrium_player -n $1 -p $2 --c11 0.5 --b11 0.25 --b21 0.0 --b23 0.125 --b32 0.75 --c33 0.0 --c34 0.75 -g kuhn.limit.3p.game
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+ THIS_DIR=$( cd "$( dirname "$0" )" && pwd )
3
+ cd $THIS_DIR && ./kuhn_3p_equilibrium_player/kuhn_3p_equilibrium_player -n $1 -p $2 --c11 0.33 --b11 0.166667 --b32 0.791667 --c33 0.0 --c34 0.75 -g kuhn.limit.3p.game
@@ -0,0 +1,23 @@
1
+ Copyright (C) 2013 by the Computer Poker Research Group, University of Alberta
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ Except as contained in this notice, the name(s) of the above copyright holders
14
+ shall not be used in advertising or otherwise to promote the sale, use or other
15
+ dealings in this Software without prior written authorization.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
@@ -0,0 +1,128 @@
1
+ THIS_DIR := $(CURDIR)/$(dir $(lastword $(MAKEFILE_LIST)))
2
+ PROJECT_DIR := $(THIS_DIR)/../
3
+
4
+ CC = gcc -std=gnu99
5
+ CFLAGS = -O0 -g
6
+ LIBS = -lm
7
+ TARGET_SYMBOLS = -DCEXCEPTION_USE_CONFIG_FILE
8
+
9
+ VENDOR_DIR := $(THIS_DIR)/vendor/
10
+ COMMANDER_DIR := $(VENDOR_DIR)/commander.c
11
+ TARGET_INCLUDES = -I$(PROJECT_DIR) -I$(THIS_DIR)/src -I$(CEXCEPTION_LIB) -I$(COMMANDER_DIR)/src
12
+
13
+ CEXCEPTION_DIR := $(VENDOR_DIR)/cexception/
14
+ CEXCEPTION_LIB := $(CEXCEPTION_DIR)/lib
15
+ CEXCEPTION_SRC := $(CEXCEPTION_LIB)/CException.c
16
+
17
+ TARGET_BASE = kuhn_3p_equilibrium_player
18
+ TARGET_SRC_DIR := $(THIS_DIR)/src
19
+ TARGET_SRC := $(TARGET_SRC_DIR)/$(TARGET_BASE).c $(CEXCEPTION_SRC)
20
+
21
+ PROJECT_SRC := $(PROJECT_DIR)/game.c $(PROJECT_DIR)/rng.c $(PROJECT_DIR)/net.c
22
+
23
+ BUILD_PREFIX := $(CC) $(CFLAGS) $(TARGET_SYMBOLS)
24
+
25
+ TARGET := $(THIS_DIR)/$(TARGET_BASE)
26
+
27
+ default: $(TARGET)
28
+
29
+ # Build target
30
+ #==============
31
+ $(TARGET): $(TARGET_SRC) $(PROJECT_DIR)/evalHandTables $(PROJECT_DIR)/game.h $(PROJECT_DIR)/net.h $(PROJECT_DIR)/rng.h
32
+ $(BUILD_PREFIX) -Wall $(TARGET_INCLUDES) $(TARGET_SRC) $(TARGET_SRC_DIR)/main.c $(TARGET_SRC_DIR)/player_config.c $(TARGET_SRC_DIR)/dealer_connection.c $(COMMANDER_DIR)/src/commander.c $(LIBS) -o $@ $(PROJECT_SRC)
33
+ chmod 755 $@
34
+
35
+ # Testing
36
+ #===========
37
+ UNITY_DIR := $(VENDOR_DIR)/unity
38
+ CMOCK_DIR := $(VENDOR_DIR)/cmock
39
+ TEST_DIR := $(THIS_DIR)/test
40
+ TEST_SUPPORT_DIR := $(TEST_DIR)/support
41
+ INC_DIRS := -I$(UNITY_DIR)/src -I$(TEST_SUPPORT_DIR) -I$(THIS_DIR)/src $(TARGET_INCLUDES)
42
+ SYMBOLS = -DTEST -DUNITY_FLOAT_TYPE=double -DUNITY_FLOAT_VERBOSE
43
+ TEST_BASE := $(TEST_DIR)/test_$(TARGET_BASE)
44
+ ifeq ($(OS),Windows_NT)
45
+ TEST_EXTENSION=.exe
46
+ else
47
+ TEST_EXTENSION=.out
48
+ endif
49
+
50
+ # Test 1
51
+ #-------------
52
+ TEST1_BASE := $(TEST_BASE)
53
+ TEST1_SRC := $(TEST1_BASE).c
54
+ TEST1 := $(TEST1_BASE)$(TEST_EXTENSION)
55
+ TEST1_RUNNER := $(TEST1_BASE)_Runner.c
56
+
57
+ $(TEST1_RUNNER):
58
+ ruby $(UNITY_DIR)/auto/generate_test_runner.rb $(TEST1_SRC) $(TEST1_RUNNER)
59
+
60
+ $(TEST1): $(TARGET) $(TEST1_RUNNER)
61
+ $(BUILD_PREFIX) $(SYMBOLS) $(INC_DIRS) $(TARGET_SRC) $(PROJECT_SRC) $(TEST_SUPPORT_DIR)/test_helper.c $(UNITY_DIR)/src/unity.c $(TEST1_SRC) $(TEST1_RUNNER) $(LIBS) -o $(TEST1)
62
+
63
+ # Test 2
64
+ #-------------
65
+ TEST2_BASE := $(TEST_BASE)_sub_family_1
66
+ TEST2_SRC := $(TEST2_BASE).c
67
+ TEST2 := $(TEST2_BASE)$(TEST_EXTENSION)
68
+ TEST2_RUNNER := $(TEST2_BASE)_Runner.c
69
+
70
+ $(TEST2_RUNNER):
71
+ ruby $(UNITY_DIR)/auto/generate_test_runner.rb $(TEST2_SRC) $(TEST2_RUNNER)
72
+
73
+ $(TEST2): $(TARGET) $(TEST2_RUNNER)
74
+ $(BUILD_PREFIX) $(SYMBOLS) $(INC_DIRS) $(TARGET_SRC) $(PROJECT_SRC) $(TEST_SUPPORT_DIR)/test_helper.c $(UNITY_DIR)/src/unity.c $(TEST2_SRC) $(TEST2_RUNNER) $(LIBS) -o $(TEST2)
75
+
76
+ # Test 3
77
+ #-------------
78
+ TEST3_BASE := $(TEST_BASE)_sub_family_2
79
+ TEST3_SRC := $(TEST3_BASE).c
80
+ TEST3 := $(TEST3_BASE)$(TEST_EXTENSION)
81
+ TEST3_RUNNER := $(TEST3_BASE)_Runner.c
82
+
83
+ $(TEST3_RUNNER):
84
+ ruby $(UNITY_DIR)/auto/generate_test_runner.rb $(TEST3_SRC) $(TEST3_RUNNER)
85
+
86
+ $(TEST3): $(TARGET) $(TEST3_RUNNER)
87
+ $(BUILD_PREFIX) $(SYMBOLS) $(INC_DIRS) $(TARGET_SRC) $(PROJECT_SRC) $(TEST_SUPPORT_DIR)/test_helper.c $(UNITY_DIR)/src/unity.c $(TEST3_SRC) $(TEST3_RUNNER) $(LIBS) -o $(TEST3)
88
+
89
+ # Test 4
90
+ #-------------
91
+ TEST4_BASE := $(TEST_BASE)_sub_family_3
92
+ TEST4_SRC := $(TEST4_BASE).c
93
+ TEST4 := $(TEST4_BASE)$(TEST_EXTENSION)
94
+ TEST4_RUNNER := $(TEST4_BASE)_Runner.c
95
+
96
+ $(TEST4_RUNNER):
97
+ ruby $(UNITY_DIR)/auto/generate_test_runner.rb $(TEST4_SRC) $(TEST4_RUNNER)
98
+
99
+ $(TEST4): $(TARGET) $(TEST4_RUNNER)
100
+ $(BUILD_PREFIX) $(SYMBOLS) $(INC_DIRS) $(TARGET_SRC) $(PROJECT_SRC) $(TEST_SUPPORT_DIR)/test_helper.c $(UNITY_DIR)/src/unity.c $(TEST4_SRC) $(TEST4_RUNNER) $(LIBS) -o $(TEST4)
101
+
102
+ # Basic functionality exercise with the dealer
103
+ #-------------------------------
104
+ $(PROJECT_DIR)/dealer:
105
+ cd $(PROJECT_DIR) && make
106
+
107
+ dealer_test: clean $(TARGET) $(PROJECT_DIR)/dealer
108
+ cd $(PROJECT_DIR) && ./dealer m kuhn.limit.3p.game 100 1 p1 p2 p3 &
109
+ sleep 0.1 # Ensure the dealer has started and is ready to accept connections
110
+ ./kuhn_3p_equilibrium_player -0 0.0 -1 0.25 -2 0.25 -4 0.9375 --c33 0.0 --c34 1.0 -p 18791 -g ../kuhn.limit.3p.game & # Sub-family 1
111
+ ./kuhn_3p_equilibrium_player --c11 0.5 --b11 0.25 --b21 0.0 --b23 0.125 --b32 0.75 --c33 0.0 --c34 0.75 -p 18374 -g ../kuhn.limit.3p.game & # Sub-family 2
112
+ ./kuhn_3p_equilibrium_player --c11 0.33 --b11 0.166667 --b32 0.791667 --c33 0.0 --c34 0.75 -p 59497 -g ../kuhn.limit.3p.game & # Sub-family 3
113
+
114
+ # Automatic tests (require Ruby)
115
+ #--------------------------------
116
+ test: clean $(TEST1) $(TEST2) $(TEST3) $(TEST4)
117
+ $(TEST1)
118
+ $(TEST2)
119
+ $(TEST3)
120
+ $(TEST4)
121
+
122
+ # Clean
123
+ #============
124
+ clean:
125
+ rm -f $(TARGET) *.o *.il *.out $(TEST1) $(TEST2) $(TEST3) $(TEST4) $(TEST1_RUNNER) $(TEST2_RUNNER) $(TEST3_RUNNER) $(TEST4_RUNNER) $(THIS_DIR)/test/*.out
126
+
127
+ dist_clean: clean
128
+ rm -f *~ core
@@ -0,0 +1,35 @@
1
+ Kuhn 3-Player Equilibrium Player
2
+ =================================
3
+ `kuhn_3p_equilibrium_player` is an ACPC compatible player that connects to the
4
+ ACPC dealer and plays 3-player Kuhn poker with an equilibrium component
5
+ strategy specified by its arguments from one of those specified by
6
+ [*A Parameterized Family of Equilibrium Profiles for Three-Player Kuhn
7
+ Poker*](http://poker.cs.ualberta.ca/publications/2013-techreport-nl-size.pdf),
8
+ written by Duane Szafron, Richard Gibson, and Nathan Sturtevant, found in
9
+ *Proceedings of the Twelfth International Conference on Autonomous Agents and
10
+ Multiagent Systems (AAMAS-13)* in May 2013.
11
+
12
+ Equilibrium sub-families
13
+ --------------------------
14
+ There are three sub-families of equilibria identified by Szafron, Gibson, and
15
+ Sturtevant, each defined by a different value of parameter `c11`. Depending on
16
+ the sub-family, different parameters must necessarily be provided, except for
17
+ `c11`, `b11`, `b32`, `c33`, and `c34`, which are always necessary. Please
18
+ see
19
+ [the paper](http://poker.cs.ualberta.ca/publications/2013-techreport-nl-size.pdf)
20
+ for the domain of each paramter.
21
+
22
+ - `c11 = 0.0` sub-family: `b21` must also be provided.
23
+ - `c11 = 1/2.0` sub-family: `b21` and `b23` must also be provided.
24
+ - `0.0 < c11 < 1/2.0` sub-family: No futher parameters are necessary.
25
+
26
+ License
27
+ -------
28
+ MIT license (see `LICENCE`).
29
+
30
+ Acknowledgements
31
+ ----------------
32
+ This project includes software developed for
33
+ the CException Project, by Mark VanderVoord and other
34
+ contributors, as well as the CMock and Unity Projects, by Mike Karlesky,
35
+ Mark VanderVoord, and Greg Williams and other contributors.
@@ -0,0 +1,12 @@
1
+ /*
2
+ Copyright (C) 2013 by the Computer Poker Research Group, University of Alberta
3
+ */
4
+
5
+ #ifndef __CEXCEPTION_CONFIG_H__
6
+ #define __CEXCEPTION_CONFIG_H__
7
+
8
+ #include <stdlib.h>
9
+
10
+ #define CEXCEPTION_NO_CATCH_HANDLER(id) exit(id)
11
+
12
+ #endif
@@ -0,0 +1,49 @@
1
+ /*
2
+ Copyright (C) 2013 by the Computer Poker Research Group, University of Alberta
3
+ */
4
+
5
+ #include <stdlib.h>
6
+ #include <assert.h>
7
+ #include "dealer_connection.h"
8
+ #include "game.h"
9
+
10
+ DealerConnection new_dealer_connection()
11
+ {
12
+ DealerConnection this = {
13
+ .host = "localhost",
14
+ .port = 0,
15
+ .toServer = NULL,
16
+ .fromServer = NULL
17
+ };
18
+
19
+ return this;
20
+ }
21
+
22
+ void connect_to_dealer(DealerConnection* this)
23
+ {
24
+ assert(this);
25
+
26
+ int sock = connectTo(this->host, this->port);
27
+ if( sock < 0 ) {
28
+ exit( EXIT_FAILURE );
29
+ }
30
+ this->toServer = fdopen( sock, "w" );
31
+ this->fromServer = fdopen( sock, "r" );
32
+ if(!(this->toServer && this->fromServer)) {
33
+ fprintf( stderr, "ERROR: could not get socket streams\n" );
34
+ exit( EXIT_FAILURE );
35
+ }
36
+
37
+ /* send version string to dealer */
38
+ if(
39
+ fprintf(
40
+ this->toServer,
41
+ "VERSION:%"PRIu32".%"PRIu32".%"PRIu32"\n",
42
+ VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION
43
+ ) != 14
44
+ ) {
45
+ fprintf( stderr, "ERROR: could not get send version to server\n" );
46
+ exit(EXIT_FAILURE);
47
+ }
48
+ fflush(this->toServer);
49
+ }
@@ -0,0 +1,22 @@
1
+ /*
2
+ Copyright (C) 2013 by the Computer Poker Research Group, University of Alberta
3
+ */
4
+
5
+ #ifndef __DEALER_CONNECTION_H__
6
+ #define __DEALER_CONNECTION_H__
7
+
8
+ #include <limits.h>
9
+ #include <stdint.h>
10
+ #include <stdio.h>
11
+
12
+ typedef struct {
13
+ char host[HOST_NAME_MAX];
14
+ uint16_t port;
15
+ FILE *toServer;
16
+ FILE *fromServer;
17
+ } DealerConnection;
18
+
19
+ DealerConnection new_dealer_connection();
20
+ void connect_to_dealer(DealerConnection* this);
21
+
22
+ #endif
@@ -0,0 +1,483 @@
1
+ /*
2
+ Copyright (C) 2013 by the Computer Poker Research Group, University of Alberta
3
+ */
4
+
5
+ #include <stdio.h>
6
+ #include <stdlib.h>
7
+ #include <string.h>
8
+ #include <stdbool.h>
9
+ #include <math.h>
10
+ #include <assert.h>
11
+
12
+ #include "CException.h"
13
+ void print_and_throw_error(const char const *message)
14
+ {
15
+ fprintf(stderr, "ERROR: %s", message);
16
+ Throw(1);
17
+ }
18
+
19
+ #include "kuhn_3p_equilibrium_player.h"
20
+
21
+ double beta(const Kuhn3pEquilibriumPlayer* kuhn_3p_e_player)
22
+ {
23
+ assert(kuhn_3p_e_player);
24
+
25
+ return fmax(
26
+ kuhn_3p_e_player->params[B11_INDEX], kuhn_3p_e_player->params[B21_INDEX]
27
+ );
28
+ }
29
+
30
+ /* Based on Unity's UnityAssertDoublesWithin function */
31
+ static bool doublesAboutEqual(double d1, double d2) {
32
+ static const double DOUBLE_PRECISION = 1e-12f;
33
+
34
+ double diff = fabs(d2 - d1);
35
+ double delta = fabs(d2 * DOUBLE_PRECISION);
36
+
37
+ //This first part of this condition will catch any NaN or Infinite values
38
+ return !((diff * 0.0 != 0.0) || (delta < diff));
39
+ }
40
+
41
+ static bool is_3p_kuhn_poker_game(const Game const *game_def)
42
+ {
43
+ assert(game_def);
44
+ return (
45
+ game_def->bettingType == limitBetting &&
46
+ game_def->numRounds == 1 && game_def->maxRaises[0] == 1 &&
47
+ game_def->numSuits == 1 && game_def->numRanks == 4 &&
48
+ game_def->numHoleCards == 1 &&
49
+ game_def->numBoardCards[0] == 0 &&
50
+ game_def->numPlayers == 3
51
+ );
52
+ }
53
+
54
+ static void check_c11_b11_and_b21(Kuhn3pEquilibriumPlayer* kuhn_3p_e_player) {
55
+ assert(kuhn_3p_e_player);
56
+
57
+ if (kuhn_3p_e_player->params[C11_INDEX] > (1/2.0)) {
58
+ print_and_throw_error(
59
+ "kuhn_3p_equilibrium_player: c11 greater than 1/2\n"
60
+ );
61
+ return;
62
+ }
63
+ if (doublesAboutEqual(0.0, kuhn_3p_e_player->params[C11_INDEX])) {
64
+ if (kuhn_3p_e_player->params[B21_INDEX] > (1/4.0)) {
65
+ print_and_throw_error(
66
+ "kuhn_3p_equilibrium_player: b21 greater than 1/4\n"
67
+ );
68
+ }
69
+ if (
70
+ kuhn_3p_e_player->params[B11_INDEX] >
71
+ kuhn_3p_e_player->params[B21_INDEX]
72
+ ) {
73
+ print_and_throw_error(
74
+ "kuhn_3p_equilibrium_player: b11 greater than b21\n"
75
+ );
76
+ }
77
+ } else {
78
+ if (kuhn_3p_e_player->params[B11_INDEX] > (1/4.0)) {
79
+ print_and_throw_error(
80
+ "kuhn_3p_equilibrium_player: b11 greater than 1/4\n"
81
+ );
82
+ }
83
+ if (kuhn_3p_e_player->params[C11_INDEX] < (1/2.0)) {
84
+ if (
85
+ kuhn_3p_e_player->params[B11_INDEX] > (1/6.0) && (
86
+ kuhn_3p_e_player->params[C11_INDEX] > (
87
+ (2 - kuhn_3p_e_player->params[B11_INDEX]) /
88
+ (3 + 4 * kuhn_3p_e_player->params[B11_INDEX])
89
+ )
90
+ )
91
+ ) {
92
+ print_and_throw_error(
93
+ "kuhn_3p_equilibrium_player: c11 too large\n"
94
+ );
95
+ }
96
+
97
+ kuhn_3p_e_player->params[B21_INDEX] =
98
+ kuhn_3p_e_player->params[B11_INDEX];
99
+ } else if (
100
+ kuhn_3p_e_player->params[B21_INDEX] > fmin(
101
+ kuhn_3p_e_player->params[B11_INDEX],
102
+ (1/2.0) - 2 * kuhn_3p_e_player->params[B11_INDEX]
103
+ )
104
+ ) {
105
+ print_and_throw_error(
106
+ "kuhn_3p_equilibrium_player: b21 too large\n"
107
+ );
108
+ }
109
+ }
110
+ }
111
+
112
+ static void check_b32(Kuhn3pEquilibriumPlayer* kuhn_3p_e_player) {
113
+ assert(kuhn_3p_e_player);
114
+
115
+ if (
116
+ kuhn_3p_e_player->params[B32_INDEX] > (
117
+ (1 / 2.0) + (3 / 4.0) * (
118
+ kuhn_3p_e_player->params[B11_INDEX] +
119
+ kuhn_3p_e_player->params[B21_INDEX]
120
+ ) + (beta(kuhn_3p_e_player) / 4.0)
121
+ )
122
+ ) {
123
+ print_and_throw_error(
124
+ "kuhn_3p_equilibrium_player: b32 too large\n");
125
+ }
126
+ }
127
+
128
+ static void check_c33(Kuhn3pEquilibriumPlayer* kuhn_3p_e_player) {
129
+ assert(kuhn_3p_e_player);
130
+
131
+ if (
132
+ kuhn_3p_e_player->params[C33_INDEX] < (
133
+ (1 / 2.0) - kuhn_3p_e_player->params[B32_INDEX])
134
+ ) {
135
+ print_and_throw_error(
136
+ "kuhn_3p_equilibrium_player: c33 too small\n");
137
+ }
138
+ if (
139
+ kuhn_3p_e_player->params[C33_INDEX] > (
140
+ (1 / 2.0) - kuhn_3p_e_player->params[B32_INDEX] + (3 / 4.0) * (
141
+ kuhn_3p_e_player->params[B11_INDEX] +
142
+ kuhn_3p_e_player->params[B21_INDEX]
143
+ ) + (beta(kuhn_3p_e_player) / 4.0)
144
+ )
145
+ ) {
146
+ print_and_throw_error(
147
+ "kuhn_3p_equilibrium_player: c33 too large\n"
148
+ );
149
+ }
150
+ }
151
+
152
+ static void check_b23(Kuhn3pEquilibriumPlayer* kuhn_3p_e_player) {
153
+ if (
154
+ kuhn_3p_e_player->params[B23_INDEX] > fmax(
155
+ 0.0,
156
+ (
157
+ kuhn_3p_e_player->params[B11_INDEX] -
158
+ kuhn_3p_e_player->params[B21_INDEX]
159
+ ) /
160
+ (2 * (1.0 - kuhn_3p_e_player->params[B21_INDEX]))
161
+ )
162
+ ) {
163
+ print_and_throw_error("kuhn_3p_equilibrium_player: b23 too large\n");
164
+ }
165
+ }
166
+
167
+ static void check_params(Kuhn3pEquilibriumPlayer* kuhn_3p_e_player)
168
+ {
169
+ assert(kuhn_3p_e_player);
170
+
171
+ check_c11_b11_and_b21(kuhn_3p_e_player);
172
+
173
+ check_b23(kuhn_3p_e_player);
174
+ kuhn_3p_e_player->params[B33_INDEX] = (
175
+ (1 / 2.0) + (1 / 2.0)*(
176
+ kuhn_3p_e_player->params[B11_INDEX] +
177
+ kuhn_3p_e_player->params[B21_INDEX]
178
+ ) +
179
+ (beta(kuhn_3p_e_player) / 2.0) - kuhn_3p_e_player->params[B23_INDEX] * (
180
+ 1 - kuhn_3p_e_player->params[B21_INDEX]
181
+ )
182
+ );
183
+ kuhn_3p_e_player->params[B41_INDEX] = (
184
+ 2 * kuhn_3p_e_player->params[B11_INDEX] +
185
+ 2 * kuhn_3p_e_player->params[B21_INDEX]
186
+ );
187
+
188
+ check_b32(kuhn_3p_e_player);
189
+ check_c33(kuhn_3p_e_player);
190
+
191
+ kuhn_3p_e_player->params[B41_INDEX] = (
192
+ 2 * kuhn_3p_e_player->params[B11_INDEX] +
193
+ 2 * kuhn_3p_e_player->params[B21_INDEX]
194
+ );
195
+ kuhn_3p_e_player->params[C21_INDEX] = (
196
+ (1 / 2.0) - kuhn_3p_e_player->params[C11_INDEX]
197
+ );
198
+
199
+ for (size_t i = 0; i < NUM_PARAMS; ++i) {
200
+ if (
201
+ kuhn_3p_e_player->params[i] < 0.0 ||
202
+ kuhn_3p_e_player->params[i] > 1.0
203
+ ) {
204
+ print_and_throw_error(
205
+ "kuhn_3p_equilibrium_player: strategy parameters must be in [0,1]\n"
206
+ );
207
+ }
208
+ }
209
+ return;
210
+ }
211
+
212
+ static void action_probs_p0(
213
+ uint8_t card_rank,
214
+ const State const* state,
215
+ double* probs
216
+ ) {
217
+ assert(probs);
218
+ assert(state);
219
+
220
+ size_t situation_index = 0;
221
+
222
+ if (0 == state->numActions[0]) { // Situation 1
223
+ probs[a_fold] = 0.0;
224
+ probs[a_call] = 1.0 - A[card_rank - JACK_RANK][0];
225
+ probs[a_raise] = A[card_rank - JACK_RANK][0];
226
+ return;
227
+ } else if (a_call == state->action[0][1].type) { // Situation 2
228
+ situation_index = 1;
229
+ } else if (a_fold == state->action[0][2].type) { // Situation 3
230
+ situation_index = 2;
231
+ } else { // Situation 4
232
+ situation_index = 3;
233
+ }
234
+ probs[a_fold] = 1.0 - A[card_rank - JACK_RANK][situation_index];
235
+ probs[a_call] = A[card_rank - JACK_RANK][situation_index];
236
+ probs[a_raise] = 0.0;
237
+
238
+ return;
239
+ }
240
+
241
+ static void action_probs_p1(
242
+ const double const* params,
243
+ uint8_t card_rank,
244
+ const State const* state,
245
+ double* probs
246
+ ) {
247
+ assert(params);
248
+ assert(probs);
249
+ assert(state);
250
+
251
+ double param;
252
+
253
+ // Situation 1 or 2
254
+ if (1 == state->numActions[0]) {
255
+ if (a_call == state->action[0][0].type) { // Situation 1
256
+ if (JACK_RANK == card_rank) {
257
+ param = params[B11_INDEX];
258
+ } else if (QUEEN_RANK == card_rank) {
259
+ param = params[B21_INDEX];
260
+ } else if (KING_RANK == card_rank) {
261
+ param = B31;
262
+ } else {
263
+ param = params[B41_INDEX];
264
+ }
265
+ probs[a_fold] = 0.0;
266
+ probs[a_call] = 1.0 - param;
267
+ probs[a_raise] = param;
268
+ return;
269
+ } else { // Situation 2
270
+ if (JACK_RANK == card_rank) {
271
+ param = B12;
272
+ } else if (QUEEN_RANK == card_rank) {
273
+ param = B22;
274
+ } else if (KING_RANK == card_rank) {
275
+ param = params[B32_INDEX];
276
+ } else {
277
+ param = B42;
278
+ }
279
+ }
280
+ } else { // Situation 3 or 4
281
+ if (a_fold == state->action[0][3].type) { // Situation 3
282
+ if (JACK_RANK == card_rank) {
283
+ param = B13;
284
+ } else if (QUEEN_RANK == card_rank) {
285
+ param = params[B23_INDEX];
286
+ } else if (KING_RANK == card_rank) {
287
+ param = params[B33_INDEX];
288
+ } else {
289
+ param = B43;
290
+ }
291
+ } else { // Situation 4
292
+ if (JACK_RANK == card_rank) {
293
+ param = B14;
294
+ } else if (QUEEN_RANK == card_rank) {
295
+ param = B24;
296
+ } else if (KING_RANK == card_rank) {
297
+ param = B34;
298
+ } else {
299
+ param = B44;
300
+ }
301
+ }
302
+ }
303
+
304
+ probs[a_fold] = 1.0 - param;
305
+ probs[a_call] = param;
306
+ probs[a_raise] = 0.0;
307
+
308
+ return;
309
+ }
310
+
311
+ static void action_probs_p2(
312
+ const double const* params,
313
+ uint8_t card_rank,
314
+ const State const* state,
315
+ double* probs
316
+ )
317
+ {
318
+ assert(params);
319
+ assert(probs);
320
+ assert(state);
321
+
322
+ double param;
323
+
324
+ // Situation 1
325
+ if (a_call == state->action[0][0].type) {
326
+ if (a_call == state->action[0][1].type) { // Situation 1
327
+ if (JACK_RANK == card_rank) {
328
+ param = params[C11_INDEX];
329
+ } else if (QUEEN_RANK == card_rank) {
330
+ param = params[C21_INDEX];
331
+ } else if (KING_RANK == card_rank) {
332
+ param = C31;
333
+ } else {
334
+ param = C4[0];
335
+ }
336
+ probs[a_fold] = 0.0;
337
+ probs[a_call] = 1.0 - param;
338
+ probs[a_raise] = param;
339
+ return;
340
+ } else { // Situation 2
341
+ if (JACK_RANK == card_rank) {
342
+ param = C12;
343
+ } else if (QUEEN_RANK == card_rank) {
344
+ param = C22;
345
+ } else if (KING_RANK == card_rank) {
346
+ param = C32;
347
+ } else {
348
+ param = C4[1];
349
+ }
350
+ }
351
+ } else { // Situation 3 or 4
352
+ if (a_fold == state->action[0][1].type) { // Situation 3
353
+ if (JACK_RANK == card_rank) {
354
+ param = C13;
355
+ } else if (QUEEN_RANK == card_rank) {
356
+ param = C23;
357
+ } else if (KING_RANK == card_rank) {
358
+ param = params[C33_INDEX];
359
+ } else {
360
+ param = C4[2];
361
+ }
362
+ } else { // Situation 4
363
+ if (JACK_RANK == card_rank) {
364
+ param = C14;
365
+ } else if (QUEEN_RANK == card_rank) {
366
+ param = C24;
367
+ } else if (KING_RANK == card_rank) {
368
+ param = params[C34_INDEX];
369
+ } else {
370
+ param = C4[3];
371
+ }
372
+ }
373
+ }
374
+
375
+ probs[a_fold] = 1.0 - param;
376
+ probs[a_call] = param;
377
+ probs[a_raise] = 0.0;
378
+
379
+ return;
380
+ }
381
+
382
+ /*********************************/
383
+ /****** Player Interface *********/
384
+ /*********************************/
385
+
386
+ /* create any private space needed for future calls
387
+ game_def is a private copy allocated by the dealer for the player's use */
388
+ Kuhn3pEquilibriumPlayer new_kuhn_3p_equilibrium_player(
389
+ const Game const* game_def,
390
+ const double const* params,
391
+ uint32_t seed
392
+ )
393
+ {
394
+ assert(game_def);
395
+ assert(params);
396
+
397
+ Kuhn3pEquilibriumPlayer kuhn_3p_e_player;
398
+
399
+ /* This player cannot be used outside of Kuhn poker */
400
+ if(!is_3p_kuhn_poker_game(game_def)) {
401
+ print_and_throw_error(
402
+ "kuhn_3p_equilibrium_player used in non-Kuhn game\n"
403
+ );
404
+ return kuhn_3p_e_player;
405
+ }
406
+
407
+ kuhn_3p_e_player.game_def = game_def;
408
+
409
+ memset(
410
+ kuhn_3p_e_player.params,
411
+ 0,
412
+ NUM_PARAMS * sizeof(*kuhn_3p_e_player.params)
413
+ );
414
+ for (size_t i = 0; i < NUM_PARAMS; ++i) {
415
+ kuhn_3p_e_player.params[i] = params[i];
416
+ }
417
+
418
+ kuhn_3p_e_player.seed = seed;
419
+
420
+ CEXCEPTION_T e = 0;
421
+ Try {
422
+ check_params(&kuhn_3p_e_player);
423
+ } Catch(e) {
424
+ Throw(e);
425
+ }
426
+
427
+ /* Create our random number generators */
428
+ init_genrand(&kuhn_3p_e_player.get_action_rng, kuhn_3p_e_player.seed);
429
+
430
+ return kuhn_3p_e_player;
431
+ }
432
+
433
+ /* return a (valid!) action at the information state described by view */
434
+ Action action(
435
+ Kuhn3pEquilibriumPlayer* player,
436
+ MatchState view
437
+ )
438
+ {
439
+ assert(player);
440
+
441
+ double probs[NUM_ACTION_TYPES];
442
+ memset(probs, 0, NUM_ACTION_TYPES * sizeof(*probs));
443
+ action_probs(player, view, probs);
444
+
445
+ double r = genrand_real2(&player->get_action_rng);
446
+
447
+ enum ActionType i = a_fold;
448
+ for (; i < NUM_ACTION_TYPES - 1; ++i) {
449
+ if (r <= probs[i]) {
450
+ break;
451
+ }
452
+ r -= probs[i];
453
+ }
454
+
455
+ Action a = {a.type = i, a.size = 0};
456
+
457
+ return a;
458
+ }
459
+
460
+ /* Returns a distribution of actions in action_triple
461
+ This is an extra function, and does _NOT_ need to be implemented
462
+ to be considered a valid player.h interface. */
463
+ void action_probs(
464
+ const Kuhn3pEquilibriumPlayer const* player,
465
+ MatchState view,
466
+ double* probs
467
+ )
468
+ {
469
+ assert(player);
470
+ assert(probs);
471
+
472
+ uint8_t card_rank = rankOfCard(view.state.holeCards[view.viewingPlayer][0]);
473
+
474
+ if (0 == view.viewingPlayer) {
475
+ action_probs_p0(card_rank, &view.state, probs);
476
+ } else if (1 == view.viewingPlayer) {
477
+ action_probs_p1(player->params, card_rank, &view.state, probs);
478
+ } else {
479
+ action_probs_p2(player->params, card_rank, &view.state, probs);
480
+ }
481
+
482
+ return;
483
+ }