Exemplo n.º 1
0
        /// <summary>
        /// Fisher–Yates shuffle
        /// https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
        /// </summary>
        private void ShufflePool()
        {
            FileLogger.Singleton.Debug("PoolBeforeShuffle: {pool}", _pool);
            int n = _pool.Count;

            while (n > 1)
            {
                --n;
                int k     = _rng.GetOneNumber(0, n + 1);
                var value = _pool[k];
                _pool[k] = _pool[n];
                _pool[n] = value;
            }
            FileLogger.Singleton.Debug("PoolAfterShuffle: {pool}", _pool);
        }