BWAPI::connect

connect function

Attaches to a Starcraft process with BWAPI plugin loaded.

bool connect();
  

Parameters

None.

Return Value

Immediately returns false if no Starcraft process with loaded BWAPI plugin is running. Returns true after connected successfully.

Remarks

The same agent process cannot attach to two different Starcraft processes at a time.

Exceptions are NOT thrown when no running Starcraft process is found on the current machine. Because this situation is an expected one, it is signalled through the return value. Exceptions could however be thrown during the actual connection process to Starcraft.

Example Code

if(!connect())
{
  printf("Waiting for Starcraft to startup.\n");
  while(!connect())
  {
    // retry every second
    Sleep(1000);
  }
}
printf("Connected.\n");