28
29
/// also provides some utility functions not found on standard
29
30
/// Random classes.
31
public static class TerrellaRandom
32
public class TerrellaRandom
33
private static Random random;
35
public static double NextRawDouble() {
36
return random.NextDouble();
34
public Random RandomCore;
37
public TerrellaRandom()
39
this.RandomCore = new Random();
42
public double NextRawDouble() {
43
return RandomCore.NextDouble();
39
public static E Choice<E>(ICollection<E> source) {
46
public E Choice<E>(IEnumerable<E> source)
48
return Choice(new List<E>(source));
51
public E Choice<E>(IList<E> source) {
40
52
int count = NextInt(0, source.Count - 1);
41
var en = source.GetEnumerator();
49
public static double NextDouble(double min, double max) {
50
return ((max - min) * random.NextDouble()) + min;
53
public static int NextInt(int min, int max) {
54
return random.Next(min, max);
57
public static void SetRandom(Random r) {
56
public double NextDouble(double min, double max) {
57
return ((max - min) * RandomCore.NextDouble()) + min;
60
public int NextInt(int min, int max) {
61
return RandomCore.Next(min, max);
64
public void SetRandom(Random r) {