@@ -22,7 +22,7 @@ class BotWrapperAsync extends BotWrapper {
2222 // Use reduced priority to encourage Windows to give priority to StarCraft.exe/BWAPI.
2323 // If BWAPI doesn't get priority, it may not detect completion of a frame on our end in timely fashion.
2424 Thread .currentThread ().setName ("JBWAPI Client" );
25- Thread .currentThread ().setPriority (4 );
25+ Thread .currentThread ().setPriority (Thread . NORM_PRIORITY - 1 );
2626 }
2727
2828 /**
@@ -35,12 +35,13 @@ void startNewGame(WrappedBuffer liveData, PerformanceMetrics performanceMetrics)
3535 liveClientData .setBuffer (liveData );
3636 this .liveData = liveData ;
3737
38- configuration .log ("Main: Starting bot thread" );
39- botThread = createBotThread ();
40- botThread .setName ("JBWAPI Bot" );
41- // Reduced priority helps ensure that StarCraft.exe/BWAPI pick up on our frame completion in timely fashion
42- botThread .setPriority (3 );
43- botThread .start ();
38+ // configuration.log("Main: Starting bot thread");
39+ // botThread = createBotThread();
40+ // botThread.setName("JBWAPI Bot");
41+ // // Reduced priority helps ensure that StarCraft.exe/BWAPI pick up on our frame completion in timely fashion
42+ // botThread.setPriority(Thread.NORM_PRIORITY - 2);
43+ // botThread.start();
44+ botThread = null ;
4445 }
4546
4647
@@ -81,6 +82,15 @@ void asyncOnFrame() {
8182 long startNanos = System .nanoTime ();
8283 long endNanos = startNanos + (long ) configuration .getMaxFrameDurationMs () * 1000000 ;
8384
85+ if (botThread == null ) {
86+ configuration .log ("Main: Starting bot thread" );
87+ botThread = createBotThread ();
88+ botThread .setName ("JBWAPI Bot" );
89+ // Reduced priority helps ensure that StarCraft.exe/BWAPI pick up on our frame completion in timely fashion
90+ botThread .setPriority (3 );
91+ botThread .start ();
92+ }
93+
8494 // Unsafe mode:
8595 // If the frame buffer is empty (meaning the bot must be idle)
8696 // allow the bot to read directly from shared memory while we copy it over
0 commit comments