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) {
93
93
}
94
94
}
95
95
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
+ } );
102
102
performanceMetrics .bwapiResponse .time (client ::update );
103
103
if (!client .isConnected ()) {
104
+ System .out .println ("Reconnecting..." );
104
105
client .reconnect ();
105
106
}
106
107
}
Original file line number Diff line number Diff line change @@ -86,7 +86,6 @@ void record(double value) {
86
86
avgValueExceeding = (avgValueExceeding * samplesExceeding + value ) / (samplesExceeding + 1d );
87
87
++samplesExceeding ;
88
88
}
89
- System .out .println ("Metric: " + name + " (n=" + samples + "): " + value ); // TODO: REMOVE
90
89
}
91
90
92
91
/**
Original file line number Diff line number Diff line change @@ -20,12 +20,8 @@ public static Game createGame() throws IOException {
20
20
21
21
public static Game createGame (String mapName ) throws IOException {
22
22
final ByteBuffer buffer = binToBuffer (RESOURCES + mapName + "_frame0_buffer.bin" );
23
- return createGame (new Client (buffer ));
24
- }
25
-
26
- public static Game createGame (Client client ) {
27
23
final Game game = new Game ();
28
- game .clientData ().setBuffer (client . mapFile () );
24
+ game .clientData ().setBuffer (buffer );
29
25
game .init ();
30
26
return game ;
31
27
}
Original file line number Diff line number Diff line change @@ -89,13 +89,16 @@ public void shouldNotFindNonOverlappingUnits(
89
89
90
90
@ Test
91
91
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 );
93
93
94
- Client client = new Client (buffer );
95
94
// 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 );
97
98
98
- Game game = GameBuilder .createGame (client );
99
+ Game game = new Game ();
100
+ game .clientData ().setBuffer (buffer );
101
+ game .init ();
99
102
100
103
assertThat (game .isReplay ());
101
104
assertNull (game .self ());
You can’t perform that action at this time.
0 commit comments