Blizzard / s2client-api

StarCraft II Client - C++ library supported on Windows, Linux and Mac designed for building scripted bots and research using the SC2API.
MIT License
1.66k stars 281 forks source link

Get error when opened many coordinators simultaneously #330

Open monarchBacilluscoli opened 4 years ago

monarchBacilluscoli commented 4 years ago

I want to launch many (about 100-200) sc2 games at the same time. during their launch, there is always an error shown 2-3 times like this :

Deferred error: 536936448 (0x20010000)
Deferred error details: Bad profiling data. TimeMS: 22722180.000000 Conversion: 1.000000e-03

I have no idea about it and I can not find anything through directly searching the error.

The code is like this:

void CSetAndStart(Coordinator &cor, int port, int argc, char *argv[], Agent *bot1, Agent *bot2)
{
    cor.LoadSettings(argc, argv);
    cor.SetParticipants({CreateParticipant(Terran, bot1), CreateParticipant(Terran, bot2)});
    cor.SetPortStart(port);
    cor.SetMapPath("PCANP_EnemyZealotModVSMarines.SC2Map"); // map designed by myself
    cor.SetStepSize(1);
    cor.LaunchStarcraft();
    cor.StartGame();
}

int main(){
    std::vector<Coordinator> cors(100);
    ANBot bots1[100];
    ANBot bots2[100];
    int count = 100; // num of sc2 processes
    std::vector<std::future<void>> cors_futures(100);
    for (int i = 0; i < count; ++i) // launch, the error occured during the launch process
    {
        cors_futures[i] = std::async(std::launch::async, CSetAndStart, std::ref(cors[i]), 4000 + 10 * i, argc, argv, &(bots1[i]), &(bots2[i]));
    }
    for (int i = 0; i < count; ++i)
    {
        cors_futures[i].wait();
    }
    return 0;
}