samedi 1 février 2020

std::uniform_int_distribution, works with Visual Studio 2019 compiler but not Clion and MinGw

My question references the code below. In Visual Studio 2019 the code runs as expected and I get the random integer values. However, in Clion with the MinGw 5 compiler, the code returns the same value every time. It would seem it is not being seeded properly.

I'd appreciate it if someone could take a moment to shed some light on the issue for me:

int roll_die()
{
    std::random_device random_device;
    std::mt19937 random_engine(random_device());
    std::uniform_int_distribution<int> distribution(MIN_DIE_VALUE, MAX_DIE_VALUE);
    auto const rollValue = distribution(random_engine);
    return rollValue;
}

Thanks, Marc




Aucun commentaire:

Enregistrer un commentaire