acpc_dealer 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 00bbd47995a7c97603b156001d76276e59ab27c2
|
|
4
|
+
data.tar.gz: 826b3f4488fb64a04010fd2429b002f942cbcca4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0d665782f2e464c27fef0012bc0a8a355beec06a9459d11ac04be46706050bf7691447d94d3e0c749275156172ac94196b0a46647825423e563da7c42ee01c08
|
|
7
|
+
data.tar.gz: 2df7ccbf5153837c5f075d038b2f0fbab23ae5101b064ddeb6b5bc5fc292eb735356f8df60c7b43502c63cb3e55e54c881b5a9eed2aceb521b52efcfdbc4fce6
|
data/lib/acpc_dealer/version.rb
CHANGED
|
@@ -22,6 +22,9 @@ bm_server: bm_server.c game.c game.h rng.c rng.h net.c net.h
|
|
|
22
22
|
bm_widget: bm_widget.c net.c net.h
|
|
23
23
|
$(CC) $(CFLAGS) -o $@ bm_widget.c net.c
|
|
24
24
|
|
|
25
|
+
bm_run_matches: bm_run_matches.c net.c net.h
|
|
26
|
+
$(CC) $(CFLAGS) -o $@ bm_run_matches.c net.c
|
|
27
|
+
|
|
25
28
|
dealer: game.c game.h evalHandTables rng.c rng.h dealer.c net.c net.h
|
|
26
29
|
$(CC) $(CFLAGS) -o $@ game.c rng.c dealer.c net.c
|
|
27
30
|
|
|
@@ -111,4 +111,3 @@ If you are creating your own game definitions, please note that game.h defines
|
|
|
111
111
|
some constants for maximums in games (e.g., number of rounds). These may need
|
|
112
112
|
to be changed for games outside of the what is being run for the Annual
|
|
113
113
|
Computer Poker Competition.
|
|
114
|
-
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
#include <stdlib.h>
|
|
2
|
+
#include <stdio.h>
|
|
3
|
+
#define __STDC_FORMAT_MACROS
|
|
4
|
+
#include <inttypes.h>
|
|
5
|
+
#include <assert.h>
|
|
6
|
+
#include <string.h>
|
|
7
|
+
#include <unistd.h>
|
|
8
|
+
#include <netdb.h>
|
|
9
|
+
#include <sys/socket.h>
|
|
10
|
+
#include <netinet/in.h>
|
|
11
|
+
#include <netinet/tcp.h>
|
|
12
|
+
#include <sys/wait.h>
|
|
13
|
+
#include <errno.h>
|
|
14
|
+
#include "net.h"
|
|
15
|
+
|
|
16
|
+
#define ARG_SERVERNAME 1
|
|
17
|
+
#define ARG_SERVERPORT 2
|
|
18
|
+
#define ARG_BOT_COMMAND 7
|
|
19
|
+
#define ARG_MIN_ARGS 6
|
|
20
|
+
|
|
21
|
+
static void printUsage( FILE *file )
|
|
22
|
+
{
|
|
23
|
+
fprintf( file, "Sample usages:\n" );
|
|
24
|
+
fprintf( file, " bm_run_matches <bm_hostname> <bm_port> <username> <pw> "
|
|
25
|
+
"games\n" );
|
|
26
|
+
fprintf( file, " See a list of possible opponents\n" );
|
|
27
|
+
fprintf( file, " bm_run_matches <bm_hostname> <bm_port> <username> <pw> "
|
|
28
|
+
"run 2pl <local script> <# runs> <tag> <seed> <player1> "
|
|
29
|
+
"<player2>\n" );
|
|
30
|
+
fprintf( file, " Run two-player limit matches\n" );
|
|
31
|
+
fprintf( file, " bm_run_matches <bm_hostname> <bm_port> <username> <pw> "
|
|
32
|
+
"run 2pn <local script> <# runs> <tag> <seed> <player1> "
|
|
33
|
+
"<player2>\n" );
|
|
34
|
+
fprintf( file, " Run two-player no-limit matches\n" );
|
|
35
|
+
fprintf( file, " bm_run_matches <bm_hostname> <bm_port> <username> <pw> "
|
|
36
|
+
"run 3pl <local script> <# runs> <tag> <seed> <player1> <player2> "
|
|
37
|
+
"<player3>\n" );
|
|
38
|
+
fprintf( file, " Run three-player limit matches\n" );
|
|
39
|
+
fprintf( file, " bm_run_matches <bm_hostname> <bm_port> <username> <pw> "
|
|
40
|
+
"rerun 2pl <local script> <match index> <tag> <seed> <player1> "
|
|
41
|
+
"<player2> (<player3>)\n" );
|
|
42
|
+
fprintf( file, " Rerun a match that failed\n" );
|
|
43
|
+
fprintf( file, "\n" );
|
|
44
|
+
fprintf( file, "<username> is your benchmark server username assigned to "
|
|
45
|
+
"you by the competition chair\n" );
|
|
46
|
+
fprintf( file, "<pw> is your benchmark server password assigned to you by "
|
|
47
|
+
"the competition chair\n" );
|
|
48
|
+
fprintf( file, "<local script> is the script that runs your agent locally. "
|
|
49
|
+
"It must take a hostname/IP and a port\n" );
|
|
50
|
+
fprintf( file, "<num runs> is the number of matches you want to run\n" );
|
|
51
|
+
fprintf( file, "<tag> is a name for this set of matches which will appear "
|
|
52
|
+
"in the names of the log files\n" );
|
|
53
|
+
fprintf( file, "<seed> is a seed used to generate the random seeds that "
|
|
54
|
+
"determine the cards in each match\n" );
|
|
55
|
+
fprintf( file, "<player-n> is either the name of an opponent or \"local\" "
|
|
56
|
+
"for your local agent\n" );
|
|
57
|
+
fprintf( file, "\n" );
|
|
58
|
+
fprintf( file, "To run N duplicate heads-up matches, do one run of N "
|
|
59
|
+
"matches with a given seed, then run a second set of N matches "
|
|
60
|
+
"with the same seed but the order of the players reversed\n" );
|
|
61
|
+
fprintf( file, "\n" );
|
|
62
|
+
fprintf( file, "If one match in a set fails, you can use the \"rerun\" "
|
|
63
|
+
"command to rerun the specified match with the specified seed. "
|
|
64
|
+
"For example, if you tried to run twenty matches with seed 0 and "
|
|
65
|
+
"the last match failed, you could use the \"rerun\" command with "
|
|
66
|
+
"seed 0 and match index 19.\n" );
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
int main( int argc, char **argv )
|
|
70
|
+
{
|
|
71
|
+
int sock, i;
|
|
72
|
+
pid_t childPID;
|
|
73
|
+
uint16_t port;
|
|
74
|
+
ReadBuf *fromServer;
|
|
75
|
+
fd_set readfds;
|
|
76
|
+
char line[ READBUF_LEN ];
|
|
77
|
+
|
|
78
|
+
if( argc < ARG_MIN_ARGS ) {
|
|
79
|
+
|
|
80
|
+
printUsage( stderr );
|
|
81
|
+
exit( EXIT_FAILURE );
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* connect to the server */
|
|
85
|
+
if( sscanf( argv[ ARG_SERVERPORT ], "%"SCNu16, &port ) < 1 ) {
|
|
86
|
+
|
|
87
|
+
fprintf( stderr, "ERROR: invalid port %s\n", argv[ ARG_SERVERPORT ] );
|
|
88
|
+
exit( EXIT_FAILURE );
|
|
89
|
+
}
|
|
90
|
+
sock = connectTo( argv[ ARG_SERVERNAME ], port );
|
|
91
|
+
if( sock < 0 ) {
|
|
92
|
+
|
|
93
|
+
exit( EXIT_FAILURE );
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// EJ additions 9/3/2012
|
|
97
|
+
// Turn on keep-alive for socket connection with more frequent checking
|
|
98
|
+
// than the Linux default. What I've observed is that if a socket
|
|
99
|
+
// connection is idle for long enough it gets dropped. This only
|
|
100
|
+
// happens for some users.
|
|
101
|
+
int on = 1;
|
|
102
|
+
if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)) == -1) {
|
|
103
|
+
fprintf( stderr, "ERROR: setsockopt failed; errno %i\n", errno );
|
|
104
|
+
exit( EXIT_FAILURE );
|
|
105
|
+
}
|
|
106
|
+
// Not sure what this should be
|
|
107
|
+
int num_before_failure = 2;
|
|
108
|
+
if (setsockopt(sock, SOL_TCP, TCP_KEEPCNT, &num_before_failure,
|
|
109
|
+
sizeof(num_before_failure)) == -1) {
|
|
110
|
+
fprintf( stderr, "ERROR: setsockopt failed; errno %i\n", errno );
|
|
111
|
+
exit( EXIT_FAILURE );
|
|
112
|
+
}
|
|
113
|
+
// First check after 60 seconds
|
|
114
|
+
int initial_secs = 60;
|
|
115
|
+
if (setsockopt(sock, SOL_TCP, TCP_KEEPIDLE, &initial_secs,
|
|
116
|
+
sizeof(initial_secs)) == -1) {
|
|
117
|
+
fprintf( stderr, "ERROR: setsockopt failed; errno %i\n", errno );
|
|
118
|
+
exit( EXIT_FAILURE );
|
|
119
|
+
}
|
|
120
|
+
// Thereafter, also check every 60 seconds
|
|
121
|
+
int interval_secs = 60;
|
|
122
|
+
if (setsockopt(sock, SOL_TCP, TCP_KEEPINTVL, &interval_secs,
|
|
123
|
+
sizeof(interval_secs)) == -1) {
|
|
124
|
+
fprintf( stderr, "ERROR: setsockopt failed; errno %i\n", errno );
|
|
125
|
+
exit( EXIT_FAILURE );
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* set up read buffers */
|
|
129
|
+
fromServer = createReadBuf( sock );
|
|
130
|
+
|
|
131
|
+
/* write to server */
|
|
132
|
+
line[0] = 0;
|
|
133
|
+
for( i = 3; i < argc; ++i ) {
|
|
134
|
+
strcat( line, argv[i] );
|
|
135
|
+
if ( i < argc - 1 ) {
|
|
136
|
+
strcat( line, " " );
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
strcat( line, "\n" );
|
|
140
|
+
int len = strlen(line);
|
|
141
|
+
if( write( sock, line, len ) < 0 ) {
|
|
142
|
+
|
|
143
|
+
fprintf( stderr, "ERROR: failed while sending to server\n" );
|
|
144
|
+
exit( EXIT_FAILURE );
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* main loop */
|
|
148
|
+
while( 1 ) {
|
|
149
|
+
|
|
150
|
+
/* clean up any children */
|
|
151
|
+
while( waitpid( -1, NULL, WNOHANG ) > 0 );
|
|
152
|
+
|
|
153
|
+
/* wait for input */
|
|
154
|
+
FD_ZERO( &readfds );
|
|
155
|
+
FD_SET( sock, &readfds );
|
|
156
|
+
i = select( sock + 1, &readfds, NULL, NULL, NULL );
|
|
157
|
+
if( i < 0 ) {
|
|
158
|
+
|
|
159
|
+
fprintf( stderr, "ERROR: select failed\n" );
|
|
160
|
+
exit( EXIT_FAILURE );
|
|
161
|
+
}
|
|
162
|
+
if( i == 0 ) {
|
|
163
|
+
/* nothing ready - shouldn't happen without timeout */
|
|
164
|
+
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/* handle server messages */
|
|
169
|
+
if( FD_ISSET( sock, &readfds ) ) {
|
|
170
|
+
|
|
171
|
+
/* get the input */
|
|
172
|
+
while( ( i = getLine( fromServer, READBUF_LEN, line, 0 ) ) >= 0 ) {
|
|
173
|
+
|
|
174
|
+
if( i == 0 ) {
|
|
175
|
+
|
|
176
|
+
/* This could be an error or could just signify successful
|
|
177
|
+
completion of all matches */
|
|
178
|
+
fprintf( stderr, "Server closed connection\n" );
|
|
179
|
+
exit( EXIT_SUCCESS );
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/* check for server commands */
|
|
183
|
+
if( strncasecmp( line, "run ", 4 ) == 0 ) {
|
|
184
|
+
|
|
185
|
+
/* split the rest of the line into name ' ' port */
|
|
186
|
+
for( i = 4; line[ i ]; ++i ) {
|
|
187
|
+
|
|
188
|
+
if( line[ i ] == ' ' ) {
|
|
189
|
+
/* found the separator */
|
|
190
|
+
|
|
191
|
+
line[ i ] = 0;
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
printf( "starting match %s:%s", &line[ 4 ], &line[ i + 1 ] );
|
|
197
|
+
fflush( stdout );
|
|
198
|
+
|
|
199
|
+
/* run `command machine port` */
|
|
200
|
+
childPID = fork();
|
|
201
|
+
if( childPID < 0 ) {
|
|
202
|
+
|
|
203
|
+
fprintf( stderr, "ERROR: fork() failed\n" );
|
|
204
|
+
exit( EXIT_FAILURE );
|
|
205
|
+
}
|
|
206
|
+
if( childPID == 0 ) {
|
|
207
|
+
/* child runs the command */
|
|
208
|
+
|
|
209
|
+
execl( argv[ ARG_BOT_COMMAND ],
|
|
210
|
+
argv[ ARG_BOT_COMMAND ],
|
|
211
|
+
&line[ 4 ],
|
|
212
|
+
&line[ i + 1 ],
|
|
213
|
+
NULL );
|
|
214
|
+
fprintf( stderr,
|
|
215
|
+
"ERROR: could not run %s\n",
|
|
216
|
+
argv[ ARG_BOT_COMMAND ] );
|
|
217
|
+
exit( EXIT_FAILURE );
|
|
218
|
+
}
|
|
219
|
+
} else {
|
|
220
|
+
/* just a message, print it out */
|
|
221
|
+
|
|
222
|
+
if( fwrite( line, 1, i, stdout ) < 0 ) {
|
|
223
|
+
|
|
224
|
+
fprintf( stderr, "ERROR: failed while printing server message\n" );
|
|
225
|
+
exit( EXIT_FAILURE );
|
|
226
|
+
}
|
|
227
|
+
fflush( stdout );
|
|
228
|
+
|
|
229
|
+
if( ! strcmp( line, "Matches finished\n") ) {
|
|
230
|
+
exit( EXIT_SUCCESS );
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return EXIT_SUCCESS;
|
|
238
|
+
}
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: acpc_dealer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.1.
|
|
4
|
+
version: 2.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dustin Morrill
|
|
@@ -284,6 +284,7 @@ files:
|
|
|
284
284
|
- vendor/project_acpc_server/tags
|
|
285
285
|
- vendor/project_acpc_server/holdem.limit.2p.reverse_blinds.game
|
|
286
286
|
- vendor/project_acpc_server/kuhn_3p_equilibrium_player.sf1.sh
|
|
287
|
+
- vendor/project_acpc_server/bm_run_matches.c
|
|
287
288
|
- vendor/project_acpc_server/holdem.limit.3p.game
|
|
288
289
|
- vendor/project_acpc_server/example_player.nolimit.2p.sh
|
|
289
290
|
- vendor/project_acpc_server/game.h
|