Random Number Generation

Agent variables can be initialised with randomly generated data:

// Use the standard C++ library mt19937 random number generator
std::mt19937 rngEngine(cuda_model.getSimulationConfig().random_seed);

// Create a distribution to sample
int min_position = -2.0f;
int max_position = 2.0f;
std::uniform_real_distribution<float> position_distribution(min_position, max_position);

// For each agent
for (unsigned int i = 0; i < populationSize; i++) {
    flamegpu::AgentVector::Agent instance = population[i];

    // Randomly initialise the x, y and z variables with values between min_pos and max_pos
    instance.setVariable<float>("x", position_distribution(rngEngine));
    instance.setVariable<float>("y", position_distribution(rngEngine));
    instance.setVariable<float>("z", position_distribution(rngEngine));