Пример #1
0
 public SquareRandom(SquareType type, Dictionary <Color, int> colorWeights, int seed = 0)
 {
     this.Type        = type;
     this.Random      = new Random(seed);
     this.ColorRandom = new WeightRandom <Color>(colorWeights);
     this.ColorRandom.InitRandom(Random.Next());
 }
Пример #2
0
        public void Init(Dictionary <SquareType, int> squareWeights, Dictionary <SquareType, Dictionary <Color, int> > weights, int seed)
        {
            this.random = new Random(seed);
            var squareDict = new Dictionary <SquareRandom, int>();

            foreach (var kvp in squareWeights)
            {
                var sr = SquareRandomFactory.Create(kvp.Key, weights[kvp.Key], this.random.Next());
                squareDict.Add(sr, kvp.Value);
            }

            this.weightRandom = new WeightRandom <SquareRandom>(squareDict);
            this.weightRandom.InitRandom(this.random.Next());
        }
Пример #3
0
        public void Run()
        {
            this.InitData();

            var weightRandom = new WeightRandom <int>(this.weights);

            weightRandom.InitRandom(0);

            for (var i = 0; i < RunTimes; ++i)
            {
                var v = weightRandom.Next();
                ++this.result[v];
            }

            this.Print();
        }