Beispiel #1
0
        /// <summary>
        /// Generates a single wheel symbol, using the current probability settings.
        /// </summary>
        public Enums.WheelSymbol GetWheelSymbol()
        {
            int percent = _randomGenerator.Next(100);

            if (CacheContains(percent))
            {
                return(CacheLookup(percent));
            }

            int accumulatedProbability = 0;

            foreach (Enums.WheelSymbol symbol in _enumSymbols)
            {
                accumulatedProbability += _logicProbabilitySetup.GetProbability(symbol);
                if (accumulatedProbability > percent)
                {
                    CacheInsert(percent, symbol);
                    return(symbol);
                }
            }

            // Code will only reach this point if there is
            // an error in the probability definitions.
            throw new ArgumentException(nameof(GetWheelSymbol));
        }
Beispiel #2
0
        /// <summary>
        /// Calculate the probability for an outcome containing
        /// the specified number of the specified symbol.
        /// </summary>
        public double ProbabilityForSymbolCount(WheelSymbolCount wsCount)
        {
            double probability        = 1.0;
            int    probabilityPercent = _logicProbabilitySetup.GetProbability(wsCount.Symbol);

            // Probability for symbol to appear "count" times
            for (int i = 0; i < wsCount.Count; i++)
            {
                probability = probability * (probabilityPercent * 1.0) / 100.0;
            }

            // Probability for symbol NOT to appear in rest of symbols
            for (int i = 0; i < Configuration.Constants.NoOfWheels - wsCount.Count; i++)
            {
                probability = probability * ((100 - probabilityPercent) * 1.0) / 100.0;
            }

            // Multiply by number of ways this outcome can appear
            probability = probability * Combinations(Configuration.Constants.NoOfWheels, wsCount.Count);

            return(probability);
        }