acpc_dealer 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/acpc_dealer.gemspec +2 -2
- data/lib/acpc_dealer.rb +4 -3
- data/lib/acpc_dealer/version.rb +1 -1
- 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/assets/0.7.1/application.css +1110 -0
- data/spec/coverage/assets/0.7.1/application.js +626 -0
- data/spec/coverage/assets/0.7.1/fancybox/blank.gif +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_close.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_loading.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_nav_left.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_nav_right.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_e.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_n.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_ne.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_nw.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_s.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_se.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_sw.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_shadow_w.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_title_left.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_title_main.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_title_over.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancy_title_right.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancybox-x.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancybox-y.png +0 -0
- data/spec/coverage/assets/0.7.1/fancybox/fancybox.png +0 -0
- data/spec/coverage/assets/0.7.1/favicon_green.png +0 -0
- data/spec/coverage/assets/0.7.1/favicon_red.png +0 -0
- data/spec/coverage/assets/0.7.1/favicon_yellow.png +0 -0
- data/spec/coverage/assets/0.7.1/loading.gif +0 -0
- data/spec/coverage/assets/0.7.1/magnify.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/spec/coverage/assets/0.7.1/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/spec/coverage/index.html +72 -0
- data/spec/dealer_runner_spec.rb +6 -5
- data/spec/support/spec_helper.rb +3 -1
- data/spec/test_match.actions.log +4 -0
- data/vendor/project_acpc_server/bm_server +0 -0
- data/vendor/project_acpc_server/bm_server.c +78 -31
- data/vendor/project_acpc_server/bm_widget +0 -0
- data/vendor/project_acpc_server/bm_widget.c +35 -0
- data/vendor/project_acpc_server/dealer +0 -0
- data/vendor/project_acpc_server/dealer.c +13 -2
- data/vendor/project_acpc_server/example_player +0 -0
- data/vendor/project_acpc_server/hi.log +0 -0
- data/vendor/project_acpc_server/rng.c +14 -13
- data/vendor/project_acpc_server/rng.h +3 -3
- metadata +226 -47
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,72 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html xmlns='http://www.w3.org/1999/xhtml'>
|
3
|
+
<head>
|
4
|
+
<title>Code coverage for Spec</title>
|
5
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
6
|
+
<script src='./assets/0.7.1/application.js' type='text/javascript'></script>
|
7
|
+
<link href='./assets/0.7.1/application.css' media='screen, projection, print' rel='stylesheet' type='text/css'>
|
8
|
+
<link rel="shortcut icon" type="image/png" href="./assets/0.7.1/favicon_green.png" />
|
9
|
+
<link rel="icon" type="image/png" href="./assets/0.7.1/favicon.png" />
|
10
|
+
</head>
|
11
|
+
|
12
|
+
<body>
|
13
|
+
<div id="loading">
|
14
|
+
<img src="./assets/0.7.1/loading.gif" alt="loading"/>
|
15
|
+
</div>
|
16
|
+
<div id="wrapper" style="display:none;">
|
17
|
+
<div class="timestamp">Generated <abbr class="timeago" title="2013-04-29T14:32:03-06:00">2013-04-29T14:32:03-06:00</abbr></div>
|
18
|
+
<ul class="group_tabs"></ul>
|
19
|
+
|
20
|
+
<div id="content">
|
21
|
+
<div class="file_list_container" id="AllFiles">
|
22
|
+
<h2>
|
23
|
+
<span class="group_name">All Files</span>
|
24
|
+
(<span class="covered_percent"><span class="green">100.0%</span></span>
|
25
|
+
covered at
|
26
|
+
<span class="covered_strength">
|
27
|
+
<span class="red">
|
28
|
+
0.0
|
29
|
+
</span>
|
30
|
+
</span> hits/line)
|
31
|
+
</h2>
|
32
|
+
<a name="AllFiles"></a>
|
33
|
+
<div>
|
34
|
+
<b>0</b> files in total.
|
35
|
+
<b>0.0</b> relevant lines.
|
36
|
+
<span class="green"><b>0.0</b> lines covered</span> and
|
37
|
+
<span class="red"><b>0.0</b> lines missed </span>
|
38
|
+
</div>
|
39
|
+
<table class="file_list">
|
40
|
+
<thead>
|
41
|
+
<tr>
|
42
|
+
<th>File</th>
|
43
|
+
<th>% covered</th>
|
44
|
+
<th>Lines</th>
|
45
|
+
<th>Relevant Lines</th>
|
46
|
+
<th>Lines covered</th>
|
47
|
+
<th>Lines missed</th>
|
48
|
+
<th>Avg. Hits / Line</th>
|
49
|
+
</tr>
|
50
|
+
</thead>
|
51
|
+
<tbody>
|
52
|
+
|
53
|
+
</tbody>
|
54
|
+
</table>
|
55
|
+
</div>
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
</div>
|
60
|
+
|
61
|
+
<div id="footer">
|
62
|
+
Generated by <a href="http://github.com/colszowka/simplecov">simplecov</a> v0.7.1
|
63
|
+
and simplecov-html v0.7.1<br/>
|
64
|
+
using RSpec
|
65
|
+
</div>
|
66
|
+
|
67
|
+
<div class="source_files">
|
68
|
+
|
69
|
+
</div>
|
70
|
+
</div>
|
71
|
+
</body>
|
72
|
+
</html>
|
data/spec/dealer_runner_spec.rb
CHANGED
@@ -17,7 +17,7 @@ describe DealerRunner do
|
|
17
17
|
it 'returns two random open ports' do
|
18
18
|
various_numbers_of_players.each do |number_of_players|
|
19
19
|
DealerRunner.ports_for_players(number_of_players).each do |port|
|
20
|
-
begin
|
20
|
+
begin
|
21
21
|
TCPServer.open('localhost', port) { }
|
22
22
|
rescue Errno::EADDRINUSE => e
|
23
23
|
flunk "Port #{port} is not open: #{e.message}"
|
@@ -40,14 +40,14 @@ describe DealerRunner do
|
|
40
40
|
player_names: number_of_players.times.inject([]) do |names, i|
|
41
41
|
names << "p#{i}"
|
42
42
|
end.join(' '),
|
43
|
-
options: ['--
|
43
|
+
options: ['--start_timeout 1000'].join(' ')
|
44
44
|
},
|
45
45
|
temp_log_directory
|
46
46
|
)
|
47
47
|
|
48
48
|
@pid = result[:pid]
|
49
49
|
@port_numbers = result[:port_numbers]
|
50
|
-
|
50
|
+
|
51
51
|
result[:log_directory].must_equal temp_log_directory
|
52
52
|
|
53
53
|
check_ports_are_in_use
|
@@ -59,9 +59,10 @@ describe DealerRunner do
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
def cleanup
|
64
64
|
Process.kill 'KILL', @pid
|
65
|
+
sleep 1
|
65
66
|
|
66
67
|
->() { Process.getpgid(@pid) }.must_raise Errno::ESRCH
|
67
68
|
end
|
@@ -74,7 +75,7 @@ describe DealerRunner do
|
|
74
75
|
end
|
75
76
|
def check_ports_are_in_use
|
76
77
|
@port_numbers.each do |port|
|
77
|
-
->() do
|
78
|
+
->() do
|
78
79
|
TCPServer.open('localhost', port)
|
79
80
|
end.must_raise Errno::EADDRINUSE
|
80
81
|
end
|
data/spec/support/spec_helper.rb
CHANGED
@@ -6,7 +6,7 @@ require 'minitest/spec'
|
|
6
6
|
require 'minitest/autorun'
|
7
7
|
require 'minitest/pride'
|
8
8
|
|
9
|
-
begin
|
9
|
+
begin
|
10
10
|
require 'turn/autorun'
|
11
11
|
|
12
12
|
Turn.config do |c|
|
@@ -28,6 +28,8 @@ begin
|
|
28
28
|
obj.awesome_inspect
|
29
29
|
end
|
30
30
|
end
|
31
|
+
|
32
|
+
require 'pry-rescue/minitest'
|
31
33
|
rescue LoadError
|
32
34
|
end
|
33
35
|
|
Binary file
|
@@ -101,6 +101,9 @@ typedef struct {
|
|
101
101
|
UserSpec *user;
|
102
102
|
int numRuns;
|
103
103
|
rng_state_t rng;
|
104
|
+
uint32_t rngSeed;
|
105
|
+
int useRngForSeed; /* 0: use rngSeed as seed for each dealer run
|
106
|
+
1: use genrand_int32( match->rng ) */
|
104
107
|
char *tag;
|
105
108
|
struct timeval queueTime;
|
106
109
|
struct {
|
@@ -769,9 +772,17 @@ int parseMatchSpec( const Config *conf,
|
|
769
772
|
}
|
770
773
|
|
771
774
|
match->tag = strdup( tag );
|
775
|
+
match->rngSeed = rngSeed;
|
772
776
|
if( rngSeed ) {
|
773
777
|
|
774
778
|
init_genrand( &match->rng, rngSeed );
|
779
|
+
if( match->numRuns == 1 ) {
|
780
|
+
|
781
|
+
match->useRngForSeed = 0;
|
782
|
+
} else {
|
783
|
+
|
784
|
+
match->useRngForSeed = 1;
|
785
|
+
}
|
775
786
|
} else {
|
776
787
|
|
777
788
|
init_genrand( &match->rng, genrand_int32( &serv->rng ) );
|
@@ -802,7 +813,7 @@ void writeGameList( const Config *conf, int fd )
|
|
802
813
|
cur != NULL; cur = LLPoolNextEntry( cur ) ) {
|
803
814
|
GameConfig *game = (GameConfig *)LLPoolGetItem( cur );
|
804
815
|
|
805
|
-
r =
|
816
|
+
r = snprintf( line, sizeof( line ), "\n%s\n", game->gameFile );
|
806
817
|
assert( r > 0 );
|
807
818
|
r = write( fd, line, r );
|
808
819
|
|
@@ -810,7 +821,7 @@ void writeGameList( const Config *conf, int fd )
|
|
810
821
|
botCur != NULL; botCur = LLPoolNextEntry( botCur ) ) {
|
811
822
|
BotSpec *bot = (BotSpec *)LLPoolGetItem( botCur );
|
812
823
|
|
813
|
-
r =
|
824
|
+
r = snprintf( line, sizeof( line ), " %s\n", bot->name );
|
814
825
|
assert( r > 0 );
|
815
826
|
r = write( fd, line, r );
|
816
827
|
}
|
@@ -831,13 +842,14 @@ void writeQueueStatus( const Config *conf, const ServerState *serv, int fd )
|
|
831
842
|
cur != NULL; cur = LLPoolNextEntry( cur ) ) {
|
832
843
|
Match *match = (Match *)LLPoolGetItem( cur );
|
833
844
|
|
834
|
-
r =
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
845
|
+
r = snprintf( line,
|
846
|
+
sizeof( line ),
|
847
|
+
"%s %s %s * %d %s\n",
|
848
|
+
match->user->name,
|
849
|
+
match->tag,
|
850
|
+
match->gameConf->gameFile,
|
851
|
+
match->numRuns,
|
852
|
+
match->isRunning ? "R" : "Q" );
|
841
853
|
assert( r > 0 );
|
842
854
|
r = write( fd, line, r );
|
843
855
|
}
|
@@ -913,7 +925,7 @@ void handleConnection( Config *conf, ServerState *serv,
|
|
913
925
|
|
914
926
|
int timeIsEarlier( struct timeval *a, struct timeval *b )
|
915
927
|
{
|
916
|
-
if( a->tv_sec < b->
|
928
|
+
if( a->tv_sec < b->tv_sec ) {
|
917
929
|
return 1;
|
918
930
|
} else if( a->tv_sec == b->tv_sec
|
919
931
|
&& a->tv_usec < b->tv_usec ) {
|
@@ -939,7 +951,10 @@ int botsInMatch( const Match *match )
|
|
939
951
|
return num;
|
940
952
|
}
|
941
953
|
|
942
|
-
void startDealer( const Config *conf,
|
954
|
+
void startDealer( const Config *conf,
|
955
|
+
const Match *match,
|
956
|
+
MatchJob *job,
|
957
|
+
const uint32_t rngSeed )
|
943
958
|
{
|
944
959
|
int stdoutPipe[ 2 ], p, arg;
|
945
960
|
char handsString[ 16 ], rngString[ 16 ];
|
@@ -964,7 +979,7 @@ void startDealer( const Config *conf, const Match *match, MatchJob *job )
|
|
964
979
|
int stderrfd;
|
965
980
|
char tag[ READBUF_LEN ];
|
966
981
|
|
967
|
-
|
982
|
+
snprintf( tag, sizeof( tag ), "%s/%s.stderr", BM_LOGDIR, job->tag );
|
968
983
|
stderrfd = open( tag, O_WRONLY | O_APPEND | O_CREAT, 0644 );
|
969
984
|
if( stderrfd < 0 ) {
|
970
985
|
|
@@ -984,20 +999,21 @@ void startDealer( const Config *conf, const Match *match, MatchJob *job )
|
|
984
999
|
argv[ arg ] = BM_DEALER;
|
985
1000
|
++arg;
|
986
1001
|
|
987
|
-
|
1002
|
+
snprintf( tag, sizeof( tag ), "%s/%s", BM_LOGDIR, job->tag );
|
988
1003
|
argv[ arg ] = tag;
|
989
1004
|
++arg;
|
990
1005
|
|
991
1006
|
argv[ arg ] = match->gameConf->gameFile;
|
992
1007
|
++arg;
|
993
1008
|
|
994
|
-
|
1009
|
+
snprintf( handsString,
|
1010
|
+
sizeof( handsString ),
|
1011
|
+
"%"PRIu32,
|
1012
|
+
match->gameConf->matchHands );
|
995
1013
|
argv[ arg ] = handsString;
|
996
1014
|
++arg;
|
997
1015
|
|
998
|
-
|
999
|
-
genrand_int32( &( (Match *)LLPoolGetItem( job->matchEntry ) )
|
1000
|
-
->rng ) );
|
1016
|
+
snprintf( rngString, sizeof( rngString ), "%"PRIu32, rngSeed );
|
1001
1017
|
argv[ arg ] = rngString;
|
1002
1018
|
++arg;
|
1003
1019
|
|
@@ -1021,8 +1037,10 @@ void startDealer( const Config *conf, const Match *match, MatchJob *job )
|
|
1021
1037
|
argv[ arg ] = "--start_timeout";
|
1022
1038
|
++arg;
|
1023
1039
|
|
1024
|
-
|
1025
|
-
|
1040
|
+
snprintf( startupTimeoutString,
|
1041
|
+
sizeof( startupTimeoutString ),
|
1042
|
+
"%d",
|
1043
|
+
(int)conf->startupTimeoutSecs * 1000 );
|
1026
1044
|
argv[ arg ] = startupTimeoutString;
|
1027
1045
|
++arg;
|
1028
1046
|
}
|
@@ -1031,8 +1049,10 @@ void startDealer( const Config *conf, const Match *match, MatchJob *job )
|
|
1031
1049
|
argv[ arg ] = "--t_response";
|
1032
1050
|
++arg;
|
1033
1051
|
|
1034
|
-
|
1035
|
-
|
1052
|
+
snprintf( responseTimeoutString,
|
1053
|
+
sizeof( responseTimeoutString ),
|
1054
|
+
"%d",
|
1055
|
+
(int)conf->responseTimeoutSecs * 1000 );
|
1036
1056
|
argv[ arg ] = responseTimeoutString;
|
1037
1057
|
++arg;
|
1038
1058
|
|
@@ -1040,7 +1060,10 @@ void startDealer( const Config *conf, const Match *match, MatchJob *job )
|
|
1040
1060
|
argv[ arg ] = "--t_hand";
|
1041
1061
|
++arg;
|
1042
1062
|
|
1043
|
-
|
1063
|
+
snprintf( handTimeoutString,
|
1064
|
+
sizeof( handTimeoutString ),
|
1065
|
+
"%d",
|
1066
|
+
(int)conf->handTimeoutSecs * 1000 );
|
1044
1067
|
argv[ arg ] = handTimeoutString;
|
1045
1068
|
++arg;
|
1046
1069
|
|
@@ -1048,7 +1071,10 @@ void startDealer( const Config *conf, const Match *match, MatchJob *job )
|
|
1048
1071
|
argv[ arg ] = "--t_per_hand";
|
1049
1072
|
++arg;
|
1050
1073
|
|
1051
|
-
|
1074
|
+
snprintf( avgHandTimeString,
|
1075
|
+
sizeof( avgHandTimeString ),
|
1076
|
+
"%d",
|
1077
|
+
(int)conf->avgHandTimeSecs * 1000 );
|
1052
1078
|
argv[ arg ] = avgHandTimeString;
|
1053
1079
|
++arg;
|
1054
1080
|
|
@@ -1056,6 +1082,11 @@ void startDealer( const Config *conf, const Match *match, MatchJob *job )
|
|
1056
1082
|
argv[ arg ] = "-q";
|
1057
1083
|
++arg;
|
1058
1084
|
|
1085
|
+
/* Restore the appending behaviour so multiple matches get appended into
|
1086
|
+
* the same log file */
|
1087
|
+
argv[ arg ] = "-a";
|
1088
|
+
++arg;
|
1089
|
+
|
1059
1090
|
argv[ arg ] = NULL;
|
1060
1091
|
|
1061
1092
|
execv( BM_DEALER, argv );
|
@@ -1126,8 +1157,8 @@ pid_t startBot( const ServerState *serv,
|
|
1126
1157
|
char portString[ 8 ];
|
1127
1158
|
char posString[ 16 ];
|
1128
1159
|
|
1129
|
-
|
1130
|
-
|
1160
|
+
snprintf( portString, sizeof( portString ), "%"PRIu16, port );
|
1161
|
+
snprintf( posString, sizeof( posString ), "%d", botPosition );
|
1131
1162
|
|
1132
1163
|
/* throw away bot output */
|
1133
1164
|
dup2( serv->devnullfd, 1 );
|
@@ -1148,15 +1179,26 @@ pid_t startBot( const ServerState *serv,
|
|
1148
1179
|
}
|
1149
1180
|
|
1150
1181
|
int sendStartMessage( const ServerState *serv,
|
1182
|
+
const MatchJob *job,
|
1151
1183
|
const Connection *conn,
|
1152
1184
|
const uint16_t port )
|
1153
1185
|
{
|
1154
1186
|
int len;
|
1155
|
-
char msg[ strlen( serv->hostname ) +
|
1187
|
+
char msg[ strlen( serv->hostname ) + 12 + READBUF_LEN ];
|
1156
1188
|
|
1157
|
-
len =
|
1189
|
+
len = snprintf( msg, sizeof( msg ), "# RUNNING %s\n", job->tag );
|
1158
1190
|
assert( len > 0 );
|
1191
|
+
if( write( conn->connBuf->fd, msg, len ) < len ) {
|
1192
|
+
|
1193
|
+
fprintf( stderr, "BM_ERROR: short write to connection\n" );
|
1194
|
+
return -1;
|
1195
|
+
}
|
1159
1196
|
|
1197
|
+
len = snprintf( msg,
|
1198
|
+
sizeof( msg ),
|
1199
|
+
"RUN %s %"PRIu16"\n",
|
1200
|
+
serv->hostname, port );
|
1201
|
+
assert( len > 0 );
|
1160
1202
|
if( write( conn->connBuf->fd, msg, len ) < len ) {
|
1161
1203
|
|
1162
1204
|
fprintf( stderr, "BM_ERROR: short write to connection\n" );
|
@@ -1179,7 +1221,7 @@ MatchJob runMatchJob( const Config *conf,
|
|
1179
1221
|
job.matchEntry = matchEntry;
|
1180
1222
|
|
1181
1223
|
/* make the tag from the match tag */
|
1182
|
-
|
1224
|
+
snprintf( tag, sizeof( tag ), "%s.%s", match->user->name, match->tag );
|
1183
1225
|
job.tag = strdup( tag );
|
1184
1226
|
|
1185
1227
|
/* initialise all PIDs to 0 */
|
@@ -1190,7 +1232,7 @@ MatchJob runMatchJob( const Config *conf,
|
|
1190
1232
|
}
|
1191
1233
|
|
1192
1234
|
/* start the dealer */
|
1193
|
-
startDealer( conf, match, &job );
|
1235
|
+
startDealer( conf, match, &job, rngSeed );
|
1194
1236
|
|
1195
1237
|
/* deal with all the players */
|
1196
1238
|
botPosition = 0;
|
@@ -1200,7 +1242,7 @@ MatchJob runMatchJob( const Config *conf,
|
|
1200
1242
|
/* send message with port to network player to start up */
|
1201
1243
|
Connection *conn = (Connection*)LLPoolGetItem( match->players[ p ].entry );
|
1202
1244
|
|
1203
|
-
if( sendStartMessage( serv, conn, job.ports[ p ] ) < 0 ) {
|
1245
|
+
if( sendStartMessage( serv, &job, conn, job.ports[ p ] ) < 0 ) {
|
1204
1246
|
/* abort the job... */
|
1205
1247
|
|
1206
1248
|
fprintf( stderr, "BM_ERROR: aborting job\n" );
|
@@ -1309,7 +1351,12 @@ int startMatchJob( const Config *conf, ServerState *serv )
|
|
1309
1351
|
}
|
1310
1352
|
|
1311
1353
|
/* create the job */
|
1312
|
-
job = runMatchJob( conf,
|
1354
|
+
job = runMatchJob( conf,
|
1355
|
+
serv,
|
1356
|
+
best,
|
1357
|
+
bestMatch->useRngForSeed
|
1358
|
+
? genrand_int32( &bestMatch->rng )
|
1359
|
+
: bestMatch->rngSeed );
|
1313
1360
|
assert( job.dealerPID );
|
1314
1361
|
LLPoolAddItem( serv->jobs, &job );
|
1315
1362
|
|