예제 #1
0
        public static T RandomOrDefault <T>(this IEnumerable <T> source, ConstantRandom crng)
        {
            T   current = default(T);
            int count   = 0;

            crng.Reseed();
            foreach (T element in source)
            {
                if (crng.Next(++count) == 0)
                {
                    current = element;
                }
            }

            return(current);
        }
예제 #2
0
 protected KIController(float interval, GDGameScreen owner, Cannon cannon, Fraction fraction, float minRotDelta)
     : base(interval, owner, cannon, fraction, true)
 {
     MinimumRotationalDelta = minRotDelta;
     crng = new ConstantRandom(cannon);
 }