9 using namespace boost::program_options;
11 namespace AP_LSystem {
18 std::vector<double> probabilities;
26 const variable_value * seed = Configuration::get()->getProperty(
"RandomSeed" );
29 srand( seed->as<
unsigned int>() );
33 srand( time( NULL ) );
49 void addProbability(
double p )
51 probabilities.push_back( sum + p );
59 unsigned int getRandomIndex()
61 double r = (
static_cast<double>(rand() % 100)) * sum / 100.0f;
63 for(std::vector<double>::iterator it = probabilities.begin(); it != probabilities.end()-1; it++)
67 return it - probabilities.begin();
71 return probabilities.size( ) - 1;
75 #endif // RANDOMINDEX_H