File tree Expand file tree Collapse file tree 4 files changed +15
-16
lines changed
Expand file tree Collapse file tree 4 files changed +15
-16
lines changed Original file line number Diff line number Diff line change @@ -93,14 +93,15 @@ public void startGame(BWClientConfiguration configuration) {
9393 }
9494 }
9595 while (liveGameData .isInGame ()) {
96- if ( liveGameData . getFrameCount () > 0 || ! configuration . unlimitedFrameZero ) {
97- performanceMetrics . totalFrameDuration . startTiming ();
98- }
99- botWrapper .onFrame ();
100- performanceMetrics .flushSideEffects .time (() -> getGame ().sideEffects .flushTo (liveGameData ));
101- performanceMetrics . totalFrameDuration . stopTiming ( );
96+ performanceMetrics . totalFrameDuration . timeIf (
97+ liveGameData . getFrameCount () > 0 || ! configuration . unlimitedFrameZero ,
98+ () -> {
99+ botWrapper .onFrame ();
100+ performanceMetrics .flushSideEffects .time (() -> getGame ().sideEffects .flushTo (liveGameData ));
101+ } );
102102 performanceMetrics .bwapiResponse .time (client ::update );
103103 if (!client .isConnected ()) {
104+ System .out .println ("Reconnecting..." );
104105 client .reconnect ();
105106 }
106107 }
Original file line number Diff line number Diff line change @@ -86,7 +86,6 @@ void record(double value) {
8686 avgValueExceeding = (avgValueExceeding * samplesExceeding + value ) / (samplesExceeding + 1d );
8787 ++samplesExceeding ;
8888 }
89- System .out .println ("Metric: " + name + " (n=" + samples + "): " + value ); // TODO: REMOVE
9089 }
9190
9291 /**
Original file line number Diff line number Diff line change @@ -20,12 +20,8 @@ public static Game createGame() throws IOException {
2020
2121 public static Game createGame (String mapName ) throws IOException {
2222 final ByteBuffer buffer = binToBuffer (RESOURCES + mapName + "_frame0_buffer.bin" );
23- return createGame (new Client (buffer ));
24- }
25-
26- public static Game createGame (Client client ) {
2723 final Game game = new Game ();
28- game .clientData ().setBuffer (client . mapFile () );
24+ game .clientData ().setBuffer (buffer );
2925 game .init ();
3026 return game ;
3127 }
Original file line number Diff line number Diff line change @@ -89,13 +89,16 @@ public void shouldNotFindNonOverlappingUnits(
8989
9090 @ Test
9191 public void ifReplaySelfAndEnemyShouldBeNull () throws IOException {
92- ByteBuffer buffer = GameBuilder .binToBuffer ("src/test/resources/" + "(2)Benzene.scx" + "_frame0_buffer.bin" );
92+ ByteBuffer buffer = GameBuilder .binToBuffer (GameBuilder . DEFAULT_BUFFER_PATH );
9393
94- Client client = new Client (buffer );
9594 // modify the buffer to fake a replay
96- client .clientData ().gameData ().setIsReplay (true );
95+ ClientData clientData = new ClientData ();
96+ clientData .setBuffer (buffer );
97+ clientData .gameData ().setIsReplay (true );
9798
98- Game game = GameBuilder .createGame (client );
99+ Game game = new Game ();
100+ game .clientData ().setBuffer (buffer );
101+ game .init ();
99102
100103 assertThat (game .isReplay ());
101104 assertNull (game .self ());
You can’t perform that action at this time.
0 commit comments