acpc_dealer 2.4.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/Brickfile +6 -0
  3. data/README.md +7 -6
  4. data/Rakefile +30 -14
  5. data/acpc_dealer.gemspec +2 -1
  6. data/bin/acpc_dealer +4 -0
  7. data/ext/hand_evaluator/extconf.rb +10 -0
  8. data/lib/acpc_dealer/version.rb +1 -1
  9. data/lib/hand_evaluator.bundle +0 -0
  10. data/spec/dealer_runner_spec.rb +76 -72
  11. metadata +19 -82
  12. data/vendor/project_acpc_server/LICENCE +0 -23
  13. data/vendor/project_acpc_server/Makefile +0 -35
  14. data/vendor/project_acpc_server/README +0 -113
  15. data/vendor/project_acpc_server/README.submission +0 -42
  16. data/vendor/project_acpc_server/acpc_play_match.pl +0 -101
  17. data/vendor/project_acpc_server/bm_run_matches.c +0 -238
  18. data/vendor/project_acpc_server/bm_server.c +0 -1604
  19. data/vendor/project_acpc_server/bm_server.config +0 -78
  20. data/vendor/project_acpc_server/bm_widget.c +0 -230
  21. data/vendor/project_acpc_server/dealer.c +0 -1293
  22. data/vendor/project_acpc_server/evalHandTables +0 -4269
  23. data/vendor/project_acpc_server/example_player.c +0 -204
  24. data/vendor/project_acpc_server/example_player.limit.2p.sh +0 -3
  25. data/vendor/project_acpc_server/example_player.limit.3p.sh +0 -3
  26. data/vendor/project_acpc_server/example_player.nolimit.2p.sh +0 -3
  27. data/vendor/project_acpc_server/example_player.nolimit.3p.sh +0 -3
  28. data/vendor/project_acpc_server/game.c +0 -1792
  29. data/vendor/project_acpc_server/game.h +0 -253
  30. data/vendor/project_acpc_server/holdem.limit.2p.reverse_blinds.game +0 -13
  31. data/vendor/project_acpc_server/holdem.limit.3p.game +0 -13
  32. data/vendor/project_acpc_server/holdem.nolimit.2p.reverse_blinds.game +0 -12
  33. data/vendor/project_acpc_server/holdem.nolimit.3p.game +0 -12
  34. data/vendor/project_acpc_server/kuhn.limit.3p.game +0 -14
  35. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player.sf1.sh +0 -3
  36. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player.sf2.sh +0 -3
  37. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player.sf3.sh +0 -3
  38. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/LICENCE +0 -23
  39. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/Makefile +0 -127
  40. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/README.md +0 -35
  41. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/CExceptionConfig.h +0 -12
  42. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/dealer_connection.c +0 -49
  43. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/dealer_connection.h +0 -22
  44. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/kuhn_3p_equilibrium_player.c +0 -483
  45. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/kuhn_3p_equilibrium_player.h +0 -108
  46. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/main.c +0 -84
  47. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/player_config.c +0 -253
  48. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/player_config.h +0 -21
  49. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/support/test_helper.c +0 -45
  50. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/support/test_helper.h +0 -27
  51. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/test_kuhn_3p_equilibrium_player.c +0 -698
  52. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/test_kuhn_3p_equilibrium_player_sub_family_1.c +0 -324
  53. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/test_kuhn_3p_equilibrium_player_sub_family_2.c +0 -262
  54. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/test_kuhn_3p_equilibrium_player_sub_family_3.c +0 -177
  55. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/docs/license.txt +0 -30
  56. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/docs/readme.txt +0 -242
  57. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/lib/CException.c +0 -43
  58. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/lib/CException.h +0 -86
  59. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/release/build.info +0 -2
  60. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/release/version.info +0 -2
  61. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/History.md +0 -27
  62. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/Makefile +0 -8
  63. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/Readme.md +0 -103
  64. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/package.json +0 -9
  65. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/src/commander.c +0 -250
  66. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/src/commander.h +0 -88
  67. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/test.c +0 -34
  68. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/colour_prompt.rb +0 -94
  69. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/colour_reporter.rb +0 -39
  70. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/generate_config.yml +0 -36
  71. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/generate_module.rb +0 -202
  72. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/generate_test_runner.rb +0 -316
  73. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/test_file_filter.rb +0 -23
  74. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/unity_test_summary.rb +0 -139
  75. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/docs/Unity Summary.txt +0 -216
  76. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/docs/license.txt +0 -31
  77. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/release/build.info +0 -2
  78. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/release/version.info +0 -2
  79. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/src/unity.c +0 -1146
  80. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/src/unity.h +0 -245
  81. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/src/unity_internals.h +0 -546
  82. data/vendor/project_acpc_server/net.c +0 -218
  83. data/vendor/project_acpc_server/net.h +0 -62
  84. data/vendor/project_acpc_server/play_match.pl +0 -99
  85. data/vendor/project_acpc_server/protocol.md +0 -239
  86. data/vendor/project_acpc_server/protocol.odt +0 -0
  87. data/vendor/project_acpc_server/protocol.pdf +0 -0
  88. data/vendor/project_acpc_server/rng.c +0 -139
  89. data/vendor/project_acpc_server/rng.h +0 -63
  90. data/vendor/project_acpc_server/validate_submission.pl +0 -546
@@ -1,45 +0,0 @@
1
- /*
2
- Copyright (C) 2013 by the Computer Poker Research Group, University of Alberta
3
- */
4
-
5
- #include "test_helper.h"
6
-
7
- Game init_kuhn_poker_game_def()
8
- {
9
- Game kuhn_def;
10
-
11
- kuhn_def.bettingType = limitBetting;
12
- kuhn_def.numRounds = 1;
13
- kuhn_def.maxRaises[ 0 ] = 1;
14
- kuhn_def.numSuits = 1;
15
- kuhn_def.numRanks = 4;
16
- kuhn_def.numHoleCards = 1;
17
- kuhn_def.numBoardCards[ 0 ] = 0;
18
- kuhn_def.numPlayers = 3;
19
-
20
- return kuhn_def;
21
- }
22
-
23
- MatchState init_match_state(
24
- const Game const* game_def,
25
- uint8_t position,
26
- uint8_t card,
27
- const enum ActionType const* actions,
28
- size_t num_actions
29
- )
30
- {
31
- MatchState view;
32
-
33
- view.viewingPlayer = position;
34
- view.state.actingPlayer[0][num_actions -1] = position;
35
- view.state.numActions[0] = num_actions;
36
-
37
- for (size_t i = 0; i < num_actions; ++i)
38
- {
39
- view.state.action[0][i].type = actions[i];
40
- }
41
- view.state.holeCards[position][0] = card;
42
- view.state.round = 0;
43
-
44
- return view;
45
- }
@@ -1,27 +0,0 @@
1
- /*
2
- Copyright (C) 2013 by the Computer Poker Research Group, University of Alberta
3
- */
4
-
5
- #ifndef __TEST_HELPER__
6
- #define __TEST_HELPER__
7
-
8
- #include <stdio.h>
9
- #include "game.h"
10
-
11
- #include <unity.h>
12
- #include <CException.h>
13
-
14
- Game init_kuhn_poker_game_def();
15
- MatchState init_match_state(
16
- const Game const* game_def,
17
- uint8_t position,
18
- uint8_t card,
19
- const enum ActionType const* actions,
20
- size_t num_actions
21
- );
22
-
23
- #define DEBUG_PRINT(...) \
24
- printf(__VA_ARGS__); \
25
- fflush(NULL);
26
-
27
- #endif
@@ -1,698 +0,0 @@
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_init_private_info_throws_error_when_game_def_not_kuhn()
33
- {
34
- Game game_def;
35
-
36
- CEXCEPTION_T e = 0;
37
-
38
- Try
39
- {
40
- double params[NUM_PARAMS] = {0.1};
41
- new_kuhn_3p_equilibrium_player(&game_def, params, 12);
42
- TEST_FAIL_MESSAGE("Should Have Thrown An Error");
43
- }
44
- Catch(e)
45
- {
46
- TEST_ASSERT_EQUAL(1, e);
47
- }
48
- }
49
-
50
- void test_init_private_info_does_not_crash()
51
- {
52
- Game game_def = init_kuhn_poker_game_def();
53
-
54
- double params[NUM_PARAMS] = {0};
55
- params[C11_INDEX] = 0.0;
56
- params[B11_INDEX] = 0.25;
57
- params[B21_INDEX] = 0.25;
58
- params[B32_INDEX] = 0.9375;
59
- params[C33_INDEX] = 0.0;
60
- params[C34_INDEX] = 1.0;
61
-
62
- CEXCEPTION_T e = 0;
63
-
64
- Try {
65
- Kuhn3pEquilibriumPlayer patient = new_kuhn_3p_equilibrium_player(
66
- &game_def,
67
- params,
68
- 12
69
- );
70
- }
71
- Catch(e) {
72
- TEST_FAIL_MESSAGE("Should Not Have Thrown An Error");
73
- }
74
- }
75
-
76
- void test_out_of_bounds_c11_throws_error()
77
- {
78
- Game game_def = init_kuhn_poker_game_def();
79
-
80
- CEXCEPTION_T e = 0;
81
-
82
- Try
83
- {
84
- double params[NUM_PARAMS] = {0};
85
- params[C11_INDEX] = 0.51;
86
- params[B11_INDEX] = 0.25;
87
- params[B21_INDEX] = 0.25;
88
- params[B32_INDEX] = 0.9375;
89
- params[C33_INDEX] = 0.0;
90
- params[C34_INDEX] = 1.0;
91
-
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
- {
101
- TEST_ASSERT_EQUAL(1, e);
102
- }
103
- }
104
-
105
- void test_param_invalid_probability_throws_error()
106
- {
107
- Game game_def = init_kuhn_poker_game_def();
108
-
109
- CEXCEPTION_T e = 0;
110
-
111
- double params[NUM_PARAMS] = {0};
112
- params[C11_INDEX] = 0.0;
113
- params[B11_INDEX] = 0.25;
114
- params[B21_INDEX] = 0.25;
115
- params[B32_INDEX] = 0.9375;
116
- params[C33_INDEX] = 0.0;
117
- params[C34_INDEX] = 1.0;
118
-
119
- for (float invalid_param = -0.1; invalid_param < 2.0; invalid_param += 2.0)
120
- {
121
- Try
122
- {
123
- params[C34_INDEX] = invalid_param;
124
-
125
- Kuhn3pEquilibriumPlayer patient = new_kuhn_3p_equilibrium_player(
126
- &game_def,
127
- params,
128
- 12
129
- );
130
- TEST_FAIL_MESSAGE("Should Have Thrown An Error");
131
- }
132
- Catch(e)
133
- {
134
- TEST_ASSERT_EQUAL(1, e);
135
- }
136
- }
137
- }
138
-
139
- void test_action_probs_in_position_A()
140
- {
141
- Game game_def = init_kuhn_poker_game_def();
142
-
143
- #define NUM_PARAM_LISTS 3
144
-
145
- double* params_list[NUM_PARAM_LISTS] = {0};
146
-
147
- double params1[NUM_PARAMS] = {0};
148
- params1[C11_INDEX] = 0.0;
149
- params1[B11_INDEX] = 0.25;
150
- params1[B21_INDEX] = 0.25;
151
- params1[B32_INDEX] = 0.9375;
152
- params1[C33_INDEX] = 0.0;
153
- params1[C34_INDEX] = 1.0;
154
-
155
- double params2[NUM_PARAMS] = {0};
156
- params2[C11_INDEX] = 0.5;
157
- params2[B11_INDEX] = 0.25;
158
- params2[B21_INDEX] = 1/2.0 - 2 * params2[B11_INDEX];
159
- params2[B23_INDEX] = (params2[B11_INDEX] - params2[B21_INDEX]) /
160
- (2 * (1 - params2[B21_INDEX]));
161
- params2[B32_INDEX] = (2 + 4*params2[B11_INDEX] + 3 * params2[B21_INDEX]) / 4.0;
162
- params2[C33_INDEX] = 1/2.0 - params2[B32_INDEX] +
163
- (4 * params2[B11_INDEX] + 3 * params2[B21_INDEX]) / 4.0;
164
- params2[C34_INDEX] = 3/4.0; // Unconstrained
165
-
166
- double params3[NUM_PARAMS] = {0};
167
- params3[C11_INDEX] = 0.33;
168
- params3[B11_INDEX] = 1/6.0;
169
- params3[B32_INDEX] = (2 + 7 * params3[B11_INDEX]) / 4.0;
170
- params3[C33_INDEX] = 1/2.0 - params3[B32_INDEX] + (7/4.0) * params3[B11_INDEX];
171
- params3[C34_INDEX] = 3/4.0; // Unconstrained
172
-
173
- params_list[0] = params1;
174
- params_list[1] = params2;
175
- params_list[2] = params3;
176
-
177
- CEXCEPTION_T e = 0;
178
-
179
- Try
180
- {
181
- for (size_t i = 0; i < NUM_PARAM_LISTS; ++i) {
182
- Kuhn3pEquilibriumPlayer patient = new_kuhn_3p_equilibrium_player(
183
- &game_def,
184
- params_list[i],
185
- 12
186
- );
187
-
188
- size_t num_actions = 0;
189
-
190
- double probs[NUM_ACTION_TYPES];
191
- memset(probs, -1, NUM_ACTION_TYPES * sizeof(*probs));
192
-
193
- enum ActionType actions1[] = {};
194
- enum ActionType actions2[] = {a_call, a_call, a_raise};
195
- enum ActionType actions3[] = {a_call, a_raise, a_fold};
196
- enum ActionType actions4[] = {a_call, a_raise, a_call};
197
-
198
- for (CardRank card_rank = JACK_RANK; card_rank <= ACE_RANK; ++card_rank)
199
- {
200
- // Situation 1
201
- num_actions = 0;
202
- memset(probs, -1, NUM_ACTION_TYPES * sizeof(*probs));
203
-
204
- action_probs(
205
- &patient,
206
- init_match_state(
207
- &game_def,
208
- A_POSITION,
209
- makeCard(card_rank, KUHN_SUIT),
210
- actions1,
211
- num_actions
212
- ),
213
- probs
214
- );
215
-
216
- TEST_ASSERT_EQUAL_FLOAT(0.0, probs[a_fold]);
217
- TEST_ASSERT_EQUAL_FLOAT(1 - A[card_rank - JACK_RANK][0], probs[a_call]);
218
- TEST_ASSERT_EQUAL_FLOAT(A[card_rank - JACK_RANK][0], probs[a_raise]);
219
-
220
- // Situation 2
221
- num_actions = 3;
222
- memset(probs, -1, NUM_ACTION_TYPES * sizeof(*probs));
223
-
224
- action_probs(
225
- &patient,
226
- init_match_state(
227
- &game_def,
228
- A_POSITION,
229
- makeCard(card_rank, KUHN_SUIT),
230
- actions2,
231
- num_actions
232
- ),
233
- probs
234
- );
235
- TEST_ASSERT_EQUAL_FLOAT(
236
- 1 - A[card_rank - JACK_RANK][1], probs[a_fold]
237
- );
238
- TEST_ASSERT_EQUAL_FLOAT(A[card_rank - JACK_RANK][1], probs[a_call]);
239
- TEST_ASSERT_EQUAL_FLOAT(0.0, probs[a_raise]);
240
-
241
- // Situation 3
242
- num_actions = 3;
243
- memset(probs, -1, NUM_ACTION_TYPES * sizeof(*probs));
244
-
245
- action_probs(
246
- &patient,
247
- init_match_state(
248
- &game_def,
249
- A_POSITION,
250
- makeCard(card_rank, KUHN_SUIT),
251
- actions3,
252
- num_actions
253
- ),
254
- probs
255
- );
256
- TEST_ASSERT_EQUAL_FLOAT(1 - A[card_rank - JACK_RANK][2], probs[a_fold]);
257
- TEST_ASSERT_EQUAL_FLOAT(A[card_rank - JACK_RANK][2], probs[a_call]);
258
- TEST_ASSERT_EQUAL_FLOAT(0.0, probs[a_raise]);
259
-
260
- // Situation 4
261
- num_actions = 3;
262
- memset(probs, -1, NUM_ACTION_TYPES * sizeof(*probs));
263
-
264
- action_probs(
265
- &patient,
266
- init_match_state(
267
- &game_def,
268
- A_POSITION,
269
- makeCard(card_rank, KUHN_SUIT),
270
- actions4,
271
- num_actions
272
- ),
273
- probs
274
- );
275
- TEST_ASSERT_EQUAL_FLOAT(
276
- 1 - A[card_rank - JACK_RANK][3], probs[a_fold]
277
- );
278
- TEST_ASSERT_EQUAL_FLOAT(A[card_rank - JACK_RANK][3], probs[a_call]);
279
- TEST_ASSERT_EQUAL_FLOAT(0.0, probs[a_raise]);
280
- }
281
- }
282
- }
283
- Catch(e)
284
- {
285
- TEST_FAIL_MESSAGE("Should Not Have Thrown An Error");
286
- }
287
- }
288
-
289
- void test_action_probs_in_position_B()
290
- {
291
- Game game_def = init_kuhn_poker_game_def();
292
-
293
- #define NUM_PARAM_LISTS 3
294
-
295
- double* params_list[NUM_PARAM_LISTS] = {0};
296
-
297
- double params1[NUM_PARAMS] = {0};
298
- params1[C11_INDEX] = 0.0;
299
- params1[B11_INDEX] = 0.25;
300
- params1[B21_INDEX] = 0.25;
301
- params1[B32_INDEX] = 0.9375;
302
- params1[C33_INDEX] = 0.0;
303
- params1[C34_INDEX] = 1.0;
304
-
305
- double params2[NUM_PARAMS] = {0};
306
- params2[C11_INDEX] = 0.5;
307
- params2[B11_INDEX] = 0.25;
308
- params2[B21_INDEX] = 1/2.0 - 2 * params2[B11_INDEX];
309
- params2[B23_INDEX] = (params2[B11_INDEX] - params2[B21_INDEX]) /
310
- (2 * (1 - params2[B21_INDEX]));
311
- params2[B32_INDEX] = (2 + 4*params2[B11_INDEX] + 3 * params2[B21_INDEX]) / 4.0;
312
- params2[C33_INDEX] = 1/2.0 - params2[B32_INDEX] +
313
- (4 * params2[B11_INDEX] + 3 * params2[B21_INDEX]) / 4.0;
314
- params2[C34_INDEX] = 3/4.0; // Unconstrained
315
-
316
- double params3[NUM_PARAMS] = {0};
317
- params3[C11_INDEX] = 0.33;
318
- params3[B11_INDEX] = 1/6.0;
319
- params3[B32_INDEX] = (2 + 7 * params3[B11_INDEX]) / 4.0;
320
- params3[C33_INDEX] = 1/2.0 - params3[B32_INDEX] + (7/4.0) * params3[B11_INDEX];
321
- params3[C34_INDEX] = 3/4.0; // Unconstrained
322
-
323
- params_list[0] = params1;
324
- params_list[1] = params2;
325
- params_list[2] = params3;
326
-
327
- CEXCEPTION_T e = 0;
328
-
329
- Try
330
- {
331
- for (size_t i = 0; i < NUM_PARAM_LISTS; ++i) {
332
- Kuhn3pEquilibriumPlayer patient = new_kuhn_3p_equilibrium_player(
333
- &game_def,
334
- params_list[i],
335
- 12
336
- );
337
-
338
- double probs[NUM_ACTION_TYPES];
339
- memset(probs, -1, NUM_ACTION_TYPES * sizeof(*probs));
340
- size_t num_actions = 0;
341
- MatchState view;
342
-
343
- enum ActionType actions1[] = {a_call};
344
- enum ActionType actions2[] = {a_raise};
345
- enum ActionType actions3[] = {
346
- a_call, a_call, a_raise, a_fold
347
- };
348
- enum ActionType actions4[] = {
349
- a_call, a_call, a_raise, a_call
350
- };
351
- double param;
352
-
353
- for (CardRank card_rank = JACK_RANK; card_rank <= ACE_RANK; ++card_rank)
354
- {
355
- // Situation 1
356
- num_actions = 1;
357
- memset(probs, -1, NUM_ACTION_TYPES * sizeof(*probs));
358
-
359
- switch (card_rank)
360
- {
361
- case JACK_RANK:
362
- param = patient.params[B11_INDEX];
363
- break;
364
- case QUEEN_RANK:
365
- param = patient.params[B21_INDEX];
366
- break;
367
- case KING_RANK:
368
- param = B31;
369
- break;
370
- default:
371
- param = patient.params[B41_INDEX];
372
- }
373
- action_probs(
374
- &patient,
375
- init_match_state(
376
- &game_def,
377
- B_POSITION,
378
- makeCard(card_rank, KUHN_SUIT),
379
- actions1,
380
- num_actions
381
- ),
382
- probs
383
- );
384
-
385
- TEST_ASSERT_EQUAL_FLOAT(0.0, probs[a_fold]);
386
- TEST_ASSERT_EQUAL_FLOAT(1 - param, probs[a_call]);
387
- TEST_ASSERT_EQUAL_FLOAT(param, probs[a_raise]);
388
-
389
- // Situation 2
390
- num_actions = 1;
391
- memset(probs, -1, NUM_ACTION_TYPES * sizeof(*probs));
392
-
393
- switch (card_rank)
394
- {
395
- case JACK_RANK:
396
- param = B12;
397
- break;
398
- case QUEEN_RANK:
399
- param = B22;
400
- break;
401
- case KING_RANK:
402
- param = patient.params[B32_INDEX];
403
- break;
404
- default:
405
- param = B42;
406
- }
407
- action_probs(
408
- &patient,
409
- init_match_state(
410
- &game_def,
411
- B_POSITION,
412
- makeCard(card_rank, KUHN_SUIT),
413
- actions2,
414
- num_actions
415
- ),
416
- probs
417
- );
418
-
419
- TEST_ASSERT_EQUAL_FLOAT(1 - param, probs[a_fold]);
420
- TEST_ASSERT_EQUAL_FLOAT(param, probs[a_call]);
421
- TEST_ASSERT_EQUAL_FLOAT(0.0, probs[a_raise]);
422
-
423
- // Situation 3
424
- num_actions = 4;
425
- memset(probs, -1, NUM_ACTION_TYPES * sizeof(*probs));
426
-
427
- switch (card_rank)
428
- {
429
- case JACK_RANK:
430
- param = B13;
431
- break;
432
- case QUEEN_RANK:
433
- param = patient.params[B23_INDEX];
434
- break;
435
- case KING_RANK:
436
- param = patient.params[B33_INDEX];
437
- break;
438
- default:
439
- param = B43;
440
- }
441
- action_probs(
442
- &patient,
443
- init_match_state(
444
- &game_def,
445
- B_POSITION,
446
- makeCard(card_rank, KUHN_SUIT),
447
- actions3,
448
- num_actions
449
- ),
450
- probs
451
- );
452
-
453
- TEST_ASSERT_EQUAL_FLOAT(1 - param, probs[a_fold]);
454
- TEST_ASSERT_EQUAL_FLOAT(param, probs[a_call]);
455
- TEST_ASSERT_EQUAL_FLOAT(0.0, probs[a_raise]);
456
-
457
- // Situation 4
458
- num_actions = 4;
459
- memset(probs, -1, NUM_ACTION_TYPES * sizeof(*probs));
460
-
461
- switch (card_rank)
462
- {
463
- case JACK_RANK:
464
- param = B14;
465
- break;
466
- case QUEEN_RANK:
467
- param = B24;
468
- break;
469
- case KING_RANK:
470
- param = B34;
471
- break;
472
- default:
473
- param = B44;
474
- }
475
- action_probs(
476
- &patient,
477
- init_match_state(
478
- &game_def,
479
- B_POSITION,
480
- makeCard(card_rank, KUHN_SUIT),
481
- actions4,
482
- num_actions
483
- ),
484
- probs
485
- );
486
-
487
- TEST_ASSERT_EQUAL_FLOAT(1 - param, probs[a_fold]);
488
- TEST_ASSERT_EQUAL_FLOAT(param, probs[a_call]);
489
- TEST_ASSERT_EQUAL_FLOAT(0.0, probs[a_raise]);
490
- }
491
- }
492
- }
493
- Catch(e)
494
- {
495
- TEST_FAIL_MESSAGE("Should Not Have Thrown An Error");
496
- }
497
- }
498
-
499
- void test_action_probs_in_position_C()
500
- {
501
- Game game_def = init_kuhn_poker_game_def();
502
-
503
- #define NUM_PARAM_LISTS 3
504
-
505
- double* params_list[NUM_PARAM_LISTS] = {0};
506
-
507
- double params1[NUM_PARAMS] = {0};
508
- params1[C11_INDEX] = 0.0;
509
- params1[B11_INDEX] = 0.25;
510
- params1[B21_INDEX] = 0.25;
511
- params1[B32_INDEX] = 0.9375;
512
- params1[C33_INDEX] = 0.0;
513
- params1[C34_INDEX] = 1.0;
514
-
515
- double params2[NUM_PARAMS] = {0};
516
- params2[C11_INDEX] = 0.5;
517
- params2[B11_INDEX] = 0.25;
518
- params2[B21_INDEX] = 1/2.0 - 2 * params2[B11_INDEX];
519
- params2[B23_INDEX] = (params2[B11_INDEX] - params2[B21_INDEX]) /
520
- (2 * (1 - params2[B21_INDEX]));
521
- params2[B32_INDEX] = (2 + 4*params2[B11_INDEX] + 3 * params2[B21_INDEX]) / 4.0;
522
- params2[C33_INDEX] = 1/2.0 - params2[B32_INDEX] +
523
- (4 * params2[B11_INDEX] + 3 * params2[B21_INDEX]) / 4.0;
524
- params2[C34_INDEX] = 3/4.0; // Unconstrained
525
-
526
- double params3[NUM_PARAMS] = {0};
527
- params3[C11_INDEX] = 0.33;
528
- params3[B11_INDEX] = 1/6.0;
529
- params3[B32_INDEX] = (2 + 7 * params3[B11_INDEX]) / 4.0;
530
- params3[C33_INDEX] = 1/2.0 - params3[B32_INDEX] + (7/4.0) * params3[B11_INDEX];
531
- params3[C34_INDEX] = 3/4.0; // Unconstrained
532
-
533
- params_list[0] = params1;
534
- params_list[1] = params2;
535
- params_list[2] = params3;
536
-
537
- CEXCEPTION_T e = 0;
538
-
539
- Try
540
- {
541
- for (size_t i = 0; i < NUM_PARAM_LISTS; ++i) {
542
- Kuhn3pEquilibriumPlayer patient = new_kuhn_3p_equilibrium_player(
543
- &game_def,
544
- params_list[i],
545
- 12
546
- );
547
- double probs[NUM_ACTION_TYPES];
548
- memset(probs, -1, NUM_ACTION_TYPES * sizeof(*probs));
549
- size_t num_actions = 2;
550
- MatchState view;
551
-
552
- enum ActionType actions1[] = {a_call, a_call};
553
- enum ActionType actions2[] = {a_call, a_raise};
554
- enum ActionType actions3[] = {a_raise, a_fold};
555
- enum ActionType actions4[] = {a_raise, a_call};
556
- double param;
557
-
558
- for (CardRank card_rank = JACK_RANK; card_rank <= ACE_RANK; ++card_rank)
559
- {
560
- // Situation 1
561
- memset(probs, -1, NUM_ACTION_TYPES * sizeof(*probs));
562
-
563
- switch (card_rank)
564
- {
565
- case JACK_RANK:
566
- param = patient.params[C11_INDEX];
567
- break;
568
- case QUEEN_RANK:
569
- param = patient.params[C21_INDEX];
570
- break;
571
- case KING_RANK:
572
- param = C31;
573
- break;
574
- default:
575
- param = C4[0];
576
- }
577
- action_probs(
578
- &patient,
579
- init_match_state(
580
- &game_def,
581
- C_POSITION,
582
- makeCard(card_rank, KUHN_SUIT),
583
- actions1,
584
- num_actions
585
- ),
586
- probs
587
- );
588
-
589
- TEST_ASSERT_EQUAL_FLOAT(0.0, probs[a_fold]);
590
- TEST_ASSERT_EQUAL_FLOAT(1 - param, probs[a_call]);
591
- TEST_ASSERT_EQUAL_FLOAT(param, probs[a_raise]);
592
-
593
- // Situation 2
594
- memset(probs, -1, NUM_ACTION_TYPES * sizeof(*probs));
595
-
596
- switch (card_rank)
597
- {
598
- case JACK_RANK:
599
- param = C12;
600
- break;
601
- case QUEEN_RANK:
602
- param = C22;
603
- break;
604
- case KING_RANK:
605
- param = C32;
606
- break;
607
- default:
608
- param = C4[1];
609
- }
610
- action_probs(
611
- &patient,
612
- init_match_state(
613
- &game_def,
614
- C_POSITION,
615
- makeCard(card_rank, KUHN_SUIT),
616
- actions2,
617
- num_actions
618
- ),
619
- probs
620
- );
621
-
622
- TEST_ASSERT_EQUAL_FLOAT(1 - param, probs[a_fold]);
623
- TEST_ASSERT_EQUAL_FLOAT(param, probs[a_call]);
624
- TEST_ASSERT_EQUAL_FLOAT(0.0, probs[a_raise]);
625
-
626
- // Situation 3
627
- memset(probs, -1, NUM_ACTION_TYPES * sizeof(*probs));
628
-
629
- switch (card_rank)
630
- {
631
- case JACK_RANK:
632
- param = C13;
633
- break;
634
- case QUEEN_RANK:
635
- param = C23;
636
- break;
637
- case KING_RANK:
638
- param = patient.params[C33_INDEX];
639
- break;
640
- default:
641
- param = C4[2];
642
- }
643
- action_probs(
644
- &patient,
645
- init_match_state(
646
- &game_def,
647
- C_POSITION,
648
- makeCard(card_rank, KUHN_SUIT),
649
- actions3,
650
- num_actions
651
- ),
652
- probs
653
- );
654
-
655
- TEST_ASSERT_EQUAL_FLOAT(1 - param, probs[a_fold]);
656
- TEST_ASSERT_EQUAL_FLOAT(param, probs[a_call]);
657
- TEST_ASSERT_EQUAL_FLOAT(0.0, probs[a_raise]);
658
-
659
- // Situation 4
660
- memset(probs, -1, NUM_ACTION_TYPES * sizeof(*probs));
661
-
662
- switch (card_rank)
663
- {
664
- case JACK_RANK:
665
- param = C14;
666
- break;
667
- case QUEEN_RANK:
668
- param = C24;
669
- break;
670
- case KING_RANK:
671
- param = patient.params[C34_INDEX];
672
- break;
673
- default:
674
- param = C4[3];
675
- }
676
- action_probs(
677
- &patient,
678
- init_match_state(
679
- &game_def,
680
- C_POSITION,
681
- makeCard(card_rank, KUHN_SUIT),
682
- actions4,
683
- num_actions
684
- ),
685
- probs
686
- );
687
-
688
- TEST_ASSERT_EQUAL_FLOAT(1 - param, probs[a_fold]);
689
- TEST_ASSERT_EQUAL_FLOAT(param, probs[a_call]);
690
- TEST_ASSERT_EQUAL_FLOAT(0.0, probs[a_raise]);
691
- }
692
- }
693
- }
694
- Catch(e)
695
- {
696
- TEST_FAIL_MESSAGE("Should Not Have Thrown An Error");
697
- }
698
- }