Exemple #1
0
        public static List <T> Choose <T>(this IRandom rand, int count, IList <T> items)
        {
            var selection = new List <T>(count);

            for (int i = 0; i < count; ++i)
            {
                selection[i] = rand.Choose(items);
            }
            return(selection);
        }
Exemple #2
0
        public IReadOnlyList <int> SelectNodeCount()
        {
            var selection = _uniqueCounts[_random.Choose(_uniqueCounts.Count)];

            /*
             * var selection = _uniqueCounts
             *  .OrderBy(x => x.Sum(y => (long)y))
             *  .First();
             */

            return(selection.Select(b => (int)b).ToList());
        }
        public Variable ChooseVariable(IScope scope, VariableOptions options = VariableOptions.None)
        {
            _candidates.Clear();
            if (options.Has(VariableOptions.ForWriting))
            {
                PrepareForWriting(scope, options);
            }
            else
            {
                PrepareForReading(scope, options);
            }
            var count = _candidates.Count;

            if (count > 0)
            {
                return(_rand.Choose(_candidates));
            }
            return(null);
        }