1
0

Implement RANDOMIZE

This commit is contained in:
otya128
2017-07-03 18:40:27 +09:00
parent ffb4b6e685
commit 3edc2a4d10
4 changed files with 50 additions and 7 deletions

26
SMILEBASIC/random.d Normal file
View File

@@ -0,0 +1,26 @@
module otya.smilebasic.random;
import std.random;
class Random
{
LinearCongruentialEngine!(uint, 16_807, 0, 2_147_483_647)[8] engine;
public this()
{
foreach (e; engine)
{
e.seed(unpredictableSeed);
}
}
public T random(T)(int seedid, T min, T max)
{
return uniform(min, max, engine[seedid]);
}
public void randomize(int seedid)
{
engine[seedid].seed(unpredictableSeed);
}
public void randomize(int seedid, int seed)
{
engine[seedid].seed(seed);
}
}