Ejemplo n.º 1
0
 public static Vector2 NextVector2(this RNG rng)
 {
     return(new Vector2(rng.NextFloat1(), rng.NextFloat1()));
 }
Ejemplo n.º 2
0
        /// <summary>Randomly select one item.</summary>
        /// <param name="rng">The RNG.</param>
        /// <returns>Index of the selected item.</returns>
        public int Select(RNG rng)
        {
            int sample = GetSample(rng);

            return(Select(sample));
        }
Ejemplo n.º 3
0
        /// <summary>Randomly select one item.</summary>
        /// <param name="rng">The RNG.</param>
        /// <returns>Selected item.</returns>
        public T SelectItem(RNG rng)
        {
            int index = Select(rng);

            return(Items[index]);
        }
Ejemplo n.º 4
0
 protected int GetSample(RNG rng)
 {
     // must be 1-based sample
     return(rng.NextIntRange(TotalWeights) + 1);
 }