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,139 +0,0 @@
1
- /*
2
- A C-program for MT19937, with initialization improved 2002/1/26.
3
- Coded by Takuji Nishimura and Makoto Matsumoto.
4
-
5
- Before using, initialize the state by using init_genrand(seed)
6
- or init_by_array(init_key, key_length).
7
-
8
- Copyright (C) 2011 by the Computer Poker Research Group, University of
9
- Alberta
10
-
11
- This file is a modification of work by Makoto Matsumoto and Takuji
12
- Nishimura. That work was provided with the following license:
13
-
14
- Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
15
- All rights reserved.
16
-
17
- Redistribution and use in source and binary forms, with or without
18
- modification, are permitted provided that the following conditions
19
- are met:
20
-
21
- 1. Redistributions of source code must retain the above copyright
22
- notice, this list of conditions and the following disclaimer.
23
-
24
- 2. Redistributions in binary form must reproduce the above copyright
25
- notice, this list of conditions and the following disclaimer in the
26
- documentation and/or other materials provided with the distribution.
27
-
28
- 3. The names of its contributors may not be used to endorse or promote
29
- products derived from this software without specific prior written
30
- permission.
31
-
32
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
35
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
36
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
37
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
38
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
39
- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
40
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
41
- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
42
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43
-
44
-
45
- Any feedback is very welcome.
46
- http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
47
- email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
48
- */
49
-
50
- #include "rng.h"
51
-
52
- /* NOTE changes made on 2005/9/7 by Neil Burch - if you have problems
53
- with this code, DON'T complain to Makoto Matsumoto... */
54
-
55
-
56
- /* initializes mt[RNG_N] with a seed */
57
- void init_genrand( rng_state_t *state, uint32_t s )
58
- {
59
- state->mt[0]= s & 0xffffffffUL;
60
- for (state->mti=1; state->mti<RNG_N; state->mti++) {
61
- state->mt[state->mti] =
62
- (1812433253UL * (state->mt[state->mti-1]
63
- ^ (state->mt[state->mti-1] >> 30))
64
- + state->mti);
65
- /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
66
- /* In the previous versions, MSBs of the seed affect */
67
- /* only MSBs of the array mt[]. */
68
- /* 2002/01/09 modified by Makoto Matsumoto */
69
- }
70
- }
71
-
72
- /* initialize by an array with array-length */
73
- /* init_key is the array for initializing keys */
74
- /* key_length is its length */
75
- /* slight change for C++, 2004/2/26 */
76
- void init_by_array( rng_state_t *state, uint32_t init_key[], int key_length )
77
- {
78
- int i, j, k;
79
-
80
- init_genrand(state, 19650218UL);
81
- i=1; j=0;
82
- k = (RNG_N>key_length ? RNG_N : key_length);
83
- for (; k; k--) {
84
- state->mt[i] = ( state->mt[i]
85
- ^ ( ( state->mt[i-1] ^ ( state->mt[i-1] >> 30 ) )
86
- * 1664525UL ) )
87
- + init_key[j] + j; /* non linear */
88
- i++; j++;
89
- if (i>=RNG_N) { state->mt[0] = state->mt[RNG_N-1]; i=1; }
90
- if (j>=key_length) j=0;
91
- }
92
- for (k=RNG_N-1; k; k--) {
93
- state->mt[i] = ( state->mt[i]
94
- ^ ( ( state->mt[i-1] ^ ( state->mt[i-1] >> 30 ) )
95
- * 1566083941UL ) )
96
- - i; /* non linear */
97
- state->mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
98
- i++;
99
- if (i>=RNG_N) { state->mt[0] = state->mt[RNG_N-1]; i=1; }
100
- }
101
-
102
- state->mt[0]|= 0x80000000UL; /* MSB is 1; assuring non-zero initial array */
103
- }
104
-
105
- /* generates a random number on [0,0xffffffff]-interval */
106
- uint32_t genrand_int32( rng_state_t *state )
107
- {
108
- uint32_t y;
109
- static uint32_t mag01[2]={0x0UL, MATRIX_A};
110
- /* mag01[x] = x * MATRIX_A for x=0,1 */
111
-
112
- if (state->mti == RNG_N) { /* generate RNG_N words at one time */
113
- int kk;
114
-
115
- for (kk=0;kk<RNG_N-RNG_M;kk++) {
116
- y = (state->mt[kk]&UPPER_MASK)|(state->mt[kk+1]&LOWER_MASK);
117
- state->mt[kk] = state->mt[kk+RNG_M] ^ (y >> 1) ^ mag01[y & 0x1UL];
118
- }
119
- for (;kk<RNG_N-1;kk++) {
120
- y = (state->mt[kk]&UPPER_MASK)|(state->mt[kk+1]&LOWER_MASK);
121
- state->mt[kk] =
122
- state->mt[kk+(RNG_M-RNG_N)] ^ (y >> 1) ^ mag01[y & 0x1UL];
123
- }
124
- y = (state->mt[RNG_N-1]&UPPER_MASK)|(state->mt[0]&LOWER_MASK);
125
- state->mt[RNG_N-1] = state->mt[RNG_M-1] ^ (y >> 1) ^ mag01[y & 0x1UL];
126
-
127
- state->mti = 0;
128
- }
129
-
130
- y = state->mt[state->mti++];
131
-
132
- /* Tempering */
133
- y ^= (y >> 11);
134
- y ^= (y << 7) & 0x9d2c5680UL;
135
- y ^= (y << 15) & 0xefc60000UL;
136
- y ^= (y >> 18);
137
-
138
- return y;
139
- }
@@ -1,63 +0,0 @@
1
- /*
2
- Copyright (C) 2011 by the Computer Poker Research Group, University of
3
- Alberta
4
- Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
5
- All rights reserved.
6
- */
7
-
8
- #ifndef _RNG_H
9
- #define _RNG_H
10
- #define __STDC_FORMAT_MACROS
11
- #include <inttypes.h>
12
-
13
-
14
- /* functions included in Takuji Nishimura and Makoto Matsumoto's RNG code */
15
- /* NOTE changes made on 2005/9/7 by Neil Burch - if you have problems
16
- with this code, DON'T complain to Makoto Matsumoto... */
17
-
18
-
19
- /* Period parameters */
20
- #define RNG_N 624
21
- #define RNG_M 397
22
- #define MATRIX_A 0x9908b0dfUL /* constant vector a */
23
- #define UPPER_MASK 0x80000000UL /* most significant w-r bits */
24
- #define LOWER_MASK 0x7fffffffUL /* least significant r bits */
25
-
26
-
27
- typedef struct {
28
- uint32_t mt[ RNG_N ];
29
- int mti;
30
- } rng_state_t;
31
-
32
-
33
- /* initializes rng state using an integer seed */
34
- void init_genrand( rng_state_t *state, uint32_t s );
35
-
36
- /* initialize by an array with array-length */
37
- /* init_key is the array for initializing keys */
38
- /* key_length is its length */
39
- void init_by_array( rng_state_t *state, uint32_t init_key[], int key_length );
40
-
41
-
42
- /* all of the functions below can not be called until init_* has been called */
43
-
44
- /* generates a random number on [0,0xffffffff]-interval */
45
- uint32_t genrand_int32( rng_state_t *state );
46
-
47
- /* generates a random number on [0,0xffffffff]-interval */
48
- #define genrand_int31(state) ((int32_t)(genrand_int32(state)>>1))
49
-
50
- /* These real versions are due to Isaku Wada, 2002/01/09 added */
51
- /* generates a random number on [0,1]-real-interval */
52
- #define genrand_real1(state) (genrand_int32(state)*(1.0/4294967295.0))
53
-
54
- /* generates a random number on [0,1)-real-interval */
55
- #define genrand_real2(state) (genrand_int32(state)*(1.0/4294967296.0))
56
-
57
- /* generates a random number on (0,1)-real-interval */
58
- #define genrand_real3(state) ((((double)genrand_int32(state))+0.5)*(1.0/4294967296.0))
59
-
60
- /* generates a random number on [0,1) with 53-bit resolution*/
61
- #define genrand_res53(state) (((genrand_int32(state)>>5)*67108864.0+(genrand_int32(state)>>6))*(1.0/9007199254740992.0))
62
-
63
- #endif
@@ -1,546 +0,0 @@
1
- #!/usr/bin/perl -w
2
-
3
- # Copyright (C) 2011 by the Computer Poker Research Group, University of Alberta
4
-
5
- use strict;
6
-
7
- use POSIX;
8
- use File::Path;
9
- use File::Copy;
10
- use File::Spec;
11
- use File::stat;
12
- use Getopt::Long;
13
- use Pod::Usage;
14
-
15
- ###############
16
- # Main script #
17
- ###############
18
-
19
- # There are several variables that should be set here by the competition
20
- # organizer specifying what minimum length of testing is desired
21
-
22
- my $max_submission_size = 50 * ( 1024 ** 3 ); # 50Gb of disk
23
- my $max_avg_millisec_per_hand = 7 * 1000; # 7 sec average per hand
24
- my $max_response_millisec = 10 * 60 * 1000; #10 minute max per response
25
- my $max_millisec_per_hand = $max_avg_millisec_per_hand * 3000; # Unconstrained
26
- my $max_shutdown_secs = 10; # Agents have 10 seconds to shutdown after a match
27
- my $min_test_hands = 12000;
28
- my $num_test_hands = 12000;
29
-
30
- my %game_types = (
31
- "submission_2pl" => {
32
- game_def => "holdem.limit.2p.reverse_blinds.game",
33
- chump => "example_player.limit.2p.sh",
34
- num_hands => 3000,
35
- big_blind => 10,
36
- players => 2
37
- },
38
- "submission_2pn" => {
39
- game_def => "holdem.nolimit.2p.reverse_blinds.game",
40
- chump => "example_player.nolimit.2p.sh",
41
- num_hands => 3000,
42
- big_blind => 100,
43
- players => 2
44
- },
45
- "submission_3pl" => {
46
- game_def => "holdem.limit.3p.game",
47
- chump => "example_player.limit.3p.sh",
48
- num_hands => 1000,
49
- big_blind => 10,
50
- players => 3
51
- }
52
- # For the possibility of future 3p_nolimit games
53
- # "3p_nolimit" => {
54
- # gamedef => "holdem.nolimit.3p.game",
55
- # chump => "example_player.nolimit.3p.sh",
56
- # num_hands => 1000,
57
- # big_blind => 100,
58
- # players => 3
59
- # }
60
- );
61
-
62
- my $man;
63
- my $help;
64
-
65
- # Parse command line arguments
66
- GetOptions( 'help' => \$help, 'man' => \$man,
67
- 'num_hands=i' => \$num_test_hands )
68
- or pod2usage( -exitstatus => 2,
69
- -message => "Invalid arguments.\n" .
70
- "Use --help or --man for detailed usage." );
71
-
72
- pod2usage( -verbose => 1 ) if( $help );
73
- pod2usage( -verbose => 2 ) if( $man );
74
- $#ARGV >= 0
75
- or pod2usage( -exitstatus => 2,
76
- -message => "Insufficient arguments.\n" .
77
- "Use --help or --man for detailed usage." );
78
-
79
- ( $num_test_hands >= $min_test_hands )
80
- or die "Must play at least $min_test_hands hands for validation, stopped";
81
-
82
- # Set up file paths
83
- my $submission_path = File::Spec->rel2abs( $ARGV[ 0 ] ) ;
84
- my ( $submission_volume, $submission_dir, $submission_last_comp )
85
- = File::Spec->splitpath( $submission_path );
86
-
87
- my $validation_dir = "$submission_path.validation";
88
- my $validation_path
89
- = File::Spec->catfile( $validation_dir, "$submission_last_comp.validation" );
90
-
91
- # XXX: Script relies on its relative position with the rest of the code. This
92
- # isn't great, but avoids other configuration files specifying this
93
- my ( $volume, $directories, $test_script_file )
94
- = File::Spec->splitpath( File::Spec->rel2abs( $0 ) );
95
- my $scripts_dir = File::Spec->catpath( $volume, $directories, '' );
96
- my $server_dir = File::Spec->catpath( $volume, $directories, '' );
97
- my $test_script_path = File::Spec->catfile( $scripts_dir, $test_script_file );
98
- my $dealer_path = File::Spec->catfile( $server_dir, "dealer" );
99
- my $example_player_path = File::Spec->catfile( $server_dir, "example_player" );
100
- my $play_match_path = File::Spec->catfile( $server_dir, "acpc_play_match.pl" );
101
-
102
- # Ensure we aren't overwriting an existing validation file
103
- ( ! -e $validation_dir )
104
- or die "ERROR: $validation_dir already exists. Move/remove it and rerun\n";
105
-
106
- mkpath( $validation_dir );
107
-
108
- # Open the validation file for writing
109
- my $VALIDATION;
110
- open( $VALIDATION, '>', $validation_path )
111
- or die "ERROR: Cannot open validation file $validation_path" .
112
- "for writing: $!\n";
113
-
114
- # Begin validation tests
115
- print $VALIDATION "Validating $submission_path\n\n";
116
- print "Validating $submission_path\n";
117
- print "Validation files will be placed in $validation_dir\n";
118
- print "Matches in progress will have output in $server_dir\n";
119
- print "Check $validation_path for more detailed progress or errors\n\n";
120
-
121
- # Test the versions of the files using checksums
122
- print $VALIDATION "Gathering file versions (md5sums)...\n\n";
123
-
124
- # Ensure the testing script is the right version
125
- my $test_script_version_cmd = "md5sum $test_script_path";
126
- print $VALIDATION "Testing script: $test_script_path\n";
127
- print $VALIDATION "$test_script_version_cmd\n";
128
-
129
- my $test_script_version_output = `$test_script_version_cmd 2>&1`;
130
- print $VALIDATION "$test_script_version_output\n";
131
- if( $? != 0 ) {
132
- print $VALIDATION "FAILED.\n";
133
- print $VALIDATION "Validation FAILED.\n";
134
- die "$test_script_version_cmd\n$test_script_version_output\n" .
135
- "ERROR: Unable to verify testing script version, stopped";
136
- }
137
-
138
- # Verify the version of the dealer program
139
- my $dealer_version_cmd = "md5sum $dealer_path";
140
- print $VALIDATION "dealer: $dealer_path\n";
141
- print $VALIDATION "$dealer_version_cmd\n";
142
-
143
- my $dealer_version_output = `$dealer_version_cmd 2>&1`;
144
- print $VALIDATION "$dealer_version_output\n";
145
- if( $? != 0 ) {
146
- print $VALIDATION "FAILED.\n";
147
- print $VALIDATION "Validation FAILED.\n";
148
- die "$dealer_version_cmd\n$dealer_version_output\n" .
149
- "ERROR: Unable to verify dealer version, stopped";
150
- }
151
-
152
- # Verify the version of the example_player program
153
- my $example_player_version_cmd = "md5sum $example_player_path";
154
- print $VALIDATION "example_player: $example_player_path\n";
155
- print $VALIDATION "$example_player_version_cmd\n";
156
-
157
- my $example_player_version_output = `$example_player_version_cmd 2>&1`;
158
- print $VALIDATION "$example_player_version_output\n";
159
- if( $? != 0 ) {
160
- print $VALIDATION "FAILED.\n";
161
- print $VALIDATION "Validation FAILED.\n";
162
- die "$example_player_version_cmd\n$example_player_version_output\n" .
163
- "ERROR: Unable to verify example_player version, stopped";
164
- }
165
-
166
- # Verify the version of the play_match program
167
- my $play_match_version_cmd = "md5sum $play_match_path";
168
- print $VALIDATION "play_match: $play_match_path\n";
169
- print $VALIDATION "$play_match_version_cmd\n";
170
-
171
- my $play_match_version_output = `$play_match_version_cmd 2>&1`;
172
- print $VALIDATION "$play_match_version_output\n";
173
- if( $? != 0 ) {
174
- print $VALIDATION "FAILED.\n";
175
- print $VALIDATION "Validation FAILED.\n";
176
- die "$play_match_version_cmd\n$play_match_version_output\n" .
177
- "ERROR: Unable to verify play_match.pl version, stopped";
178
- }
179
-
180
- # Test for what kind of submission it is (i.e., which game)
181
- my $game_label = undef;
182
- print $VALIDATION "Checking for game label... ";
183
- foreach my $game ( keys( %game_types ) ) {
184
- if( $submission_last_comp eq $game ) {
185
- $game_label = $game;
186
- print $VALIDATION "PASSED. Found $game_label\n\n";
187
- last;
188
- }
189
- }
190
-
191
- if( not defined $game_label ) {
192
- $, = ", "; # Sets the list printing separator
193
- print $VALIDATION " FAILED.\n";
194
- print $VALIDATION "Unrecognized directory name $submission_last_comp\n";
195
- print $VALIDATION "Submission directory must be one of: ",
196
- print $VALIDATION keys( %game_types );
197
- print $VALIDATION "\n";
198
- print $VALIDATION "Validation FAILED.\n";
199
- die "ERROR: Unrecognized submission directory name, stopped";
200
- }
201
-
202
- my $agent_name;
203
- if( -d $submission_path ) {
204
- $agent_name = ( File::Spec->splitdir( $submission_path ) )[ -1 ];
205
- } else {
206
- print $VALIDATION "FAILED.\n";
207
- print $VALIDATION "$submission_path is not a directory.\n";
208
- print $VALIDATION "Validation FAILED.\n";
209
- die "ERROR: Expected a directory, stopped";
210
- }
211
-
212
- # Check if the directory contains a README file
213
- print $VALIDATION "Checking for README file... ";
214
- if( -e File::Spec->catfile( $submission_path, "README" ) ) {
215
- print $VALIDATION "PASSED.\n\n";
216
- } else {
217
- print $VALIDATION "FAILED.\n";
218
- print $VALIDATION "Validation FAILED.\n";
219
- die "ERROR: Missing README file, stopped";
220
- }
221
-
222
- # Check if the directory contains an executable startme.sh script
223
- print $VALIDATION "Checking for executable startme.sh script... ";
224
- my $startme_stat = stat( File::Spec->catfile( $submission_path, "startme.sh" ) );
225
- if( $startme_stat ) {
226
- my $mode = $startme_stat->mode;
227
- my $perm_mask = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
228
- my $perm_str = sprintf( "%03o", $perm_mask & 00777 );
229
- # Test if the file has the same permissions as the mask
230
- if( ( $mode & $perm_mask ) == $perm_mask ) {
231
- print $VALIDATION "PASSED.\n\n";
232
- } else {
233
- print $VALIDATION "FAILED.\n";
234
- print $VALIDATION "startme.sh must have at least $perm_str permissions\n";
235
- print $VALIDATION "Validation FAILED.\n";
236
- die "ERROR: startme.sh must have at least $perm_str permissions, stopped";
237
- }
238
- } else {
239
- print $VALIDATION "FAILED.\n";
240
- print $VALIDATION "Validation FAILED.\n";
241
- die "ERROR: Unable to stat startme.sh file: $!, stopped";
242
- }
243
-
244
- # Check if the uncompressed size of the agent submission directory is too big
245
- # NOTE: This isn't done is a very platorm independent way. du does not always
246
- # have -b available (not to mention other OSes). Should probably just walk the
247
- # file structure ourselves.
248
- print $VALIDATION "Checking $submission_path for uncompressed file size... ";
249
- my $agent_size_cmd = "du -bc $submission_path";
250
- my @agent_size_output = `$agent_size_cmd 2>&1`;
251
- # $? is the return value of the backtick command, test it for failure
252
- if( $? == 0 ) {
253
- my @fields = split( /\W/, $agent_size_output[ -1 ] );
254
- my $agent_size = $fields[ 0 ];
255
- if( $agent_size <= $max_submission_size ) {
256
- print $VALIDATION "PASSED. ($agent_size bytes)\n\n";
257
- } else {
258
- print $VALIDATION "FAILED.\n";
259
- print $VALIDATION "Validation FAILED.\n";
260
- die "ERROR: $submission_path is too large, stopped";
261
- }
262
- } else {
263
- $, = ""; # Sets the list printing separator
264
- print $VALIDATION "FAILED.\n";
265
- print $VALIDATION "Validation FAILED.\n";
266
- die "$agent_size_cmd\n@agent_size_output\n" .
267
- "ERROR: Unable to get agent directory size, stopped";
268
- }
269
-
270
- # Run the submitted agent for the specified number of trial hands.
271
- my $matches_played = 0;
272
- my $min_matches = ceil( $num_test_hands /
273
- $game_types{ $game_label }{ num_hands } );
274
-
275
- my $total_decision_time = 0;
276
- my $total_score = 0;
277
-
278
- my $game_def = $game_types{ $game_label }{ game_def };
279
- my $num_players = $game_types{ $game_label }{ players };
280
- my $num_hands = $game_types{ $game_label }{ num_hands };
281
- my $big_blind = $game_types{ $game_label }{ big_blind };
282
- my $example_player_startme_path
283
- = File::Spec->catfile( $server_dir, $game_types{ $game_label }{ chump } );
284
-
285
- print "Running matches...\n";
286
- # Change directory to the server directory as play_match relies on relative
287
- # paths from that directory
288
- chdir( $server_dir ) or die "Unable to chdir to $server_dir: $!, stopped";
289
- # Play all of the matches needed to at least meet the minimum hand count
290
- while( $matches_played < $min_matches ) {
291
- my ( $match_start_time, $match_end_time );
292
- my $match_name = "$agent_name.test_match.$matches_played";
293
-
294
- # TODO?: Should the generated shell scripts be used to run the agent
295
- # If not, then files could be left over or we may not detect issues with
296
- # using the scripts
297
-
298
- # Construct the command for running a match
299
- my $match_cmd = "$play_match_path $match_name $game_def $num_hands " .
300
- "$matches_played $agent_name $submission_path/startme.sh";
301
- # Add the remaining players
302
- for( my $player = 1; $player < $num_players; $player++ ) {
303
- $match_cmd = $match_cmd . " chump" .
304
- ( $num_players > 2 ? "-$player" : "" ) . " $example_player_startme_path"
305
- }
306
- # Add the server timing options
307
- $match_cmd = $match_cmd . " --t_per_hand $max_avg_millisec_per_hand " .
308
- "--t_response $max_response_millisec " .
309
- "--t_hand $max_millisec_per_hand";
310
-
311
- # Give some visual output of progress
312
- print "Match ", $matches_played + 1,
313
- " of $min_matches: $match_name\n";
314
- print $VALIDATION "========== Match ", $matches_played + 1,
315
- " of $min_matches: $match_name ==========\n";
316
-
317
- # Ensure no other startme.sh script are running prior to the next match
318
- print $VALIDATION "Checking for existing agents... ";
319
- my $lingering_agent_cmd = "ps -eo command";
320
- my @lingering_agent_output = `$lingering_agent_cmd 2>&1`;
321
- # $? is the return value of the backtick command, test it for failure
322
- if( $? == 0 ) {
323
- my @lingering_agents = grep { /startme\.sh/ } @lingering_agent_output;
324
- if( @lingering_agents == 0 ) {
325
- print $VALIDATION "PASSED.\n\n";
326
- } else {
327
- $, = "\n"; # Sets the list printing separator
328
- print $VALIDATION "FAILED.\n";
329
- print $VALIDATION "Found the following existing agents:\n";
330
- print $VALIDATION @lingering_agents;
331
- print $VALIDATION "\n";
332
- print $VALIDATION "Stop other agents before proceeding with testing\n";
333
- print $VALIDATION "Validation FAILED.\n";
334
- die "ERROR: lingering startme.sh found before match $match_name, stopped";
335
- }
336
- } else {
337
- $, = ""; # Sets the list printing separator
338
- print $VALIDATION "FAILED.\n";
339
- print $VALIDATION "Validation FAILED.\n";
340
- die "$lingering_agent_cmd\n@lingering_agent_output\n" .
341
- "ERROR: Unable to get processes to check for lingering agents, stopped";
342
- }
343
-
344
- print $VALIDATION "$match_cmd\n\n";
345
-
346
- # Collect timing statistics for the run.
347
- $match_start_time = time();
348
- my $match_output = `$match_cmd 2>&1`;
349
- $match_end_time = time();
350
-
351
- # Move any available output files to the $validation_dir
352
- foreach my $file ( glob( "$server_dir/$match_name*" ) ) {
353
- move( $file, $validation_dir );
354
- }
355
-
356
- chomp( $match_output );
357
- print $VALIDATION "$match_output\n";
358
-
359
- if( $? != 0 ) {
360
- print $VALIDATION "FAILED.\n";
361
- print $VALIDATION "Validation FAILED.\n";
362
- die "$match_cmd\n$match_output\n" .
363
- "ERROR: Match $agent_name.test_match.$matches_played FAILED " .
364
- "(returned $?).\n" .
365
- "Check match log files in validation directory for cause, stopped";
366
- }
367
-
368
- # Extract the score from the dealer output
369
- # e.g., SCORE:-1430|1430:2p_limit_foo|chump
370
- my $scores = ( split( /:/, $match_output ) )[ 1 ];
371
- $total_score += ( split( /\|/, $scores ) )[ 0 ];
372
- $matches_played++;
373
- $total_decision_time += $match_end_time - $match_start_time;
374
-
375
- # Verify that the agent is shutting down correctly
376
- print $VALIDATION "Checking for lingering agents... ";
377
- # Wait a short while to give the agent time to exit after the match
378
- sleep( $max_shutdown_secs );
379
- @lingering_agent_output = `$lingering_agent_cmd 2>&1`;
380
- # $? is the return value of the backtick command, test it for failure
381
- if( $? == 0 ) {
382
- my @lingering_agents = grep { /startme\.sh/ } @lingering_agent_output;
383
- if( @lingering_agents == 0 ) {
384
- print $VALIDATION "PASSED.\n\n";
385
- } else {
386
- $, = "\n"; # Sets the list printing separator
387
- print $VALIDATION "FAILED.\n";
388
- print $VALIDATION "Found the following lingering agents:\n";
389
- print $VALIDATION @lingering_agents;
390
- print $VALIDATION "\n";
391
- print $VALIDATION "Validation FAILED.\n";
392
- die "ERROR: lingering startme.sh found after match $match_name, stopped";
393
- }
394
- } else {
395
- print $VALIDATION "FAILED.\n";
396
- print $VALIDATION "Validation FAILED.\n";
397
- die "$lingering_agent_cmd\n@lingering_agent_output\n" .
398
- "ERROR: Unable to get processes to check for lingering agents, stopped";
399
- }
400
-
401
- # Check for any warnings in the output
402
- print $VALIDATION "Checking $match_name.err output for errors/warnings... ";
403
-
404
- if( not open( DEALER_STDERR,
405
- File::Spec->catfile( $validation_dir, "$match_name.err" ) ) ) {
406
- print $VALIDATION "FAILED.\n";
407
- print $VALIDATION "Unable to open $match_name.err for reading: $!\n";
408
- print $VALIDATION "Validation FAILED.\n";
409
- die "ERROR: Cannot open $match_name.err for reading to check for " .
410
- "errors in match $match_name: $!, stopped";
411
- }
412
-
413
- my @match_warnings = grep { /(WARNING|ERROR)/ } <DEALER_STDERR>;
414
- close DEALER_STDERR;
415
-
416
- if( @match_warnings == 0 ) {
417
- print $VALIDATION "PASSED.\n\n";
418
- } else {
419
- $, = ""; # Sets the list printing separator
420
- print $VALIDATION "FAILED.\n";
421
- print $VALIDATION "Found the following warnings/errors:\n";
422
- print $VALIDATION @match_warnings;
423
- print $VALIDATION "\n";
424
- print $VALIDATION "Validation FAILED.\n";
425
- die "ERROR: dealer warnings detected in match $match_name, stopped";
426
- }
427
- }
428
-
429
- print $VALIDATION "========= Test match statistics ==========\n";
430
- print $VALIDATION "Matches played: $matches_played\n";
431
- print $VALIDATION "Hands played: ", ( $matches_played * $num_hands ), "\n";
432
- print $VALIDATION "Average time per hand (seconds): ",
433
- $total_decision_time / ( $matches_played * $num_hands ), "\n";
434
- print $VALIDATION "Average time per match (seconds): ",
435
- $total_decision_time / $matches_played, "\n";
436
-
437
- my $performance
438
- = ( 1000 * $total_score ) / ( $big_blind * $matches_played * $num_hands );
439
- print $VALIDATION "Performance (milli big blinds per hand): ",
440
- $performance, "\n";
441
-
442
- print $VALIDATION "Checking for winning performance... ";
443
- if( $performance >= 0 ) {
444
- print $VALIDATION "PASSED.\n\n";
445
- } else {
446
- print $VALIDATION "FAILED.\n";
447
- print $VALIDATION "Validation FAILED.\n";
448
- die "ERROR: Submission unable to beat chump in test matches, stopped";
449
- }
450
-
451
- # Print completion messages
452
- print "Validation PASSED.\n";
453
-
454
- print $VALIDATION "Validation PASSED.\n";
455
-
456
- close $VALIDATION;
457
-
458
- # POD Documentation for usage message
459
- __END__
460
-
461
- =head1 NAME
462
-
463
- B<validate_submission.pl> - Checks that the sepcified submission file for the
464
- Annual Computer Poker Competition is well formed and works.
465
-
466
- =head1 SYNOPSIS
467
-
468
- B<validate_submission.pl> [options] submission_dir
469
-
470
- =head1 DESCRIPTION
471
-
472
- B<validate_submission.pl> - Tests that the specified submission file passes
473
- basic sanity checks expected of entries in the Annual Computer Poker
474
- Competition. This process could take a long time depending on the
475
- size of your submission file and the rate at which it plays.
476
-
477
- Note that this script expects that your agent:
478
-
479
- =over 8
480
-
481
- =item *
482
-
483
- Is contained in a single directory named submission_2pl, submission_2pn
484
- or submission_3pl
485
-
486
- =item *
487
-
488
- Has an startme.sh script with permissions of at least 755 at the root of your
489
- directory
490
-
491
- =item *
492
-
493
- Has a README file at the root of your directory
494
-
495
- =item *
496
-
497
- Is within the size limit
498
-
499
- =item *
500
-
501
- Plays only valid actions
502
-
503
- =item *
504
-
505
- Cleans itself up once the match is over
506
-
507
- =item *
508
-
509
- Beats an agent that plays randomly and does not look at its cards
510
-
511
- =back
512
-
513
- Failure on any of these points will cause the validation to fail. Futhermore,
514
- ensure that you are B<only running one test script at a time> as they will
515
- interfere with each other.
516
-
517
- The required argument is:
518
-
519
- =over 8
520
-
521
- =item B<submission_dir>
522
-
523
- A path to a submission directory that you want to check for basic correctness
524
-
525
- =back
526
-
527
- =head1 OPTIONS
528
-
529
- =over 8
530
-
531
- =item B<--help>
532
-
533
- Print a brief help message and exits.
534
-
535
- =item B<--man>
536
-
537
- Prints the manual page and exits.
538
-
539
- =item B<--num_hands=[positive integer]>
540
-
541
- Set the number of hands you want to test for. Defaults to the minimum number
542
- of hands for validation. Please run as many as you can.
543
-
544
- =back
545
-
546
- =cut