mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
extra files
This commit is contained in:
parent
7e9879c0ea
commit
d52b00fbd8
7 changed files with 992 additions and 0 deletions
22
common/rng_sfmt.cpp
Normal file
22
common/rng_sfmt.cpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include "rng_sfmt.h"
|
||||
#include "sfmt/SFMT.h"
|
||||
#include <QDateTime>
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
|
||||
RNG_SFMT::RNG_SFMT(QObject *parent)
|
||||
: RNG_Abstract(parent)
|
||||
{
|
||||
std::cerr << "Using SFMT random number generator." << std::endl;
|
||||
|
||||
int seed = QDateTime::currentDateTime().toTime_t();
|
||||
init_gen_rand(seed);
|
||||
for (int i = 0; i < 100000; ++i)
|
||||
gen_rand64();
|
||||
}
|
||||
|
||||
unsigned int RNG_SFMT::getNumber(unsigned int min, unsigned int max)
|
||||
{
|
||||
uint64_t r = gen_rand64();
|
||||
return min + (unsigned int) (((double) (max + 1 - min)) * r / (18446744073709551616.0 + 1.0));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue