acpc_dealer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. data/README.md +33 -0
  2. data/Rakefile +20 -0
  3. data/acpc_dealer.gemspec +29 -0
  4. data/bin/acpc_dealer +168 -0
  5. data/ext/hand_evaluator/extconf.rb +5 -0
  6. data/ext/hand_evaluator/hand_evaluator.c +38 -0
  7. data/lib/acpc_dealer/2p.limit.h5.r0.logs/2p.limit.h5.r0.actions.log +5 -0
  8. data/lib/acpc_dealer/2p.limit.h5.r0.logs/2p.limit.h5.r0.log +0 -0
  9. data/lib/acpc_dealer/dealer_runner.rb +72 -0
  10. data/lib/acpc_dealer/version.rb +3 -0
  11. data/lib/acpc_dealer.rb +33 -0
  12. data/lib/hand_evaluator.so +0 -0
  13. data/spec/coverage/assets/0.5.3/app.js +88 -0
  14. data/spec/coverage/assets/0.5.3/fancybox/blank.gif +0 -0
  15. data/spec/coverage/assets/0.5.3/fancybox/fancy_close.png +0 -0
  16. data/spec/coverage/assets/0.5.3/fancybox/fancy_loading.png +0 -0
  17. data/spec/coverage/assets/0.5.3/fancybox/fancy_nav_left.png +0 -0
  18. data/spec/coverage/assets/0.5.3/fancybox/fancy_nav_right.png +0 -0
  19. data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_e.png +0 -0
  20. data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_n.png +0 -0
  21. data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_ne.png +0 -0
  22. data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_nw.png +0 -0
  23. data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_s.png +0 -0
  24. data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_se.png +0 -0
  25. data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_sw.png +0 -0
  26. data/spec/coverage/assets/0.5.3/fancybox/fancy_shadow_w.png +0 -0
  27. data/spec/coverage/assets/0.5.3/fancybox/fancy_title_left.png +0 -0
  28. data/spec/coverage/assets/0.5.3/fancybox/fancy_title_main.png +0 -0
  29. data/spec/coverage/assets/0.5.3/fancybox/fancy_title_over.png +0 -0
  30. data/spec/coverage/assets/0.5.3/fancybox/fancy_title_right.png +0 -0
  31. data/spec/coverage/assets/0.5.3/fancybox/fancybox-x.png +0 -0
  32. data/spec/coverage/assets/0.5.3/fancybox/fancybox-y.png +0 -0
  33. data/spec/coverage/assets/0.5.3/fancybox/fancybox.png +0 -0
  34. data/spec/coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.css +363 -0
  35. data/spec/coverage/assets/0.5.3/fancybox/jquery.fancybox-1.3.1.pack.js +44 -0
  36. data/spec/coverage/assets/0.5.3/favicon_green.png +0 -0
  37. data/spec/coverage/assets/0.5.3/favicon_red.png +0 -0
  38. data/spec/coverage/assets/0.5.3/favicon_yellow.png +0 -0
  39. data/spec/coverage/assets/0.5.3/highlight.css +129 -0
  40. data/spec/coverage/assets/0.5.3/highlight.pack.js +1 -0
  41. data/spec/coverage/assets/0.5.3/jquery-1.6.2.min.js +18 -0
  42. data/spec/coverage/assets/0.5.3/jquery.dataTables.min.js +152 -0
  43. data/spec/coverage/assets/0.5.3/jquery.timeago.js +141 -0
  44. data/spec/coverage/assets/0.5.3/jquery.url.js +174 -0
  45. data/spec/coverage/assets/0.5.3/loading.gif +0 -0
  46. data/spec/coverage/assets/0.5.3/magnify.png +0 -0
  47. data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  48. data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  49. data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  50. data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  51. data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  52. data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  53. data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  54. data/spec/coverage/assets/0.5.3/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  55. data/spec/coverage/assets/0.5.3/smoothness/images/ui-icons_222222_256x240.png +0 -0
  56. data/spec/coverage/assets/0.5.3/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  57. data/spec/coverage/assets/0.5.3/smoothness/images/ui-icons_454545_256x240.png +0 -0
  58. data/spec/coverage/assets/0.5.3/smoothness/images/ui-icons_888888_256x240.png +0 -0
  59. data/spec/coverage/assets/0.5.3/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  60. data/spec/coverage/assets/0.5.3/smoothness/jquery-ui-1.8.4.custom.css +295 -0
  61. data/spec/coverage/assets/0.5.3/stylesheet.css +383 -0
  62. data/spec/coverage/index.html +81 -0
  63. data/spec/dealer_runner_spec.rb +83 -0
  64. data/spec/support/spec_helper.rb +33 -0
  65. data/vendor/project_acpc_server/LICENCE +23 -0
  66. data/vendor/project_acpc_server/Makefile +22 -0
  67. data/vendor/project_acpc_server/README +113 -0
  68. data/vendor/project_acpc_server/README.submission +42 -0
  69. data/vendor/project_acpc_server/acpc_play_match.pl +101 -0
  70. data/vendor/project_acpc_server/bm_server +0 -0
  71. data/vendor/project_acpc_server/bm_server.c +1557 -0
  72. data/vendor/project_acpc_server/bm_server.config +78 -0
  73. data/vendor/project_acpc_server/bm_widget +0 -0
  74. data/vendor/project_acpc_server/bm_widget.c +186 -0
  75. data/vendor/project_acpc_server/dealer +0 -0
  76. data/vendor/project_acpc_server/dealer.c +1278 -0
  77. data/vendor/project_acpc_server/evalHandTables +4269 -0
  78. data/vendor/project_acpc_server/example_player +0 -0
  79. data/vendor/project_acpc_server/example_player.c +204 -0
  80. data/vendor/project_acpc_server/example_player.limit.2p.sh +2 -0
  81. data/vendor/project_acpc_server/example_player.limit.3p.sh +2 -0
  82. data/vendor/project_acpc_server/example_player.nolimit.2p.sh +2 -0
  83. data/vendor/project_acpc_server/example_player.nolimit.3p.sh +2 -0
  84. data/vendor/project_acpc_server/game.c +1793 -0
  85. data/vendor/project_acpc_server/game.h +253 -0
  86. data/vendor/project_acpc_server/holdem.limit.2p.reverse_blinds.game +13 -0
  87. data/vendor/project_acpc_server/holdem.limit.3p.game +13 -0
  88. data/vendor/project_acpc_server/holdem.nolimit.2p.reverse_blinds.game +12 -0
  89. data/vendor/project_acpc_server/holdem.nolimit.3p.game +12 -0
  90. data/vendor/project_acpc_server/net.c +218 -0
  91. data/vendor/project_acpc_server/net.h +61 -0
  92. data/vendor/project_acpc_server/play_match.pl +99 -0
  93. data/vendor/project_acpc_server/protocol.odt +0 -0
  94. data/vendor/project_acpc_server/protocol.pdf +0 -0
  95. data/vendor/project_acpc_server/rng.c +138 -0
  96. data/vendor/project_acpc_server/rng.h +63 -0
  97. data/vendor/project_acpc_server/test.log +11 -0
  98. data/vendor/project_acpc_server/validate_submission.pl +546 -0
  99. metadata +315 -0
@@ -0,0 +1,78 @@
1
+ # port to connect to the server
2
+ port 54000
3
+
4
+ # maxmimum number of simultaneously locally running bots
5
+ # 0 disables
6
+ maxRunningBots 0
7
+
8
+ # maximum time in seconds to wait for clients to connect when starting a match
9
+ startupTimeoutSecs 100
10
+ # maximum time in seconds to wait for clients to act during a match
11
+ responseTimeoutSecs 600
12
+ # maximum time in seconds allowed for a client to play a given hand
13
+ handTimeoutSecs 21000
14
+ # average time in seconds allowed for a client to spend on each hand
15
+ avgHandTimeSecs 7
16
+
17
+ # heads up limit Texas Hold'em
18
+ game holdem.limit.2p.reverse_blinds.game {
19
+
20
+ # maximum number of times a match can be run with a single player request
21
+ maxMatchRuns 10
22
+
23
+ # maxmimum number of simultaneously running matches using this game
24
+ # 0 disables
25
+ maxRunningJobs 1
26
+
27
+ # number of hands in a match
28
+ matchHands 5000
29
+
30
+ # bot botName botStartupScript
31
+ # botStartupScript is run with 3 args: server name, port, local position
32
+ # local postion indicates which LOCAL bot this is (index starting from 0)
33
+ # This is useful when determining which of multiple machines to run on
34
+ bot testBot example_player.limit.2p.sh
35
+ }
36
+
37
+ # heads up limit Texas Hold'em
38
+ game holdem.nolimit.2p.reverse_blinds.game {
39
+
40
+ # maximum number of times a match can be run with a single player request
41
+ maxMatchRuns 10
42
+
43
+ # maxmimum number of simultaneously running matches using this game
44
+ # 0 disables
45
+ maxRunningJobs 1
46
+
47
+ # number of hands in a match
48
+ matchHands 5000
49
+
50
+ # bot botName botStartupScript
51
+ # botStartupScript is run with 3 args: server name, port, local position
52
+ # local postion indicates which LOCAL bot this is (index starting from 0)
53
+ # This is useful when determining which of multiple machines to run on
54
+ bot testBot example_player.nolimit.2p.sh
55
+ }
56
+
57
+ # heads up limit Texas Hold'em
58
+ game holdem.limit.3p.game {
59
+
60
+ # maximum number of times a match can be run with a single player request
61
+ maxMatchRuns 10
62
+
63
+ # maxmimum number of simultaneously running matches using this game
64
+ # 0 disables
65
+ maxRunningJobs 1
66
+
67
+ # number of hands in a match
68
+ matchHands 5000
69
+
70
+ # bot botName botStartupScript
71
+ # botStartupScript is run with 3 args: server name, port, local position
72
+ # local postion indicates which LOCAL bot this is (index starting from 0)
73
+ # This is useful when determining which of multiple machines to run on
74
+ bot testBot example_player.limit.3p.sh
75
+ }
76
+
77
+ # Users authorized to run jobs on the benchmark (user name pass)
78
+ user neil test
@@ -0,0 +1,186 @@
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
+ #define __STDC_FORMAT_MACROS
8
+ #include <inttypes.h>
9
+ #include <assert.h>
10
+ #include <string.h>
11
+ #include <unistd.h>
12
+ #include <netdb.h>
13
+ #include <sys/socket.h>
14
+ #include <netinet/in.h>
15
+ #include <netinet/tcp.h>
16
+ #include <sys/wait.h>
17
+ #include "net.h"
18
+
19
+
20
+ #define ARG_SERVERNAME 1
21
+ #define ARG_SERVERPORT 2
22
+ #define ARG_BOT_COMMAND 3
23
+ #define ARG_NUM_ARGS 4
24
+
25
+
26
+ static void printUsage( FILE *file )
27
+ {
28
+ fprintf( file, "usage: bm_widget bm_hostname bm_port bot_command\n" );
29
+ fprintf( file, " bot_command: agent executable, passed \"hostname port\"\n");
30
+ }
31
+
32
+
33
+ /* 0 on success, -1 on failure */
34
+ int login( char *user, char *passwd, FILE *conn )
35
+ {
36
+ if( fprintf( conn, "%s %s\n", user, passwd ) < 0 ) {
37
+
38
+ return -1;
39
+ }
40
+ fflush( conn );
41
+
42
+ return 0;
43
+ }
44
+
45
+
46
+ int main( int argc, char **argv )
47
+ {
48
+ int sock, i;
49
+ pid_t childPID;
50
+ uint16_t port;
51
+ ReadBuf *fromUser, *fromServer;
52
+ fd_set readfds;
53
+ char line[ READBUF_LEN ];
54
+
55
+ if( argc < ARG_NUM_ARGS ) {
56
+
57
+ printUsage( stderr );
58
+ exit( EXIT_FAILURE );
59
+ }
60
+
61
+
62
+ /* connect to the server */
63
+ if( sscanf( argv[ ARG_SERVERPORT ], "%"SCNu16, &port ) < 1 ) {
64
+
65
+ fprintf( stderr, "ERROR: invalid port %s\n", argv[ ARG_SERVERPORT ] );
66
+ exit( EXIT_FAILURE );
67
+ }
68
+ sock = connectTo( argv[ ARG_SERVERNAME ], port );
69
+ if( sock < 0 ) {
70
+
71
+ exit( EXIT_FAILURE );
72
+ }
73
+
74
+ /* set up read buffers */
75
+ fromUser = createReadBuf( 0 );
76
+ fromServer = createReadBuf( sock );
77
+
78
+ printf( "Log in with 'user password'\n" );
79
+ fflush( stdout );
80
+
81
+ /* main loop */
82
+ while( 1 ) {
83
+
84
+ /* clean up any children */
85
+ while( waitpid( -1, NULL, WNOHANG ) > 0 );
86
+
87
+ /* wait for input */
88
+ FD_ZERO( &readfds );
89
+ FD_SET( 0, &readfds );
90
+ FD_SET( sock, &readfds );
91
+ i = select( sock + 1, &readfds, NULL, NULL, NULL );
92
+ if( i < 0 ) {
93
+
94
+ fprintf( stderr, "ERROR: select failed\n" );
95
+ exit( EXIT_FAILURE );
96
+ }
97
+ if( i == 0 ) {
98
+ /* nothing ready - shouldn't happen without timeout */
99
+
100
+ continue;
101
+ }
102
+
103
+ /* handle user input by passing it directly to server */
104
+ if( FD_ISSET( 0, &readfds ) ) {
105
+
106
+ /* get the input */
107
+ while( ( i = getLine( fromUser, READBUF_LEN, line, 0 ) ) >= 0 ) {
108
+
109
+ if( i == 0 ) {
110
+ /* Done! */
111
+
112
+ exit( EXIT_SUCCESS );
113
+ }
114
+
115
+ /* write to server */
116
+ if( write( sock, line, i ) < 0 ) {
117
+
118
+ fprintf( stderr, "ERROR: failed while sending to server\n" );
119
+ exit( EXIT_FAILURE );
120
+ }
121
+ }
122
+ }
123
+
124
+ /* handle server messages */
125
+ if( FD_ISSET( sock, &readfds ) ) {
126
+
127
+ /* get the input */
128
+ while( ( i = getLine( fromServer, READBUF_LEN, line, 0 ) ) >= 0 ) {
129
+
130
+ if( i == 0 ) {
131
+
132
+ fprintf( stderr, "ERROR: server closed connection?\n" );
133
+ exit( EXIT_FAILURE );
134
+ }
135
+
136
+ /* check for server commands */
137
+ if( strncasecmp( line, "run ", 4 ) == 0 ) {
138
+
139
+ /* split the rest of the line into name ' ' port */
140
+ for( i = 4; line[ i ]; ++i ) {
141
+
142
+ if( line[ i ] == ' ' ) {
143
+ /* found the separator */
144
+
145
+ line[ i ] = 0;
146
+ break;
147
+ }
148
+ }
149
+
150
+ printf( "starting match %s:%s", &line[ 4 ], &line[ i + 1 ] );
151
+
152
+ /* run `command machine port` */
153
+ childPID = fork();
154
+ if( childPID < 0 ) {
155
+
156
+ fprintf( stderr, "ERROR: fork() failed\n" );
157
+ exit( EXIT_FAILURE );
158
+ }
159
+ if( childPID == 0 ) {
160
+ /* child runs the command */
161
+
162
+ execl( argv[ ARG_BOT_COMMAND ],
163
+ argv[ ARG_BOT_COMMAND ],
164
+ &line[ 4 ],
165
+ &line[ i + 1 ],
166
+ NULL );
167
+ fprintf( stderr,
168
+ "ERROR: could not run %s\n",
169
+ argv[ ARG_BOT_COMMAND ] );
170
+ exit( EXIT_FAILURE );
171
+ }
172
+ } else {
173
+ /* just a message, print it out */
174
+
175
+ if( fwrite( line, 1, i, stdout ) < 0 ) {
176
+
177
+ fprintf( stderr, "ERROR: failed while printing server message\n" );
178
+ exit( EXIT_FAILURE );
179
+ }
180
+ }
181
+ }
182
+ }
183
+ }
184
+
185
+ return EXIT_SUCCESS;
186
+ }
Binary file