You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extracted portions of Client to GameDataUtils. Removed the bot loop entirely for reinsertion via BotWrapper, so this revision is in a non-working state.
Copy file name to clipboardExpand all lines: src/main/java/bwapi/BWClientConfiguration.java
+24-8Lines changed: 24 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,11 @@
5
5
*/
6
6
publicclassBWClientConfiguration {
7
7
8
+
/**
9
+
* Set to `true` for more explicit error messages (which might spam the terminal).
10
+
*/
11
+
publicbooleandebugConnection;
12
+
8
13
/**
9
14
* When true, restarts the client loop when a game ends, allowing the client to play multiple games without restarting.
10
15
*/
@@ -24,18 +29,19 @@ public class BWClientConfiguration {
24
29
publicbooleanasync = false;
25
30
26
31
/**
27
-
* If JBWAPI detects that this much time (in nanoseconds) has passed since a bot's event handlers began, returns control back to BWAPI.
28
-
* Real-time human play typically uses the "fastest" game speed, which has 42.86ms (42,860ns) between frames.
32
+
* How frequently (in nanoseconds) to poll for the bot's event handlers completing. Acts as a floor on the bot's frame duration.
29
33
*/
30
-
publicintasyncFrameDurationNanosMax = 40000;
34
+
publicintasyncFrameDurationNanosMin = 500;
31
35
32
36
/**
33
-
* How frequently (in nanoseconds) to poll for the bot's event handlers completing. Acts as a floor on the bot's frame duration.
37
+
* If JBWAPI detects that this much time (in nanoseconds) has passed since a bot's event handlers began, returns control back to BWAPI.
38
+
* Real-time human play typically uses the "fastest" game speed, which has 42.86ms (42,860ns) between frames.
34
39
*/
35
-
publicintasyncFrameDurationNanosMin = 500;
40
+
publicintasyncFrameDurationNanosMax = 40000;
36
41
37
42
/**
38
-
* The maximum number of frames to buffer while waiting on a bot
43
+
* The maximum number of frames to buffer while waiting on a bot.
44
+
* Each frame buffered adds about 33 megabytes to JBWAPI's memory footprint.
39
45
*/
40
46
publicintasyncFrameBufferSize = 10;
41
47
@@ -49,7 +55,17 @@ public class BWClientConfiguration {
49
55
publicbooleanasyncWaitOnFrameZero = true;
50
56
51
57
/**
52
-
* Set to `true` for more explicit error messages (which might spam the terminal).
58
+
* Checks that the configuration is in a valid state. Throws an IllegalArgumentException if it isn't.
53
59
*/
54
-
publicbooleandebugConnection;
60
+
publicvoidvalidate() {
61
+
if (async && asyncFrameDurationNanosMin <= 0) {
62
+
thrownewIllegalArgumentException("asyncFrameDurationNanosMin needs to be a positive number (it's how long JBWAPI waits to poll for a completed frame.");
63
+
}
64
+
if (async && asyncFrameDurationNanosMax < 0) {
65
+
thrownewIllegalArgumentException("asyncFrameDurationNanosMax needs to be a non-negative number (it's how long JBWAPI waits for a bot response before returning control to BWAPI).");
66
+
}
67
+
if (async && asyncFrameBufferSize < 1) {
68
+
thrownewIllegalArgumentException("asyncFrameBufferSize needs to be a positive number (There needs to be at least one frame buffer).");
0 commit comments