本文整理汇总了C++中PRNG::uniform方法的典型用法代码示例。如果您正苦于以下问题:C++ PRNG::uniform方法的具体用法?C++ PRNG::uniform怎么用?C++ PRNG::uniform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PRNG
的用法示例。
在下文中一共展示了PRNG::uniform方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: randomizeRow
// For now, this just directly puts them into 'frags'
void Board::randomizeRow(unsigned int i) {
unsigned int maxInt = 8; // the higher, the more blank spaces
//maxInt = 400; // good to keep whole pieces separate
// maxInt = 8; // good for individual squares
PRNG* rng = Tetris::TApp::theApp->rng;
int j = rng->uniform() % clms;
auto k = nFromIJ(i, j);
unsigned int pi = rng->uniform() % maxInt;
TCode p = ((1 <= pi) && (pi <= 7)) ? ((TCode)pi) : N;
if (N != p) {
Shape s = Shape(p);
s.setRandomShape();
bool ok = testShape(s, i, j);
if (ok) {
placeShape(s,i,j);
s.showCoords();
cout << endl << flush;
}
}
return;
}
示例2: render
void HistogramImage::render(std::vector<unsigned char> &rgb, double scale, double exponent)
{
// Tone mapping from 64-bit-per-channel to 8-bit-per-channel, with dithering.
PRNG rng;
rng.seed(0);
unsigned i = 0;
unsigned e = mWidth * mHeight * kChannels;
rgb.resize(e);
for (; i != e; ++i) {
double u = std::max(0.0, mCounts[i] * scale);
double dither = rng.uniform();
double v = 255.0 * pow(u, exponent) + dither;
rgb[i] = std::max(0.0, std::min(255.9, v));
}
}