forked from giacomelli/GeneticSharp
/
BasicRandomization.cs
39 lines (35 loc) · 1.01 KB
/
BasicRandomization.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Linq;
using HelperSharp;
namespace GeneticSharp.Domain.Randomizations
{
/// <summary>
/// An IRandomization implementation using System.Random has pseudo-number generator.
/// </summary>
public class BasicRandomization : RandomizationBase
{
#region Fields
private Random m_random = new Random (DateTime.Now.Millisecond);
#endregion
#region Methods
/// <summary>
/// Gets an integer value between minimum value (inclusive) and maximum value (exclusive).
/// </summary>
/// <returns>The integer.</returns>
/// <param name="min">Minimum value (inclusive).</param>
/// <param name="max">Maximum value (exclusive).</param>
public override int GetInt(int min, int max)
{
return m_random.Next(min, max);
}
/// <summary>
/// Gets a double value between 0.0 and 1.0.
/// </summary>
/// <returns>The double value.</returns>
public override double GetDouble()
{
return m_random.NextDouble ();
}
#endregion
}
}