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
@@ -0,0 +1,177 @@
1
+ /*
2
+ Copyright (C) 2013 by the Computer Poker Research Group, University of Alberta
3
+ */
4
+
5
+ #include <stdio.h>
6
+ #include <string.h>
7
+ #include <unistd.h>
8
+
9
+ #include "test_helper.h"
10
+
11
+ #include "kuhn_3p_equilibrium_player.h"
12
+
13
+ static int stderr_copy;
14
+ static FILE* dev_null = NULL;
15
+ void setUp()
16
+ {
17
+ // Silence error output
18
+ stderr_copy = dup(fileno(stderr));
19
+ dev_null = freopen("/dev/null", "w", stderr);
20
+ }
21
+
22
+ void tearDown()
23
+ {
24
+ if (dev_null) {
25
+ // Restore error output
26
+ fflush(stderr);
27
+ dup2(stderr_copy, fileno(stderr));
28
+ close(stderr_copy);
29
+ }
30
+ }
31
+
32
+ void test_params_set_properly()
33
+ {
34
+ Game game_def = init_kuhn_poker_game_def();
35
+
36
+ double params[NUM_PARAMS] = {0};
37
+ params[C11_INDEX] = 0.33;
38
+ params[B11_INDEX] = 1/6.0;
39
+ params[B32_INDEX] = (2 + 7 * params[B11_INDEX]) / 4.0;
40
+ double b21 = params[B11_INDEX];
41
+ double b23 = 0.0;
42
+ params[C33_INDEX] = 1/2.0 - params[B32_INDEX] + (7/4.0) * params[B11_INDEX];
43
+ params[C34_INDEX] = 3/4.0; // Unconstrained
44
+
45
+ double b33 = (1.0 + 3 * params[B11_INDEX] ) / 2.0;
46
+ double b41 = 4 * params[B11_INDEX];
47
+ double c21 = (1/2.0) - params[C11_INDEX];
48
+
49
+ CEXCEPTION_T e = 0;
50
+
51
+ Try {
52
+ Kuhn3pEquilibriumPlayer patient = new_kuhn_3p_equilibrium_player(
53
+ &game_def,
54
+ params,
55
+ 12
56
+ );
57
+
58
+ TEST_ASSERT_EQUAL_FLOAT(params[C11_INDEX], patient.params[C11_INDEX]);
59
+ TEST_ASSERT_EQUAL_FLOAT(params[B11_INDEX], patient.params[B11_INDEX]);
60
+ TEST_ASSERT_EQUAL_FLOAT(b21, patient.params[B21_INDEX]);
61
+ TEST_ASSERT_EQUAL_FLOAT(b23, patient.params[B23_INDEX]);
62
+ TEST_ASSERT_EQUAL_FLOAT(params[B32_INDEX], patient.params[B32_INDEX]);
63
+ TEST_ASSERT_EQUAL_FLOAT(params[C33_INDEX], patient.params[C33_INDEX]);
64
+ TEST_ASSERT_EQUAL_FLOAT(params[C34_INDEX], patient.params[C34_INDEX]);
65
+
66
+ TEST_ASSERT_EQUAL_FLOAT(12, patient.seed);
67
+
68
+ TEST_ASSERT_EQUAL_FLOAT(b33, patient.params[B33_INDEX]);
69
+ TEST_ASSERT_EQUAL_FLOAT(b41, patient.params[B41_INDEX]);
70
+ TEST_ASSERT_EQUAL_FLOAT(c21, patient.params[C21_INDEX]);
71
+ } Catch(e) {
72
+ TEST_FAIL_MESSAGE("Should Not Have Thrown An Error");
73
+ }
74
+ }
75
+
76
+ void test_b11_upper_bound()
77
+ {
78
+ Game game_def = init_kuhn_poker_game_def();
79
+
80
+ double params[NUM_PARAMS] = {0};
81
+ params[C11_INDEX] = 0.33;
82
+ params[B11_INDEX] = 1/4.0 + 0.01;
83
+ params[B32_INDEX] = (2 + 7 * params[B11_INDEX] - 0.01) / 4.0;
84
+ params[C33_INDEX] = 1/2.0 - params[B32_INDEX] + (7/4.0) * (
85
+ params[B11_INDEX] - 0.01
86
+ );
87
+ params[C34_INDEX] = 3/4.0; // Unconstrained
88
+
89
+ CEXCEPTION_T e = 0;
90
+
91
+ Try {
92
+ Kuhn3pEquilibriumPlayer patient = new_kuhn_3p_equilibrium_player(
93
+ &game_def,
94
+ params,
95
+ 12
96
+ );
97
+ TEST_FAIL_MESSAGE("Should Have Thrown An Error");
98
+ }
99
+ Catch(e) {
100
+ TEST_ASSERT_EQUAL(1, e);
101
+ }
102
+ }
103
+
104
+ void test_b32_upper_bound()
105
+ {
106
+ Game game_def = init_kuhn_poker_game_def();
107
+
108
+ double params[NUM_PARAMS] = {0};
109
+ params[C11_INDEX] = 0.33;
110
+ params[B11_INDEX] = 1/6.0;
111
+ params[B32_INDEX] = ((2 + 7 * params[B11_INDEX] - 0.01) / 4.0) + 0.01;
112
+ params[C33_INDEX] = 1/2.0 - params[B32_INDEX] + (7/4.0) * (
113
+ params[B11_INDEX] - 0.01
114
+ );
115
+ params[C34_INDEX] = 3/4.0; // Unconstrained
116
+
117
+ CEXCEPTION_T e = 0;
118
+
119
+ Try {
120
+ Kuhn3pEquilibriumPlayer patient = new_kuhn_3p_equilibrium_player(
121
+ &game_def,
122
+ params,
123
+ 12
124
+ );
125
+ TEST_FAIL_MESSAGE("Should Have Thrown An Error");
126
+ }
127
+ Catch(e) {
128
+ TEST_ASSERT_EQUAL(1, e);
129
+ }
130
+ }
131
+
132
+ void test_c11()
133
+ {
134
+ Game game_def = init_kuhn_poker_game_def();
135
+
136
+ double params[NUM_PARAMS] = {0};
137
+
138
+ // When b11 <= 1/6.0
139
+ params[C11_INDEX] = 1/2.0 - 0.01;
140
+ params[B11_INDEX] = 1/6.0;
141
+ params[B32_INDEX] = 0.0;
142
+ params[C33_INDEX] = 1/2.0 - params[B32_INDEX];
143
+ params[C34_INDEX] = 3/4.0; // Unconstrained
144
+
145
+ CEXCEPTION_T e = 0;
146
+
147
+ Try {
148
+ Kuhn3pEquilibriumPlayer patient = new_kuhn_3p_equilibrium_player(
149
+ &game_def,
150
+ params,
151
+ 12
152
+ );
153
+ }
154
+ Catch(e) {
155
+ TEST_FAIL_MESSAGE("Should Not Have Thrown An Error");
156
+ }
157
+
158
+ // When b11 > 1/6.0
159
+ params[B11_INDEX] = 1/4.0;
160
+ params[C11_INDEX] = (2 - params[B11_INDEX]) / (3 + 4 * params[B11_INDEX]) +
161
+ 0.01;
162
+ params[B32_INDEX] = 0.0;
163
+ params[C33_INDEX] = 1/2.0 - params[B32_INDEX];
164
+ params[C34_INDEX] = 3/4.0; // Unconstrained
165
+
166
+ Try {
167
+ Kuhn3pEquilibriumPlayer patient = new_kuhn_3p_equilibrium_player(
168
+ &game_def,
169
+ params,
170
+ 12
171
+ );
172
+ TEST_FAIL_MESSAGE("Should Have Thrown An Error");
173
+ }
174
+ Catch(e) {
175
+ TEST_ASSERT_EQUAL(1, e);
176
+ }
177
+ }
@@ -0,0 +1,30 @@
1
+ Copyright (c) 2007 Mark VanderVoord
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ The end-user documentation included with the redistribution, if
16
+ any, must include the following acknowledgment: "This product
17
+ includes software developed for the CEXCeption Project, by Mark
18
+ VanderVoord and other contributors", in the same place and form
19
+ as other third-party acknowledgments. Alternately, this
20
+ acknowledgment may appear in the software itself, in the same
21
+ form and location as other such third-party acknowledgments.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
25
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
27
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
28
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
30
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,242 @@
1
+ ====================================================================
2
+ CException
3
+ ====================================================================
4
+
5
+ CException is a basic exception framework for C, suitable for use in
6
+ embedded applications. It provides an exception framework similar in
7
+ use to C++, but with much less overhead.
8
+
9
+ CException uses C standard library functions setjmp and longjmp to
10
+ operate. As long as the target system has these two functions defined,
11
+ this library should be useable with very little configuration. It
12
+ even supports environments where multiple program flows are in use,
13
+ such as real-time operating systems.
14
+
15
+ There are about a gabillion exception frameworks using a similar
16
+ setjmp/longjmp method out there... and there will probably be more
17
+ in the future. Unfortunately, when we started our last embedded
18
+ project, all those that existed either (a) did not support multiple
19
+ tasks (therefore multiple stacks) or (b) were way more complex than
20
+ we really wanted. CException was born.
21
+
22
+ Why use CException?
23
+
24
+ 0. It's ANSI C, and it beats passing error codes around.
25
+
26
+ 1. You want something simple... CException throws a single id. You can
27
+ define those ID's to be whatever you like. You might even choose which
28
+ type that number is for your project. But that's as far as it goes.
29
+ We weren't interested in passing objects or structs or strings...
30
+ just simple error codes.
31
+
32
+ 2. Performance... CException can be configured for single tasking or
33
+ multitasking. In single tasking, there is very little overhead past
34
+ the setjmp/longjmp calls (which are already fast). In multitasking,
35
+ your only additional overhead is the time it takes you to determine
36
+ a unique task id 0 - num_tasks.
37
+
38
+ For the latest version, go to http://cexception.sourceforge.net
39
+
40
+ --------------------------------------------------------------------
41
+ CONTENTS OF THIS DOCUMENT
42
+ --------------------------------------------------------------------
43
+
44
+ Usage
45
+ Limitations
46
+ API
47
+ Configuration
48
+ Testing
49
+ License
50
+
51
+ --------------------------------------------------------------------
52
+ Usage
53
+ --------------------------------------------------------------------
54
+
55
+ Code that is to be protected are wrapped in Try { } Catch { } blocks.
56
+ The code directly following the Try call is "protected", meaning that
57
+ if any Throws occur, program control is directly transferred to the
58
+ start of the Catch block.
59
+
60
+ A numerical exception ID is included with Throw, and is made accessible
61
+ from the Catch block.
62
+
63
+ Throws can occur from within function calls (nested as deeply as you
64
+ like) or directly from within the function itself.
65
+
66
+ --------------------------------------------------------------------
67
+ Limitations
68
+ --------------------------------------------------------------------
69
+
70
+ This library was made to be as fast as possible, and provide basic
71
+ exception handling. It is not a full-blown exception library. Because
72
+ of this, there are a few limitations that should be observed in order
73
+ to successfully utilize this library:
74
+
75
+ 1. Do not directly "return" from within a Try block, nor "goto"
76
+ into or out of a Try block.
77
+
78
+ Why?
79
+
80
+ The "Try" macro allocates some local memory and alters a global
81
+ pointer. These are cleaned up at the top of the "Catch" macro.
82
+ Gotos and returns would bypass some of these steps, resulting in
83
+ memory leaks or unpredictable behavior.
84
+
85
+ 2. If (a) you change local (stack) variables within your Try block,
86
+ AND (b) wish to make use of the updated values after an exception
87
+ is thrown, those variables should be made volatile. Note that this
88
+ is ONLY for locals and ONLY when you need access to them after a
89
+ throw.
90
+
91
+ Why?
92
+
93
+ Compilers optimize. There is no way to guarantee that the actual
94
+ memory location was updated and not just a register unless the
95
+ variable is marked volatile.
96
+
97
+ 3. Memory which is malloc'd or new'd is not automatically released
98
+ when an error is thrown. This will sometimes be desirable, and
99
+ othertimes may not. It will be the responsibility of the Catch
100
+ block to perform this kind of cleanup.
101
+
102
+ Why?
103
+
104
+ There's just no easy way to track malloc'd memory, etc., without
105
+ replacing or wrapping malloc calls or something like that. This
106
+ is a light framework, so these options were not desirable.
107
+
108
+ --------------------------------------------------------------------
109
+ API
110
+ --------------------------------------------------------------------
111
+
112
+ Try
113
+ ---
114
+
115
+ Try is a macro which starts a protected block. It MUST be followed by
116
+ a pair of braces or a single protected line (similar to an 'if'),
117
+ enclosing the data that is to be protected. It MUST be followed by a
118
+ Catch block (don't worry, you'll get compiler errors to let you know if
119
+ you mess any of that up).
120
+
121
+ Catch(e)
122
+ --------
123
+
124
+ Catch is a macro which ends the Try block and starts the error handling
125
+ block. The catch block is called if and only if an exception was thrown
126
+ while within the Try block. This error was thrown by a Throw call
127
+ somewhere within Try (or within a function called within Try, or a function
128
+ called by a function called within Try, etc).
129
+
130
+ The single parameter 'e' is filled with the error code which was thrown.
131
+ This can be used for reporting, conditional cleanup, etc. (or you can just
132
+ ignore it if you really want... people ignore return codes all the time,
133
+ right?). 'e' should be of type EXCEPTION_T;
134
+
135
+ Throw(e)
136
+ --------
137
+
138
+ The method of throwing an error. Throws should only occur from within a
139
+ protected (Try...Catch) block, though it may easily be nested many function
140
+ calls deep without an impact on performance or functionality. Throw takes
141
+ a single argument, which is an exception id which will be passed to Catch
142
+ as the reason for the error.
143
+
144
+ If you wish to Rethrow an error, this can be done by calling Throw(e) with
145
+ the error code you just caught. It IS valid to throw from a catch block.
146
+
147
+ --------------------------------------------------------------------
148
+ CONFIGURATION
149
+ --------------------------------------------------------------------
150
+
151
+ CException is a mostly portable library. It has one universal
152
+ dependency, and some macros which are required if working in a
153
+ multi-tasking environment.
154
+
155
+ 1. The standard C library setjmp must be available. Since this is part
156
+ of the standard library, chances are good that you'll be fine.
157
+
158
+ 2. If working in a multitasking environment, methods for obtaining an
159
+ index into an array of frames and to get the overall number of
160
+ id's are required. If the OS supports a method to retrieve Task
161
+ ID's, and those Tasks are number 0, 1, 2... you are in an ideal
162
+ situation. Otherwise, a more creative mapping function may be
163
+ required. Note that this function is likely to be called twice
164
+ for each protected block and once during a throw. This is the
165
+ only overhead in the system.
166
+
167
+ Exception.h
168
+ -----------------
169
+ By convention, most projects include Exception.h which defines any
170
+ further requirements, then calls CException.h to do the gruntwork. All
171
+ of these are optional. You could directly include CException.h if
172
+ you wanted and just use the defaults provided.
173
+
174
+ EXCEPTION_T - Set this to the type you want your exception id's
175
+ to be. Defaults to 'unsigned int'.
176
+
177
+ EXCEPTION_NONE - Set this to a number which will never be an
178
+ exception id in your system. Defaults to 0x5a5a5a5a.
179
+
180
+ EXCEPTION_GET_ID - If in a multi-tasking environment, this should be
181
+ set to be a call to the function described in #2 above.
182
+ Defaults to just return 0 all the time (good for
183
+ single tasking environments)
184
+
185
+ EXCEPTION_NUM_ID - If in a multi-tasking environment, this should be set
186
+ to the number of ID's required (usually the number of
187
+ tasks in the system). Defaults to 1 (for single
188
+ tasking environments).
189
+
190
+ CEXCEPTION_NO_CATCH_HANDLER(id) - This macro can be optionally specified.
191
+ It allows you to specify code to be called when a Throw
192
+ is made outside of Try...Catch protection. Consider
193
+ this the emergency fallback plan for when something has
194
+ gone terribly wrong.
195
+
196
+ You may also want to include any header files which will commonly be
197
+ needed by the rest of your application where it uses exception handling
198
+ here. For example, OS header files or exception codes would be useful.
199
+
200
+ --------------------------------------------------------------------
201
+ TESTING
202
+ --------------------------------------------------------------------
203
+
204
+ If you want to validate that CException works with your tools or that
205
+ it works with your custom configuration, you may want to run the test
206
+ suite.
207
+
208
+ The test suite included makes use of the Unity Test Framework. It will
209
+ require a native C compiler. The example makefile uses MinGW's gcc.
210
+ Modify the makefile to include the proper paths to tools, then run 'make'
211
+ to compile and run the test application.
212
+
213
+ C_COMPILER - The C compiler to use to perform the tests
214
+ C_LIBS - The path to the C libraries (including setjmp)
215
+ UNITY_DIR - The path to the Unity framework (required to run tests)
216
+ (get it at http://unity.sourceforge.net)
217
+
218
+ --------------------------------------------------------------------
219
+ LICENSE
220
+ --------------------------------------------------------------------
221
+
222
+ This software is licensed under the MIT License
223
+
224
+ Copyright (c) 2007-2012 Mark VanderVoord
225
+
226
+ Permission is hereby granted, free of charge, to any person obtaining a copy
227
+ of this software and associated documentation files (the "Software"), to deal
228
+ in the Software without restriction, including without limitation the rights
229
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
230
+ copies of the Software, and to permit persons to whom the Software is
231
+ furnished to do so, subject to the following conditions:
232
+
233
+ The above copyright notice and this permission notice shall be included in
234
+ all copies or substantial portions of the Software.
235
+
236
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
237
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
238
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
239
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
240
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
241
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
242
+ THE SOFTWARE.