3535var timeoutOption = CreateOption < int > ( "--timeout" , "Game timeout in seconds." , 30 , "-to" ) ;
3636var clientPortOption = CreateOption < int > ( "--client-port" , "Base client port for gRPC bots." , 50000 , "-cp" ) ;
3737var serverPortOption = CreateOption < int > ( "--server-port" , "Base server port for gRPC bots." , 49000 , "-sp" ) ;
38+ var patronsOption = CreateOption < string [ ] > ( "--patrons" , "Allowed patrons for this run. Use 'default' (alias: 'all') for standard set (all selectable, no TREASURY)." , Array . Empty < string > ( ) , "-p" ) ;
3839
3940var bot1NameArgument = CreateBotArgument ( "bot1" , "Name of the first bot or command." ) ;
4041var bot2NameArgument = CreateBotArgument ( "bot2" , "Name of the second bot or command." ) ;
4950 timeoutOption ,
5051 clientPortOption ,
5152 serverPortOption ,
53+ patronsOption ,
5254 bot1NameArgument ,
5355 bot2NameArgument ,
5456} ;
154156
155157#region Prepare game
156158
157- ScriptsOfTribute . AI . ScriptsOfTribute PrepareGame ( AI bot1 , AI bot2 , LogsEnabled enableLogs , ulong seed , LogFileNameProvider ? logProvider , int timeout )
159+ ScriptsOfTribute . AI . ScriptsOfTribute PrepareGame (
160+ AI bot1 ,
161+ AI bot2 ,
162+ LogsEnabled enableLogs , ulong seed , LogFileNameProvider ? logProvider , int timeout , IEnumerable < string > ? patronTokens
163+ )
158164{
159- var game = new ScriptsOfTribute . AI . ScriptsOfTribute ( bot1 , bot2 , TimeSpan . FromSeconds ( timeout ) )
165+ var game = new ScriptsOfTribute . AI . ScriptsOfTribute ( bot1 , bot2 , TimeSpan . FromSeconds ( timeout ) , patronTokens )
160166 {
161167 Seed = seed ,
162168 } ;
@@ -203,6 +209,7 @@ ScriptsOfTribute.AI.ScriptsOfTribute PrepareGame(AI bot1, AI bot2, LogsEnabled e
203209 int timeout = context . ParseResult . GetValueForOption ( timeoutOption ) ;
204210 int baseClientPort = context . ParseResult . GetValueForOption ( clientPortOption ) ;
205211 int baseServerPort = context . ParseResult . GetValueForOption ( serverPortOption ) ;
212+ IEnumerable < string > ? patrons = context . ParseResult . GetValueForOption ( patronsOption ) ;
206213 BotInfo ? bot1Info = context . ParseResult . GetValueForArgument ( bot1NameArgument ) ;
207214 BotInfo ? bot2Info = context . ParseResult . GetValueForArgument ( bot2NameArgument ) ;
208215
@@ -219,9 +226,9 @@ ScriptsOfTribute.AI.ScriptsOfTribute PrepareGame(AI bot1, AI bot2, LogsEnabled e
219226 ulong actualSeed = seed ?? ( ulong ) new Random ( ) . NextInt64 ( ) ;
220227
221228 if ( threads == 1 )
222- RunSingleThreaded ( runs , bot1Info , bot2Info , logs , logProvider , actualSeed , timeout , baseClientPort , baseServerPort , baseHost ) ;
229+ RunSingleThreaded ( runs , bot1Info , bot2Info , logs , logProvider , actualSeed , timeout , baseClientPort , baseServerPort , patrons , baseHost ) ;
223230 else
224- RunMultiThreaded ( runs , threads , bot1Info , bot2Info , logs , logProvider , actualSeed , timeout , baseClientPort , baseServerPort , baseHost ) ;
231+ RunMultiThreaded ( runs , threads , bot1Info , bot2Info , logs , logProvider , actualSeed , timeout , baseClientPort , baseServerPort , patrons , baseHost ) ;
225232} ) ;
226233
227234void RunSingleThreaded (
@@ -234,6 +241,7 @@ void RunSingleThreaded(
234241 int timeout ,
235242 int baseClientPort ,
236243 int baseServerPort ,
244+ IEnumerable < string > ? patrons ,
237245 string baseHost = "localhost"
238246)
239247{
@@ -262,7 +270,7 @@ void RunSingleThreaded(
262270
263271 for ( var i = 0 ; i < runs ; i ++ )
264272 {
265- var game = PrepareGame ( bot1 , bot2 , enableLogs , currentSeed , logFileNameProvider , timeout ) ;
273+ var game = PrepareGame ( bot1 , bot2 , enableLogs , currentSeed , logFileNameProvider , timeout , patrons ) ;
266274 currentSeed += 1 ;
267275
268276 granularWatch . Reset ( ) ;
@@ -301,6 +309,7 @@ void RunMultiThreaded(
301309 int timeout ,
302310 int baseClientPort ,
303311 int baseServerPort ,
312+ IEnumerable < string > ? patrons ,
304313 string baseHost = "localhost"
305314)
306315{
@@ -310,7 +319,13 @@ void RunMultiThreaded(
310319 var gamesPerThreadRemainder = runs % noOfThreads ;
311320 var threads = new Task < List < ScriptsOfTribute . Board . EndGameState > > [ noOfThreads ] ;
312321
313- List < ScriptsOfTribute . Board . EndGameState > PlayGames ( int amount , BotInfo bot1Info , BotInfo bot2Info , int threadNo , ulong seed )
322+ List < ScriptsOfTribute . Board . EndGameState > PlayGames (
323+ int amount ,
324+ BotInfo bot1Info ,
325+ BotInfo bot2Info ,
326+ int threadNo ,
327+ ulong seed ,
328+ IEnumerable < string > ? patronsLocal )
314329 {
315330 var results = new ScriptsOfTribute . Board . EndGameState [ amount ] ;
316331 var timeMeasurements = new long [ amount ] ;
@@ -321,7 +336,7 @@ void RunMultiThreaded(
321336
322337 for ( var i = 0 ; i < amount ; i ++ )
323338 {
324- var game = PrepareGame ( bot1 , bot2 , enableLogs , seed , logFileNameProvider , timeout ) ;
339+ var game = PrepareGame ( bot1 , bot2 , enableLogs , seed , logFileNameProvider , timeout , patronsLocal ) ;
325340 seed += 1 ;
326341
327342 watch . Reset ( ) ;
@@ -374,7 +389,7 @@ void RunMultiThreaded(
374389 ServerPort = baseServerPort + noOfThreads + i ,
375390 }
376391 : bot2Info ;
377- threads [ i ] = Task . Factory . StartNew ( ( ) => PlayGames ( gamesToPlay , bot1ThreadInfo , bot2ThreadInfo , threadNo , currentSeedCopy ) ) ;
392+ threads [ i ] = Task . Factory . StartNew ( ( ) => PlayGames ( gamesToPlay , bot1ThreadInfo , bot2ThreadInfo , threadNo , currentSeedCopy , patrons ) ) ;
378393 currentSeed += ( ulong ) gamesToPlay ;
379394 }
380395
0 commit comments