Exemplo n.º 1
0
ULong PathFinder::GetNearestNode(const EERIE_3D & pos) const
{
    ULong best(0);
    Float dist, b_dist(FLT_MAX);

    for (ULong i(0); i < map_s; i++)
    {
        dist = Distance(map_d[i].pos, pos);

        if (dist < b_dist && map_d[i].nblinked) best = i, b_dist = dist;
    }

    return best;
}
Exemplo n.º 2
0
double SampleBernoulli (double prob, int seed)
{
    // Create a Mersenne twister random number generator
    // that is seeded once with #seconds since 1970
    static mt19937 rng(static_cast<unsigned> (seed));
 
    // select Gaussian probability distribution
    bernoulli_distribution<> b_dist(prob);
 
    // bind random number generator to distribution, forming a function
    variate_generator<mt19937&, bernoulli_distribution<double> >  b_sampler(rng, b_dist);
 
    // sample from the distribution
    return b_sampler();
}