acpc_dealer 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +33 -0
- data/Rakefile +20 -0
- data/acpc_dealer.gemspec +29 -0
- data/bin/acpc_dealer +168 -0
- data/ext/hand_evaluator/extconf.rb +5 -0
- data/ext/hand_evaluator/hand_evaluator.c +38 -0
- data/lib/acpc_dealer/2p.limit.h5.r0.logs/2p.limit.h5.r0.actions.log +5 -0
- data/lib/acpc_dealer/2p.limit.h5.r0.logs/2p.limit.h5.r0.log +0 -0
- data/lib/acpc_dealer/dealer_runner.rb +72 -0
- data/lib/acpc_dealer/version.rb +3 -0
- data/lib/acpc_dealer.rb +33 -0
- data/lib/hand_evaluator.so +0 -0
- data/spec/coverage/assets/0.5.3/app.js +88 -0
- data/spec/coverage/assets/0.5.3/fancybox/blank.gif +0 -0
- data/spec/coverage/assets/0.5.3/fancybox/fancy_close.png +0 -0
- data/spec/coverage/assets/0.5.3/fancybox/fancy_loading.png +0 -0
- data/spec/coverage/assets/0.5.3/fancybox/fancy_nav_left.png +0 -0
- data/spec/coverage/assets/0.5.3/fancybox/fancy_nav_right.png +0 -0
- data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_e.png +0 -0
- data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_n.png +0 -0
- data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_ne.png +0 -0
- data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_nw.png +0 -0
- data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_s.png +0 -0
- data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_se.png +0 -0
- data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_sw.png +0 -0
- data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_w.png +0 -0
- data/spec/coverage/assets/0.5.3/fancybox/fancy_title_left.png +0 -0
- data/spec/coverage/assets/0.5.3/fancybox/fancy_title_main.png +0 -0
- data/spec/coverage/assets/0.5.3/fancybox/fancy_title_over.png +0 -0
- data/spec/coverage/assets/0.5.3/fancybox/fancy_title_right.png +0 -0
- data/spec/coverage/assets/0.5.3/fancybox/fancybox-x.png +0 -0
- data/spec/coverage/assets/0.5.3/fancybox/fancybox-y.png +0 -0
- data/spec/coverage/assets/0.5.3/fancybox/fancybox.png +0 -0
- data/spec/coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.css +363 -0
- data/spec/coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.pack.js +44 -0
- data/spec/coverage/assets/0.5.3/favicon_green.png +0 -0
- data/spec/coverage/assets/0.5.3/favicon_red.png +0 -0
- data/spec/coverage/assets/0.5.3/favicon_yellow.png +0 -0
- data/spec/coverage/assets/0.5.3/highlight.css +129 -0
- data/spec/coverage/assets/0.5.3/highlight.pack.js +1 -0
- data/spec/coverage/assets/0.5.3/jquery-1.6.2.min.js +18 -0
- data/spec/coverage/assets/0.5.3/jquery.dataTables.min.js +152 -0
- data/spec/coverage/assets/0.5.3/jquery.timeago.js +141 -0
- data/spec/coverage/assets/0.5.3/jquery.url.js +174 -0
- data/spec/coverage/assets/0.5.3/loading.gif +0 -0
- data/spec/coverage/assets/0.5.3/magnify.png +0 -0
- data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/spec/coverage/assets/0.5.3/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/spec/coverage/assets/0.5.3/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/spec/coverage/assets/0.5.3/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/spec/coverage/assets/0.5.3/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/spec/coverage/assets/0.5.3/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/spec/coverage/assets/0.5.3/smoothness/jquery-ui-1.8.4.custom.css +295 -0
- data/spec/coverage/assets/0.5.3/stylesheet.css +383 -0
- data/spec/coverage/index.html +81 -0
- data/spec/dealer_runner_spec.rb +83 -0
- data/spec/support/spec_helper.rb +33 -0
- data/vendor/project_acpc_server/LICENCE +23 -0
- data/vendor/project_acpc_server/Makefile +22 -0
- data/vendor/project_acpc_server/README +113 -0
- data/vendor/project_acpc_server/README.submission +42 -0
- data/vendor/project_acpc_server/acpc_play_match.pl +101 -0
- data/vendor/project_acpc_server/bm_server +0 -0
- data/vendor/project_acpc_server/bm_server.c +1557 -0
- data/vendor/project_acpc_server/bm_server.config +78 -0
- data/vendor/project_acpc_server/bm_widget +0 -0
- data/vendor/project_acpc_server/bm_widget.c +186 -0
- data/vendor/project_acpc_server/dealer +0 -0
- data/vendor/project_acpc_server/dealer.c +1278 -0
- data/vendor/project_acpc_server/evalHandTables +4269 -0
- data/vendor/project_acpc_server/example_player +0 -0
- data/vendor/project_acpc_server/example_player.c +204 -0
- data/vendor/project_acpc_server/example_player.limit.2p.sh +2 -0
- data/vendor/project_acpc_server/example_player.limit.3p.sh +2 -0
- data/vendor/project_acpc_server/example_player.nolimit.2p.sh +2 -0
- data/vendor/project_acpc_server/example_player.nolimit.3p.sh +2 -0
- data/vendor/project_acpc_server/game.c +1793 -0
- data/vendor/project_acpc_server/game.h +253 -0
- data/vendor/project_acpc_server/holdem.limit.2p.reverse_blinds.game +13 -0
- data/vendor/project_acpc_server/holdem.limit.3p.game +13 -0
- data/vendor/project_acpc_server/holdem.nolimit.2p.reverse_blinds.game +12 -0
- data/vendor/project_acpc_server/holdem.nolimit.3p.game +12 -0
- data/vendor/project_acpc_server/net.c +218 -0
- data/vendor/project_acpc_server/net.h +61 -0
- data/vendor/project_acpc_server/play_match.pl +99 -0
- data/vendor/project_acpc_server/protocol.odt +0 -0
- data/vendor/project_acpc_server/protocol.pdf +0 -0
- data/vendor/project_acpc_server/rng.c +138 -0
- data/vendor/project_acpc_server/rng.h +63 -0
- data/vendor/project_acpc_server/test.log +11 -0
- data/vendor/project_acpc_server/validate_submission.pl +546 -0
- metadata +315 -0
Binary file
|
@@ -0,0 +1,204 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (C) 2011 by the Computer Poker Research Group, University of Alberta
|
3
|
+
*/
|
4
|
+
|
5
|
+
#include <stdlib.h>
|
6
|
+
#include <stdio.h>
|
7
|
+
#include <assert.h>
|
8
|
+
#include <string.h>
|
9
|
+
#include <unistd.h>
|
10
|
+
#include <netdb.h>
|
11
|
+
#include <sys/socket.h>
|
12
|
+
#include <sys/time.h>
|
13
|
+
#include <netinet/in.h>
|
14
|
+
#include <netinet/tcp.h>
|
15
|
+
#include <getopt.h>
|
16
|
+
#include "game.h"
|
17
|
+
#include "rng.h"
|
18
|
+
#include "net.h"
|
19
|
+
|
20
|
+
int main( int argc, char **argv )
|
21
|
+
{
|
22
|
+
int sock, len, r, a;
|
23
|
+
int32_t min, max;
|
24
|
+
uint16_t port;
|
25
|
+
double p;
|
26
|
+
Game *game;
|
27
|
+
MatchState state;
|
28
|
+
Action action;
|
29
|
+
FILE *file, *toServer, *fromServer;
|
30
|
+
struct timeval tv;
|
31
|
+
double probs[ NUM_ACTION_TYPES ];
|
32
|
+
double actionProbs[ NUM_ACTION_TYPES ];
|
33
|
+
rng_state_t rng;
|
34
|
+
char line[ MAX_LINE_LEN ];
|
35
|
+
|
36
|
+
/* we make some assumptions about the actions - check them here */
|
37
|
+
assert( NUM_ACTION_TYPES == 3 );
|
38
|
+
|
39
|
+
if( argc < 4 ) {
|
40
|
+
|
41
|
+
fprintf( stderr, "usage: player game server port\n" );
|
42
|
+
exit( EXIT_FAILURE );
|
43
|
+
}
|
44
|
+
|
45
|
+
/* Define the probabilities of actions for the player */
|
46
|
+
probs[ a_fold ] = 0.06;
|
47
|
+
probs[ a_call ] = ( 1.0 - probs[ a_fold ] ) * 0.5;
|
48
|
+
probs[ a_raise ] = ( 1.0 - probs[ a_fold ] ) * 0.5;
|
49
|
+
|
50
|
+
/* Initialize the player's random number state using time */
|
51
|
+
gettimeofday( &tv, NULL );
|
52
|
+
init_genrand( &rng, tv.tv_usec );
|
53
|
+
|
54
|
+
/* get the game */
|
55
|
+
file = fopen( argv[ 1 ], "r" );
|
56
|
+
if( file == NULL ) {
|
57
|
+
|
58
|
+
fprintf( stderr, "ERROR: could not open game %s\n", argv[ 1 ] );
|
59
|
+
exit( EXIT_FAILURE );
|
60
|
+
}
|
61
|
+
game = readGame( file );
|
62
|
+
if( game == NULL ) {
|
63
|
+
|
64
|
+
fprintf( stderr, "ERROR: could not read game %s\n", argv[ 1 ] );
|
65
|
+
exit( EXIT_FAILURE );
|
66
|
+
}
|
67
|
+
fclose( file );
|
68
|
+
|
69
|
+
/* connect to the dealer */
|
70
|
+
if( sscanf( argv[ 3 ], "%"SCNu16, &port ) < 1 ) {
|
71
|
+
|
72
|
+
fprintf( stderr, "ERROR: invalid port %s\n", argv[ 3 ] );
|
73
|
+
exit( EXIT_FAILURE );
|
74
|
+
}
|
75
|
+
sock = connectTo( argv[ 2 ], port );
|
76
|
+
if( sock < 0 ) {
|
77
|
+
|
78
|
+
exit( EXIT_FAILURE );
|
79
|
+
}
|
80
|
+
toServer = fdopen( sock, "w" );
|
81
|
+
fromServer = fdopen( sock, "r" );
|
82
|
+
if( toServer == NULL || fromServer == NULL ) {
|
83
|
+
|
84
|
+
fprintf( stderr, "ERROR: could not get socket streams\n" );
|
85
|
+
exit( EXIT_FAILURE );
|
86
|
+
}
|
87
|
+
|
88
|
+
/* send version string to dealer */
|
89
|
+
if( fprintf( toServer, "VERSION:%"PRIu32".%"PRIu32".%"PRIu32"\n",
|
90
|
+
VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION ) != 14 ) {
|
91
|
+
|
92
|
+
fprintf( stderr, "ERROR: could not get send version to server\n" );
|
93
|
+
exit( EXIT_FAILURE );
|
94
|
+
}
|
95
|
+
fflush( toServer );
|
96
|
+
|
97
|
+
/* play the game! */
|
98
|
+
while( fgets( line, MAX_LINE_LEN, fromServer ) ) {
|
99
|
+
|
100
|
+
/* ignore comments */
|
101
|
+
if( line[ 0 ] == '#' || line[ 0 ] == ';' ) {
|
102
|
+
continue;
|
103
|
+
}
|
104
|
+
|
105
|
+
len = readMatchState( line, game, &state );
|
106
|
+
if( len < 0 ) {
|
107
|
+
|
108
|
+
fprintf( stderr, "ERROR: could not read state %s", line );
|
109
|
+
exit( EXIT_FAILURE );
|
110
|
+
}
|
111
|
+
|
112
|
+
if( stateFinished( &state.state ) ) {
|
113
|
+
/* ignore the game over message */
|
114
|
+
|
115
|
+
continue;
|
116
|
+
}
|
117
|
+
|
118
|
+
if( currentPlayer( game, &state.state ) != state.viewingPlayer ) {
|
119
|
+
/* we're not acting */
|
120
|
+
|
121
|
+
continue;
|
122
|
+
}
|
123
|
+
|
124
|
+
/* add a colon (guaranteed to fit because we read a new-line in fgets) */
|
125
|
+
line[ len ] = ':';
|
126
|
+
++len;
|
127
|
+
|
128
|
+
/* build the set of valid actions */
|
129
|
+
p = 0;
|
130
|
+
for( a = 0; a < NUM_ACTION_TYPES; ++a ) {
|
131
|
+
|
132
|
+
actionProbs[ a ] = 0.0;
|
133
|
+
}
|
134
|
+
|
135
|
+
/* consider fold */
|
136
|
+
action.type = a_fold;
|
137
|
+
action.size = 0;
|
138
|
+
if( isValidAction( game, &state.state, 0, &action ) ) {
|
139
|
+
|
140
|
+
actionProbs[ a_fold ] = probs[ a_fold ];
|
141
|
+
p += probs[ a_fold ];
|
142
|
+
}
|
143
|
+
|
144
|
+
/* consider call */
|
145
|
+
action.type = a_call;
|
146
|
+
action.size = 0;
|
147
|
+
actionProbs[ a_call ] = probs[ a_call ];
|
148
|
+
p += probs[ a_call ];
|
149
|
+
|
150
|
+
/* consider raise */
|
151
|
+
if( raiseIsValid( game, &state.state, &min, &max ) ) {
|
152
|
+
|
153
|
+
actionProbs[ a_raise ] = probs[ a_raise ];
|
154
|
+
p += probs[ a_raise ];
|
155
|
+
}
|
156
|
+
|
157
|
+
/* normalise the probabilities */
|
158
|
+
assert( p > 0.0 );
|
159
|
+
for( a = 0; a < NUM_ACTION_TYPES; ++a ) {
|
160
|
+
|
161
|
+
actionProbs[ a ] /= p;
|
162
|
+
}
|
163
|
+
|
164
|
+
/* choose one of the valid actions at random */
|
165
|
+
p = genrand_real2( &rng );
|
166
|
+
for( a = 0; a < NUM_ACTION_TYPES - 1; ++a ) {
|
167
|
+
|
168
|
+
if( p <= actionProbs[ a ] ) {
|
169
|
+
|
170
|
+
break;
|
171
|
+
}
|
172
|
+
p -= actionProbs[ a ];
|
173
|
+
}
|
174
|
+
action.type = (enum ActionType)a;
|
175
|
+
if( a == a_raise ) {
|
176
|
+
|
177
|
+
action.size = min + genrand_int32( &rng ) % ( max - min + 1 );
|
178
|
+
}
|
179
|
+
|
180
|
+
/* do the action! */
|
181
|
+
assert( isValidAction( game, &state.state, 0, &action ) );
|
182
|
+
r = printAction( game, &action, MAX_LINE_LEN - len - 2,
|
183
|
+
&line[ len ] );
|
184
|
+
if( r < 0 ) {
|
185
|
+
|
186
|
+
fprintf( stderr, "ERROR: line too long after printing action\n" );
|
187
|
+
exit( EXIT_FAILURE );
|
188
|
+
}
|
189
|
+
len += r;
|
190
|
+
line[ len ] = '\r';
|
191
|
+
++len;
|
192
|
+
line[ len ] = '\n';
|
193
|
+
++len;
|
194
|
+
|
195
|
+
if( fwrite( line, 1, len, toServer ) != len ) {
|
196
|
+
|
197
|
+
fprintf( stderr, "ERROR: could not get send response to server\n" );
|
198
|
+
exit( EXIT_FAILURE );
|
199
|
+
}
|
200
|
+
fflush( toServer );
|
201
|
+
}
|
202
|
+
|
203
|
+
return EXIT_SUCCESS;
|
204
|
+
}
|