@@ -177,156 +177,6 @@ public static Game runOne(GameType gameToPlay, String parameterConfigFile, List<
177
177
return game ;
178
178
}
179
179
180
- /**
181
- * Runs several games with a given random seed.
182
- *
183
- * @param gamesToPlay - list of games to play.
184
- * @param players - list of players for the game.
185
- * @param nRepetitions - number of repetitions of each game.
186
- * @param seed - random seed for all games. If null, a new random seed is used for each game.
187
- * @param randomizeParameters - if true, game parameters are randomized for each run of each game (if possible).
188
- * @param detailedStatistics - if true, detailed statistics are printed, otherwise just average of wins
189
- */
190
- public static void runMany (List <GameType > gamesToPlay , List <AbstractPlayer > players , Long seed ,
191
- int nRepetitions , boolean randomizeParameters ,
192
- boolean detailedStatistics , List <IGameListener > listeners , int turnPause ) {
193
- int nPlayers = players .size ();
194
-
195
- // Save win rate statistics over all games
196
- TAGNumericStatSummary [] overall = new TAGNumericStatSummary [nPlayers ];
197
- String [] agentNames = new String [nPlayers ];
198
- for (int i = 0 ; i < nPlayers ; i ++) {
199
- String [] split = players .get (i ).getClass ().toString ().split ("\\ ." );
200
- String agentName = split [split .length - 1 ] + "-" + i ;
201
- overall [i ] = new TAGNumericStatSummary ("Overall " + agentName );
202
- agentNames [i ] = agentName ;
203
- }
204
-
205
- // For each game...
206
- for (GameType gt : gamesToPlay ) {
207
-
208
- // Save win rate statistics over all repetitions of this game
209
- TAGNumericStatSummary [] statSummaries = new TAGNumericStatSummary [nPlayers ];
210
- for (int i = 0 ; i < nPlayers ; i ++) {
211
- statSummaries [i ] = new TAGNumericStatSummary ("{Game: " + gt .name () + "; Player: " + agentNames [i ] + "}" );
212
- }
213
-
214
- // Play n repetitions of this game and record player results
215
- Game game = null ;
216
- int offset = 0 ;
217
- for (int i = 0 ; i < nRepetitions ; i ++) {
218
- Long s = seed ;
219
- if (s == null ) s = System .currentTimeMillis ();
220
- s += offset ;
221
- game = runOne (gt , null , players , s , randomizeParameters , listeners , null , turnPause );
222
- if (game != null ) {
223
- recordPlayerResults (statSummaries , game );
224
- offset = game .getGameState ().getRoundCounter () * game .getGameState ().getNPlayers ();
225
- } else {
226
- break ;
227
- }
228
- // System.out.println("Game " + i + "/" + nRepetitions);
229
- }
230
-
231
- if (game != null ) {
232
- System .out .println ("---------------------" );
233
- for (int i = 0 ; i < nPlayers ; i ++) {
234
- // Print statistics for this game
235
- if (detailedStatistics ) {
236
- System .out .println (statSummaries [i ].toString ());
237
- } else {
238
- System .out .println (statSummaries [i ].name + ": " + statSummaries [i ].mean () + " (n=" + statSummaries [i ].n () + ")" );
239
- }
240
-
241
- // Record in overall statistics
242
- overall [i ].add (statSummaries [i ]);
243
- }
244
- }
245
- }
246
-
247
- // Print final statistics
248
- System .out .println ("\n =====================\n " );
249
- for (int i = 0 ; i < nPlayers ; i ++) {
250
- // Print statistics for this game
251
- if (detailedStatistics ) {
252
- System .out .println (overall [i ].toString ());
253
- } else {
254
- System .out .println (overall [i ].name + ": " + overall [i ].mean ());
255
- }
256
- }
257
- }
258
-
259
- /**
260
- * Runs several games with a set of random seeds, one for each repetition of a game.
261
- *
262
- * @param gamesToPlay - list of games to play.
263
- * @param players - list of players for the game.
264
- * @param nRepetitions - number of repetitions of each game.
265
- * @param seeds - random seeds array, one for each repetition of a game.
266
- * @param ac - action controller for GUI interactions, null if playing without visuals.
267
- * @param randomizeParameters - if true, game parameters are randomized for each run of each game (if possible).
268
- */
269
- public static void runMany (List <GameType > gamesToPlay , List <AbstractPlayer > players , int nRepetitions ,
270
- long [] seeds , ActionController ac , boolean randomizeParameters , List <IGameListener > listeners , int turnPause ) {
271
- int nPlayers = players .size ();
272
-
273
- // Save win rate statistics over all games
274
- TAGNumericStatSummary [] overall = new TAGNumericStatSummary [nPlayers ];
275
- for (int i = 0 ; i < nPlayers ; i ++) {
276
- overall [i ] = new TAGNumericStatSummary ("Overall Player " + i );
277
- }
278
-
279
- // For each game...
280
- for (GameType gt : gamesToPlay ) {
281
-
282
- // Save win rate statistics over all repetitions of this game
283
- TAGNumericStatSummary [] statSummaries = new TAGNumericStatSummary [nPlayers ];
284
- for (int i = 0 ; i < nPlayers ; i ++) {
285
- statSummaries [i ] = new TAGNumericStatSummary ("Game: " + gt .name () + "; Player: " + i );
286
- }
287
-
288
- // Play n repetitions of this game and record player results
289
- for (int i = 0 ; i < nRepetitions ; i ++) {
290
- Game game = runOne (gt , null , players , seeds [i ], randomizeParameters , listeners , null , turnPause );
291
- if (game != null ) {
292
- recordPlayerResults (statSummaries , game );
293
- }
294
- }
295
-
296
- for (int i = 0 ; i < nPlayers ; i ++) {
297
- // Print statistics for this game
298
- System .out .println (statSummaries [i ].toString ());
299
-
300
- // Record in overall statistics
301
- overall [i ].add (statSummaries [i ]);
302
- }
303
- }
304
-
305
- // Print final statistics
306
- System .out .println ("\n ---------------------\n " );
307
- for (int i = 0 ; i < nPlayers ; i ++) {
308
- // Print statistics for this game
309
- System .out .println (overall [i ].toString ());
310
- }
311
- }
312
-
313
- /**
314
- * Records statistics of given game into the given StatSummary objects. Only WIN, LOSE or DRAW are valid results
315
- * recorded.
316
- *
317
- * @param statSummaries - object recording statistics
318
- * @param game - finished game
319
- */
320
- public static void recordPlayerResults (TAGNumericStatSummary [] statSummaries , Game game ) {
321
- int nPlayers = statSummaries .length ;
322
- CoreConstants .GameResult [] results = game .getGameState ().getPlayerResults ();
323
- for (int p = 0 ; p < nPlayers ; p ++) {
324
- if (results [p ] == CoreConstants .GameResult .WIN_GAME || results [p ] == CoreConstants .GameResult .LOSE_GAME || results [p ] == CoreConstants .GameResult .DRAW_GAME ) {
325
- statSummaries [p ].add (results [p ].value );
326
- }
327
- }
328
- }
329
-
330
180
public void setTurnPause (int turnPause ) {
331
181
this .turnPause = turnPause ;
332
182
}
0 commit comments