Skip to content

Commit 4cf39fc

Browse files
committed
Removed commented-out printlns. Stubbed diagnostics configuration variable.
1 parent 156c382 commit 4cf39fc

File tree

4 files changed

+10
-22
lines changed

4 files changed

+10
-22
lines changed

src/main/java/bwapi/BWClient.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,9 @@ public void startGame(BWClientConfiguration configuration) {
5252
client.reconnect();
5353

5454
do {
55-
//System.out.println("Client: Beginning game loop");
5655
ClientData.GameData liveGameData = client.clientData().gameData();
5756
while (!liveGameData.isInGame()) {
58-
if (client.isConnected()) {
59-
//System.out.println("Client: Not in game; Connected.");
60-
} else {
61-
//System.out.println("Client: Not in game; Not connected.");
57+
if (!client.isConnected()) {
6258
return;
6359
}
6460
client.update();
@@ -67,17 +63,14 @@ public void startGame(BWClientConfiguration configuration) {
6763
}
6864
}
6965
while (liveGameData.isInGame()) {
70-
//System.out.println("Client: In game on frame " + liveGameData.getFrameCount());
7166
botWrapper.onFrame();
72-
//System.out.println("Client: Sending commands for frame " + liveGameData.getFrameCount());
7367
getGame().sideEffects.flushTo(liveGameData);
7468
client.update();
7569
if (!client.isConnected()) {
76-
//System.out.println("Reconnecting...");
7770
client.reconnect();
7871
}
7972
}
8073
botWrapper.endGame();
81-
} while (configuration.autoContinue); // lgtm [java/constant-loop-condition]
74+
} while (configuration.autoContinue);
8275
}
8376
}

src/main/java/bwapi/BWClientConfiguration.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ public class BWClientConfiguration {
4949
*/
5050
public boolean asyncWaitOnFrameZero = true;
5151

52+
/**
53+
* Enables collection of diagnostics.
54+
* When enabled, JBWAPI collects and publishes performance metrics.
55+
*/
56+
public boolean diagnosePerformance = false;
57+
5258
/**
5359
* Checks that the configuration is in a valid state. Throws an IllegalArgumentException if it isn't.
5460
*/

src/main/java/bwapi/BotWrapper.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ void onFrame() {
7272
long startNanos = System.nanoTime();
7373
long endNanos = startNanos + configuration.asyncFrameDurationNanos;
7474
if (botThread == null) {
75-
//System.out.println("Creating bot thread");
7675
botThread = createBotThread();
7776
botThread.setName("JBWAPI Bot");
7877
botThread.start();
@@ -116,12 +115,9 @@ private Thread createBotThread() {
116115
try { while (frameBuffer.empty()) frameBuffer.conditionSize.awaitUninterruptibly(); } finally { frameBuffer.lockSize.unlock(); }
117116

118117
game.clientData().setBuffer(frameBuffer.peek());
119-
//System.out.println("Bot thread: Handling events.");
120118
handleEvents();
121-
//System.out.println("Bot thread: Handled events.");
122119
frameBuffer.dequeue();
123120
}
124-
//System.out.println("Bot thread: Ending because game is over.");
125121
});
126122
}
127123

src/main/java/bwapi/FrameBuffer.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class FrameBuffer {
4444

4545
// Synchronization locks
4646
private final Lock lockWrite = new ReentrantLock();
47-
private final Lock lockRead = lockWrite;
4847
final Lock lockSize = new ReentrantLock();
4948
final Condition conditionSize = lockSize.newCondition();
5049

@@ -120,36 +119,30 @@ void enqueueFrame() {
120119
lockSize.lock();
121120
try {
122121
++stepGame;
123-
//System.out.println("FrameBuffer: Enqueued buffer " + indexGame() + " on game step #" + stepGame);
124-
if (framesBuffered() > 0) {
125-
//System.out.println("FrameBuffer: There are now " + framesBuffered() + " frames buffered.");
126-
}
127122
conditionSize.signalAll();
128123
} finally { lockSize.unlock(); }
129124
} finally { lockWrite.unlock(); }
130125
}
131126

132127
/**
133-
* Peeks the frontmost value in the buffer.
128+
* Peeks the front-most value in the buffer.
134129
*/
135130
ByteBuffer peek() {
136131
lockSize.lock();
137132
try {
138133
while(empty()) conditionSize.awaitUninterruptibly();
139-
//System.out.println("FrameBuffer: Sharing buffer " + indexBot() + " on bot step #" + stepBot);
140134
return dataBuffer.get(indexBot());
141135
} finally { lockSize.unlock(); }
142136

143137
}
144138

145139
/**
146-
* Removes the frontmost frame in the buffer.
140+
* Removes the front-most frame in the buffer.
147141
*/
148142
void dequeue() {
149143
lockSize.lock();
150144
try {
151145
while(empty()) conditionSize.awaitUninterruptibly();
152-
//System.out.println("FrameBuffer: Dequeuing buffer " + indexBot() + " on bot step #" + stepBot);
153146
++stepBot;
154147
conditionSize.signalAll();
155148
} finally { lockSize.unlock(); }

0 commit comments

Comments
 (0)