コード例 #1
0
 /// <summary>
 /// Inject in dependencies, in the event we want to test out different wheel spinners or payout calculators
 /// </summary>
 /// <param name="wheel">The wheel to use during the simulation.  The only thing we need is to get a series of results from it</param>
 /// <param name="payoutCalculator">Calculate what the payout is for the roll.  I assume we can only do a straight bet, for simplicity</param>
 public RouletteRunner(
     IRouletteWheel wheel,
     IPayoutCalculator payoutCalculator)
 {
     _wheel = wheel;
     _payoutCalculator = payoutCalculator;
     _players = new ConcurrentBag<IRoulettePlayer>();
     _tableBets = new Dictionary<IRoulettePlayer, IReadOnlyCollection<IRouletteBet>>();
 }
コード例 #2
0
        /// <summary>
        /// If you need to specify a name and starting amount, here's a constructor for YOU
        /// </summary>
        /// <param name="name"></param>
        /// <param name="startingAmount"></param>
        /// <param name="payoutCalculator"></param>
        public CheatingRoulettePlayer(string name, decimal startingAmount, IPayoutCalculator payoutCalculator)
        {
            _payoutCalculator = payoutCalculator;
            MoneyTotal = startingAmount;
            Name = name;

            Thread.Sleep(1); // wait to make sure seed is unique in his program
            _random = new Random((int)DateTime.Now.Ticks);
            _enumLength = Enum.GetNames(typeof(RouletteResult)).Length;

            // build up probability array
            _rouletteResultProbabilities = new Dictionary<RouletteResult, int>();
            foreach (var idx in Enum.GetValues(typeof(RouletteResult)))
            {
                var rIdx = (RouletteResult)idx;
                _rouletteResultProbabilities[rIdx] = _randomIndex;
            }
        }