/// <summary>
        /// Fill grid with '-' and numbers for bombs
        /// </summary>
        /// <param name="rng">Random number generator for random generate positions of mines</param>
        public void FillPlayfield(IRandomNumberGenerator rng)
        {
            this.grid = new string[this.size, this.size];

            int minesCount = this.GetNumberOfMines();

            var mines = this.GenerateMines(rng, minesCount);

            foreach (var mine in mines)
            {
                int mineNumber = rng.Next(1, this.size);

                if (mineNumber > MaxMineNumber)
                {
                    mineNumber = MaxMineNumber;
                }

                this.SetCell(mine, mineNumber.ToString());
            }

            for (int row = 0; row < this.size; row++)
            {
                for (int col = 0; col < this.size; col++)
                {
                    if (this.GetCell(row, col) == null)
                    {
                        this.SetCell(row, col, "-");
                    }
                }
            }
        }
 public void SetUp()
 {
     _logger = new ConsoleOutLogger("IdFromNameGeneratorTests", LogLevel.All, true, false, false, "yyyy-MM-dd hh:mm:ss");
     _stubRandomNumberGenerator = MockRepository.GenerateStub<IRandomNumberGenerator>();
     _randomNumberExpected = 1234567890;
     _stubRandomNumberGenerator.Stub(generator => generator.GetRandomNumber()).Return(_randomNumberExpected);
 }
        /// <summary>
        /// Generates random string of specified length
        /// </summary>
        /// <param name="random">The random number generator to use.</param>
        /// <param name="minLength">Minimum length of the generated string.</param>
        /// <param name="maxLength">Maximum length of the generated string.</param>
        /// <returns>Generated string.</returns>
        public string GenerateString(IRandomNumberGenerator random, int minLength, int maxLength)
        {
            ExceptionUtilities.CheckArgumentNotNull(random, "random");
            ExceptionUtilities.CheckValidRange(minLength, "minLength", maxLength, "maxLength");

            return this.GenerateStringCore(random, minLength, maxLength);
        }
        /// <summary>
        /// Method that generates the playfield
        /// </summary>
        /// <param name="rand">Parameter of type IRandomNumberGenerator</param>
        /// <returns>Returns the playfield as a two dimensional array</returns>
        public ICell[,] GeneratePlayField(IRandomNumberGenerator rand)
        {
            for (int row = 0; row < this.rows; row++)
            {
                for (int col = 0; col < this.cols; col++)
                {
                    int cellRandomValue = rand.GenerateNext(0, 1);

                    char charValue;
                    if (cellRandomValue == 0)
                    {
                        charValue = Constants.StandardGameCellEmptyValue;
                    }
                    else
                    {
                        charValue = Constants.StandardGameCellWallValue;
                    }

                    this.playField[row, col] = new Cell(new Position(row, col), charValue);
                }
            }

            this.playField[this.playerPosition.Row, this.playerPosition.Column].ValueChar = Constants.StandardGamePlayerChar;

            bool exitPathExists = this.ExitPathExists();
            if (!exitPathExists)
            {
                return this.GeneratePlayField(rand);
            }
            else
            {
                return this.playField;
            }
        }
		public ThrowCommand(Creature thrower, Field targetField, Map map, IRandomNumberGenerator randomNumberGenerator)
		{
			this.thrower = thrower;
			this.targetField = targetField;
			this.map = map;
			this.randomNumberGenerator = randomNumberGenerator;
		}
		public ShootCommand(Creature attacker, Creature target, Map map, IRandomNumberGenerator randomNumberGenerator)
		{
			this.randomNumberGenerator = randomNumberGenerator;
			this.deffender = target;
			this.attacker = attacker;
			this.map = map;
		}
 public gameChromosome(IRandomNumberGenerator chromosomeGenerator,
     IRandomNumberGenerator mutationMultiplierGenerator,
     IRandomNumberGenerator mutationAdditionGenerator, int length)
     : base(chromosomeGenerator, mutationMultiplierGenerator, mutationMultiplierGenerator, length)
 {
     this.cFitness = 0.000000001; //Fitness muy bajo pero mayor que 0 (como lo requiere la libreria AForge).
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RelationshipSelector"/> class.
 /// </summary>
 /// <param name="random">The random number generator.</param>
 public RelationshipSelector(IRandomNumberGenerator random)
 {
     this.random = random;
     this.usedVectors = new List<RelationshipCandidate[]>();
     this.ends = new List<RelationshipGroupEnd>();
     this.endsWhichFormTheKey = new List<RelationshipGroupEnd>();
 }
Exemple #9
0
        /// <summary>
        /// Generates extra operations to go into a request changeset
        /// </summary>
        /// <param name="random">For generating the payloads to go in the extra operations</param>
        /// <param name="requestManager">For building the operations</param>
        /// <param name="model">To add any new types to.</param>
        /// <param name="baseUri">Base uri for the extra operations.</param>
        /// <param name="version">Maximum version for </param>
        /// <returns>An array of extra request operations.</returns>
        public static IHttpRequest[] ExtraRequestChangesetOperations(
            IRandomNumberGenerator random,
            IODataRequestManager requestManager,
            EdmModel model,
            ODataUri baseUri,
            ODataVersion version = ODataVersion.V4)
        {
            ExceptionUtilities.CheckArgumentNotNull(random, "random");
            ExceptionUtilities.CheckArgumentNotNull(requestManager, "requestManager");
            ExceptionUtilities.CheckArgumentNotNull(baseUri, "baseUri");
            var headers = new Dictionary<string, string> { { "RequestHeader", "RequestHeaderValue" } };
            string mergeContentType = HttpUtilities.BuildContentType(MimeTypes.ApplicationXml, Encoding.UTF8.WebName, null);

            List<IHttpRequest> requests = new List<IHttpRequest>();
            ODataRequest request = null;
            for (int i = 0; i < 4; i++)
            {
                request = requestManager.BuildRequest(baseUri, HttpVerb.Post, headers);
                request.Body = requestManager.BuildBody(mergeContentType, baseUri, RandomPayloadBuilder.GetRandomPayload(random, model, version));
                requests.Add(request);
                request = requestManager.BuildRequest(baseUri, HttpVerb.Put, headers);
                request.Body = requestManager.BuildBody(mergeContentType, baseUri, RandomPayloadBuilder.GetRandomPayload(random, model, version));
                requests.Add(request);
                request = requestManager.BuildRequest(baseUri, HttpVerb.Patch, headers);
                request.Body = requestManager.BuildBody(mergeContentType, baseUri, RandomPayloadBuilder.GetRandomPayload(random, model, version));
                requests.Add(request);
                request = requestManager.BuildRequest(baseUri, HttpVerb.Delete, headers);
                requests.Add(request);
            }

            return requests.ToArray();
        }
        /// <summary>
        /// Generates an arbitrary top load payload based on the maximum version supplied.
        /// </summary>
        /// <param name="random">Random generator for generating arbitrary payloads</param>
        /// <param name="model">The model to add any new types to</param>
        /// <param name="version">Maximum version for generated payloads.</param>
        /// <returns>A top level payload.</returns>
        public static ODataPayloadElement GetRandomPayload(IRandomNumberGenerator random, EdmModel model, ODataVersion version = ODataVersion.V4)
        {
            ExceptionUtilities.CheckArgumentNotNull(random, "random");
            ExceptionUtilities.CheckArgumentNotNull(model, "model");

            Func<ODataPayloadElement>[] payloadCalls = new Func<ODataPayloadElement>[]
            {
                () => { return GetComplexInstanceCollection(random, model, version); }, 
                () => { return GetComplexProperty(random, model, version); }, 
                () => { return GetDeferredLink(); }, 
                () => { return GetLinkCollection(); }, 
                () => { return GetEntityInstance(random, model, version); }, 
                () => { return GetEntitySetInstance(random, model); }, 
                () => { return GetODataErrorPayload(random); }, 
                () => { return GetPrimitiveCollection(random); }, 
                () => { return GetPrimitiveProperty(random, model); }, 
                () => { return GetPrimitiveValue(random, model); },
            };

            payloadCalls.Concat(new Func<ODataPayloadElement>[]
            {
                () => { return GetComplexMultiValueProperty(random, model, version); }, 
                () => { return GetPrimitiveMultiValueProperty(random); },
            });

            var payloadCall = random.ChooseFrom(payloadCalls);
            return payloadCall();
        }
Exemple #11
0
 /// <summary>
 /// Initializes a new instance of the Battlefield class.
 /// </summary>
 /// <param name="size">The size (width and height) of the battlefield</param>
 private Battlefield(int size, IRandomNumberGenerator randomNumberGenerator)
 {
     this.Rand = randomNumberGenerator;
     this.FieldSize = size;
     this.InitField();
     this.InitMines();
 }
        /// <summary>
        /// Generates random string of specified length
        /// </summary>
        /// <param name="random">The random number generator to use.</param>
        /// <param name="minLength">Minimum length of the generated string.</param>
        /// <param name="maxLength">Maximum length of the generated string.</param>
        /// <returns>Generated string.</returns>
        public string GenerateString(IRandomNumberGenerator random, int minLength, int maxLength)
        {
            ExceptionUtilities.CheckArgumentNotNull(random, "random");
            ExceptionUtilities.CheckValidRange(minLength, "minLength", maxLength, "maxLength");

            int wordCount = random.NextFromRange(2, 10);
            int length = random.NextFromRange(minLength, maxLength);

            StringBuilder sb = new StringBuilder();
            while (sb.Length < length)
            {
                string word = this.wordGenerator.GenerateString(random, 2, Math.Max(3, length / wordCount));

                sb.Append(word);
                if (sb.Length < length)
                {
                    sb.Append(' ');
                    if (random.Next(100) < 30)
                    {
                        sb.Append(random.ChooseFrom(glueWords));
                        sb.Append(' ');
                    }
                }
            }

            if (maxLength > 0 && sb.Length > maxLength - 1)
            {
                sb.Length = maxLength - 1;
                sb.Append(".");

                sb[0] = char.ToUpperInvariant(sb[0]);
            }

            return sb.ToString();
        }
Exemple #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ZmachineV1"/> class.
 /// </summary>
 /// <param name="frontEnd">
 /// The zmachine front end.
 /// </param>
 /// <param name="story">
 /// The story.
 /// </param>
 /// <param name="random">
 /// The random number generator.
 /// </param>
 internal ZmachineV1(FrontEnd frontEnd, ImmutableArray<byte> story, IRandomNumberGenerator random)
 {
     this.frontEnd = frontEnd;
     this.memory = new Memory(story, this.FrontEnd);
     this.randomNumberGenerator = new RandomNumberGenerator(random);
     this.callStack = new CallStack(this.FrontEnd);
 }
 public Population(IElementProvider elementProvider, IRandomNumberGenerator randomNumberGenerator, IComparer<IChromosome> chromosomeComparison, int size = 20)
 {
     this.size = size;
     this.elementProvider = elementProvider;
     this.randomNumberGenerator = randomNumberGenerator;
     this.chromosomeComparison = chromosomeComparison;
     Fill();
 }
        public Chromosome(IElementProvider elementProvider, IRandomNumberGenerator randomNumberGenerator, Element[] startingElements = null)
        {
            this.randomNumberGenerator = randomNumberGenerator;
            this.elementProvider = elementProvider;

            PopulateElements(startingElements);
            PostInitialisation();
        }
        /// <summary>
        ///   Constructs a new Gaussian Weight initialization.
        /// </summary>
        /// 
        /// <param name="network">The activation network whose weights will be initialized.</param>
        /// <param name="stdDev">The standard deviation to be used. Common values lie in the 0.001-
        /// 0.1 range. Default is 0.1.</param>
        /// 
        public GaussianWeights(ActivationNetwork network, double stdDev = 0.1)
        {
            this.network = network;

            this.random = new NormalDistribution(0, stdDev);

            this.UpdateThresholds = false;
        }
 public ComplimentFetcher(IRandomNumberGenerator randomNumberGenerator, IComplimentService complimentService, IComplimentTextTransformer complimentTextTransformer,
     IComplimentTextDeserializer complimentTextDeserializer)
 {
     _randomNumberGenerator = randomNumberGenerator;
     _complimentService = complimentService;
     _complimentTextTransformer = complimentTextTransformer;
     _complimentTextDeserializer = complimentTextDeserializer;
 }
Exemple #18
0
        public Deck(CardData data, IRandomNumberGenerator rg)
        {
            availableCards = data.Cards.ToList();
            shuffledCards = new List<Card>();

            in_deck = new bool[availableCards.Count];

            randomNumberGenerator = rg;
        }
Exemple #19
0
 public YammerTaskRunner(IYammerMessagePoster poster, IYammerMessageFetcher messageFetcher, IYammerMessageDatabaseManager databaseManager, IYammerResponseFetcher responseFetcher, IRandomNumberGenerator randomNumberGenerator, IYammerCommandFetcher commandFetcher)
 {
     _poster = poster;
     _messageFetcher = messageFetcher;
     _databaseManager = databaseManager;
     _responseFetcher = responseFetcher;
     _randomNumberGenerator = randomNumberGenerator;
     _commandFetcher = commandFetcher;
 }
 public RandomLiquidityMaker(IRandomNumberGenerator randomNumberGenerator, double maxOrderSize, double maxPriceDifferential, double doNothingProbability, Normal normalDist,int decimals)
 {
     _rng = randomNumberGenerator;
     _maxOrderSize = maxOrderSize;
     _maxPriceDifferential = maxPriceDifferential;
     _doNothingProbability = doNothingProbability;
     _normal = normalDist;
     _decimals = decimals;
 }
 /// <summary>
 /// Prevents a default instance of the <see cref="GameFifteenEngine"/> class from being created
 /// </summary>
 public GameFifteenEngine(
     IMatrixField field,
     IScoreboard scoreboardProxy,
     IRandomNumberGenerator random)
 {
     this.field = field;
     this.scoreboard = scoreboardProxy;
     this.random = random;
 }
Exemple #22
0
        public TicTacToeGame(IGameBoard gameBoard, IDisplayHelper displayHelper, IRandomNumberGenerator randomNumberGenerator)
        {
            _gameBoard = gameBoard;
            _displayHelper = displayHelper;
            _randomNumberGenerator = randomNumberGenerator;

            // Started with player factory but I think it was over engineered so replaced it with direct player creations
            PlayerO = new Player('O');
            PlayerX = new Player('X');
        }
Exemple #23
0
        public RandomRoll(int numberSides, IRandomNumberGenerator randomNumberGen)
        {
            if (numberSides <= 1)
                throw new ArgumentOutOfRangeException("numberSides must be greater than 1.");
            if (randomNumberGen == null)
                throw new ArgumentNullException("randomNumberGen cannot be null.");

            _generator = randomNumberGen;
            _numberSides = numberSides;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="EntitySetAndTypeSelector"/> class.
        /// </summary>
        /// <param name="entityContainer">The entity container.</param>
        /// <param name="random">The random number generator.</param>
        /// <param name="minimumNumberOfEntitiesPerEntitySet">The minimum number of entities per entity set.</param>
        public EntitySetAndTypeSelector(
            EntityContainer entityContainer,
            IRandomNumberGenerator random,
            int minimumNumberOfEntitiesPerEntitySet)
        {
            this.entityContainer = entityContainer;
            this.random = random;

            this.InitializeTargets(minimumNumberOfEntitiesPerEntitySet);
        }
Exemple #25
0
        public WeightedRoll(int numberSides, IRandomNumberGenerator randomNumGenerator)
        {
            if (randomNumGenerator == null)
                throw new ArgumentNullException("randomNumGenerator cannot be null.");

            _numberSides = numberSides;
            _generator = randomNumGenerator;
            _weights = Enumerable.Range(0, numberSides)
                .Select(x => 1000)
                .ToArray();
        }
 public PlayerManager(
     IRandomNumberGenerator randomNumberGenerator,
     InputManager inputManager,
     CardManager cardManager,
     bool isHost)
 {
     this.randomNumberGenerator = randomNumberGenerator;
     this.inputManager = inputManager;
     this.cardManager = cardManager;
     this.isHost = isHost;
 }
 /// <summary>
 /// Puts the specified <paramref name="payload"/> into an expanded link inside of a newly constructed entry.
 /// </summary>
 /// <param name="payload">The payload to be used as content for the expanded link.</param>
 /// <param name="isSingletonRelationship">true if the navigation property is of singleton cardinality; false for a cardinality many. Default is false.</param>
 /// <param name="randomDataGeneratorResolver">Random dataGeneration resolver</param>
 /// <param name="randomNumberGenerator">random number generator</param>
 /// <returns>An entry payload with an expanded link that contains the specified <paramref name="payload"/>.</returns>
 public static PayloadReaderTestDescriptor InEntryWithExpandedLink(
     this PayloadReaderTestDescriptor payload,
     bool isSingletonRelationship = false,
     IRandomDataGeneratorResolver randomDataGeneratorResolver = null,
     IRandomNumberGenerator randomNumberGenerator = null)
 {
     return new PayloadReaderTestDescriptor(payload)
     {
         PayloadDescriptor = payload.PayloadDescriptor.InEntryWithExpandedLink(isSingletonRelationship, randomDataGeneratorResolver, randomNumberGenerator)
     };
 }
        /// <summary>
        /// Generates the specified number of similar complex instances
        /// </summary>
        /// <param name="random">Random number generator for generating instance property values.</param>
        /// <param name="currentInstance">Instance to copy.</param>
        /// <param name="numberOfInstances">Number of similar instances to generate.</param>
        /// <param name="randomizePropertyValues">If this is false it will copy the instance without changing it otherwise the property values will be randomized.</param>
        /// <returns>A set of similar instances.</returns>
        public static IEnumerable<ComplexInstance> GenerateSimilarComplexInstances(
            IRandomNumberGenerator random,
            ComplexInstance currentInstance,
            int numberOfInstances,
            bool randomizePropertyValues = false)
        {
            ExceptionUtilities.CheckArgumentNotNull(random, "random");
            ExceptionUtilities.CheckArgumentNotNull(currentInstance, "currentInstance");
            ExceptionUtilities.CheckArgumentNotNull(numberOfInstances, "numberOfInstance");

            return Enumerable.Range(0, numberOfInstances).Select(x => GenerateSimilarComplexInstance(random, currentInstance));
        }
        /// <summary>
        /// Generates random string of specified length.
        /// </summary>
        /// <param name="random">The random number generator to use.</param>
        /// <param name="minLength">Minimum length of the generated string.</param>
        /// <param name="maxLength">Maximum length of the generated string.</param>
        /// <returns>Generated string.</returns>
        public string GenerateString(IRandomNumberGenerator random, int minLength, int maxLength)
        {
            ExceptionUtilities.CheckArgumentNotNull(random, "random");
            ExceptionUtilities.CheckValidRange(minLength, "minLength", maxLength, "maxLength");

            var selectedGenerator = random.ChooseFrom(this.generators, this.weights);
            if (selectedGenerator == null)
            {
                throw new TaupoInvalidOperationException("Unable to select a string generator. Check the weights.");
            }

            return selectedGenerator.GenerateString(random, minLength, maxLength);
        }
 public TrainingSession(IUserSettings settings, ITimer timer, ITrainer trainer, ITaunter taunter, IMetronome metronome, ISequencer sequencer, IContentCollection content, 
     IContentViewer viewer, IRandomNumberGenerator randomNumberGenerator)
 {
     _taunter = taunter;
     Settings = settings;
     Trainer = trainer;
     Taunter = taunter;
     Metronome = metronome;
     Sequencer = sequencer;
     Content = content;
     Viewer = viewer;
     Timer = timer;
     RNG = randomNumberGenerator;
 }
Exemple #31
0
 public ComplexRandomNumberAlgorithm(IRandomNumberGenerator random)
     : base(random)
 {
 }
Exemple #32
0
 public RationalRandomNumberAlgorithm(IRandomNumberGenerator random)
     : base(random)
 {
 }
 public CustomWebApplicationFactory(IRandomNumberGenerator randomNumberGenerator = null)
 {
     this.randomNumberGenerator = randomNumberGenerator ?? new RandomNumberGenerator();
 }
 public StratifiedRandomSampleGenerator(IRandomNumberGenerator rng)
 {
     _rng = rng;
 }
Exemple #35
0
 /// <summary>
 ///     初始化随机数生成器
 /// </summary>
 /// <param name="generator">随机数字生成器</param>
 public RandomBuilder(IRandomNumberGenerator generator = null)
 {
     _random = generator ?? new RandomNumberGenerator();
 }
Exemple #36
0
 protected RandomNumberAlgorithm(IRandomNumberGenerator random)
 {
     this.random = random;
 }
Exemple #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AdditiveNoise"/> class.
 /// </summary>
 ///
 /// <param name="generator">Random number genertor used to add noise.</param>
 ///
 public AdditiveNoise(IRandomNumberGenerator generator)
     : this()
 {
     this.generator = generator;
 }
Exemple #38
0
        public DrayageOptimizer(IProbabilityMatrix probabilityMatrix,
                                IRouteService routeService, INodeService nodeService, IRouteStopService routeStopService,
                                IRouteExitFunction routeExitFunction, ILogger logger, IPheromoneMatrix pheromoneMatrix, IRandomNumberGenerator randomNumberGenerator, INodeFactory nodeFactory)
        {
            _probabilityMatrix     = probabilityMatrix;
            _routeStopService      = routeStopService;
            _routeExitFunction     = routeExitFunction;
            _logger                = logger;
            _pheromoneMatrix       = pheromoneMatrix;
            _randomNumberGenerator = randomNumberGenerator;
            this._nodeFactory      = nodeFactory;
            _nodeService           = nodeService;
            _routeService          = routeService;

            // default values
            EnableParallelism           = false;
            PheromoneUpdateFrequency    = 10;
            MaxIterations               = 10000;
            MaxIterationSinceBestResult = 1000;
            MaxExecutionTime            = 10000;
        }
        public List <Agent> MakeCrossovers(List <Agent> parentAgents, int populationSize, IRandomNumberGenerator random)
        {
            List <Agent> children = MakeOnePointCombineCrossovers(parentAgents, populationSize, random);

            return(children);
        }
 public HealthCheckGetController(IRandomNumberGenerator generator)
 {
     _generator = generator;
 }
        private IEnumerable <string> SelectPasswords(IRandomNumberGenerator random, int length, int count, bool onlyFromBasicMultilingualPlane, bool includeEastAsianCharacters)
        {
            length = Math.Min(length, MaxLength);
            count  = Math.Min(count, MaxCount);
            if (count <= 0 || length <= 0)
            {
                yield break;
            }
            var allowedCategories = includeEastAsianCharacters ? AsianCategories : DefaultCategories;

            var sw = System.Diagnostics.Stopwatch.StartNew();
            int numberOfCharacters = 0, attempts = 0;
            var mask = onlyFromBasicMultilingualPlane ? 0x0000ffff : 0x001fffff;
            var sb   = new StringBuilder();

            for (int i = 0; i < count; i++)
            {
                numberOfCharacters = 0;
                attempts           = 0;
                sb.Clear();

                while (numberOfCharacters < length)
                {
                    // Get random int32 and create a code point from it.
                    // PERF: can reduce number of bytes required here based on the mask.
                    var codePoint = random.GetRandomInt32();
                    codePoint = codePoint & mask;       // Mask off the top bits, which aren't used.
                    attempts++;

                    // Break if too many attempts.
                    if (attempts > MaxAttemptsPerCodePoint)
                    {
                        continue;
                    }

                    // Surrogate code points are invalid.
                    if (this.InvalidSurrogateCodePoints(codePoint))
                    {
                        continue;
                    }
                    // Ensure the code point is not outside the maximum range.
                    if (this.InvalidMaxCodePoints(codePoint))
                    {
                        continue;
                    }

                    // the Int32 to up to 2 Char structs (in a string).
                    var s        = Char.ConvertFromUtf32(codePoint);
                    var category = Char.GetUnicodeCategory(s, 0);
                    if (!allowedCategories.Contains(category))
                    {
                        // Not allowed category.
                        continue;
                    }
                    sb.Append(s);
                    numberOfCharacters++;
                }

                var result = sb.ToString();
                yield return(result);

                attempts = 0;
            }
            sw.Stop();


            var bytesRequested = (int)((random as Terninger.Random.CypherBasedPrngGenerator)?.BytesRequested).GetValueOrDefault();

            RandomService.LogPasswordStat("Unicode", count, sw.Elapsed, bytesRequested, IPAddressHelpers.GetHostOrCacheIp(Request).AddressFamily, HttpContext.GetApiKeyId());
            if (!IpThrottlerService.HasAnyUsage(IPAddressHelpers.GetHostOrCacheIp(this.HttpContext.Request)))
            {
                RandomService.AddWebRequestEntropy(this.Request);
            }
            IpThrottlerService.IncrementUsage(IPAddressHelpers.GetHostOrCacheIp(this.HttpContext.Request), count);
        }
 public RandomNumberGeneratorAdapter(IRandomNumberGenerator rng)
 {
     this.rng = rng;
 }
Exemple #43
0
 public DoubleRandomNumberAlgorithm(IRandomNumberGenerator random)
     : base(random)
 {
 }
Exemple #44
0
 /// <summary>
 /// Creates an exhaustive delay-bounding strategy that uses
 /// the specified random number generator.
 /// </summary>
 /// <param name="maxSteps">Max scheduling steps</param>
 /// <param name="maxDelays">Max number of delays</param>
 /// <param name="logger">ILogger</param>
 /// <param name="random">IRandomNumberGenerator</param>
 public ExhaustiveDelayBoundingStrategy(int maxSteps, int maxDelays, ILogger logger, IRandomNumberGenerator random)
     : base(maxSteps, maxDelays, logger, random)
 {
     DelaysCache = Enumerable.Repeat(0, MaxDelays).ToList();
 }
Exemple #45
0
 public BigIntegerRandomNumberAlgorithm(IRandomNumberGenerator random)
     : base(random)
 {
 }
Exemple #46
0
 public Int64RandomNumberAlgorithm(IRandomNumberGenerator random)
     : base(random)
 {
 }
Exemple #47
0
        private async Task FuzzGenerator(int iterations, int bytesPerRequestMin, int bytesPerRequestMax, IRandomNumberGenerator generator, string filename)
        {
            var rng = new StandardRandomWrapperGenerator();

            using (var sw = new StreamWriter(filename + ".txt", false, Encoding.UTF8))
            {
                await sw.WriteLineAsync($"{generator.GetType().FullName} - {iterations:N0} iterations");

                for (int i = 0; i < iterations; i++)
                {
                    var bytesToGet = rng.GetRandomInt32(bytesPerRequestMin, bytesPerRequestMax);
                    var bytes      = generator.GetRandomBytes(bytesToGet);
                    if (bytes == null)
                    {
                        await sw.WriteLineAsync("<null>");
                    }
                    else
                    {
                        await sw.WriteLineAsync(bytes.ToHexString());
                    }
                }
            }
        }
Exemple #48
0
 public UInt32RandomNumberAlgorithm(IRandomNumberGenerator random)
     : base(random)
 {
 }
Exemple #49
0
        public void Constructor_FromRng_NullExceptionTest()
        {
            IRandomNumberGenerator nRng = null;

            Assert.Throws <ArgumentNullException>(() => new BIP0032(nRng));
        }
Exemple #50
0
 public NumberRandomNumberAlgorithm(IRandomNumberGenerator random)
     : base(random)
 {
     trandom = random.Create <T>();
 }
Exemple #51
0
 public object GetValue(IRandomNumberGenerator rng)
 {
     return(Color.Lerp(this.min, this.max, rng.Float()));
 }
Exemple #52
0
 /// <summary>
 /// Dealer constructor.
 /// </summary>
 /// <param name="random">The random number generator.</param>
 public Dealer(IRandomNumberGenerator random)
 {
     _random = random;
 }