Esempio n. 1
0
 public void InitialiseRandomComponent(RandomComponentPlayMode playMode)
 {
     if (playMode == RandomComponentPlayMode.Random)
     {
         InitialiseWeights();
         UpdateWeights();
         _shareRandomNoRepeatHistory = false;
         return;
     }
     _randomNoRepeatIndexes = new int[_components.Count];
     for (int i = 0; i < _randomNoRepeatIndexes.Length; i++)
     {
         _randomNoRepeatIndexes[i] = i;
     }
     MyArray <int> .Shuffle(_randomNoRepeatIndexes, _randomComponents);
 }
Esempio n. 2
0
        private int GetNextRandomNoRepeatIndex()
        {
            int result = 0;

            if (_randomNoRepeatIndexes.Length > 1)
            {
                if (_randomNoRepeatIndex == -1 || _randomNoRepeatIndex >= _components.Count)
                {
                    int num = _randomNoRepeatIndexes[_randomNoRepeatIndexes.Length - 1];
                    MyArray <int> .Shuffle(_randomNoRepeatIndexes, _randomComponents);

                    if (num == _randomNoRepeatIndexes[0])
                    {
                        int num2 = _randomNoRepeatIndexes[0];
                        _randomNoRepeatIndexes[0] = _randomNoRepeatIndexes[1];
                        _randomNoRepeatIndexes[1] = num2;
                    }
                    _randomNoRepeatIndex = 0;
                }
                result = _randomNoRepeatIndexes[_randomNoRepeatIndex++];
            }
            return(result);
        }