Implemented Mersenne Twister RNG.
This commit is contained in:
+10
-1
@@ -39,8 +39,17 @@ All rights reserved.
|
||||
#include "olcPixelGameEngine.h"
|
||||
#include "olcPGEX_TTF.h"
|
||||
|
||||
std::random_device rd;
|
||||
std::mt19937 rng(rd());
|
||||
|
||||
float util::random(float range){
|
||||
return float(rand())/RAND_MAX*range;
|
||||
static std::uniform_real_distribution<float>distrib(0,1);
|
||||
return distrib(rng)*range;
|
||||
}
|
||||
|
||||
int util::random(){
|
||||
static std::uniform_int_distribution<int>distrib(0,32767);
|
||||
return distrib(rng);
|
||||
}
|
||||
|
||||
vf2d util::pointTo(vf2d posFrom,vf2d posTo){
|
||||
|
||||
Reference in New Issue
Block a user