Exemple #1
0
 public static void LayoutObjectsAtRandom <T>(T[] items, DataGrid <T> grid, BoundsInt bounds, int z, float chance, bool overwrite = false)
 {
     for (int y = bounds.yMin; y <= bounds.yMax; y++)
     {
         for (int x = bounds.xMin; x <= bounds.xMax; x++)
         {
             if (Random.Bool(chance))
             {
                 grid.Add(new Vector3Int(x, y, z), items[items.RandomArrayIndex()], overwrite);
             }
         }
     }
 }
Exemple #2
0
        public static Game Random(int size = 20)
        {
            var game = new Game(size);

            for (var x = 0; x < size; x++)
            {
                for (var y = 0; y < size; y++)
                {
                    game._grid[x, y] = Rnd.Bool();
                }
            }

            return(game);
        }
Exemple #3
0
        static int ChangeThickness(int thickness, Vector2Int range)
        {
            if (Random.Bool())
            {
                if (Random.Bool())
                {
                    thickness++;
                }
                else
                {
                    thickness--;
                }

                thickness = Mathf.Clamp(thickness, range.x, range.y);
            }

            return(thickness);
        }
    public void SetupIslandForGeneration(Island island)
    {
        //always use random with static unique per island seed so engine will generate always same island in given position
        random = new Random(GetPerIslandSeed(island));

        //height generation properties
        PerIslandGeneratorProperties properties = new PerIslandGeneratorProperties();

        island.GeneratorProperties = properties;

        properties.islandSize   = (int)random.Range(300, 1000);
        properties.noiseOffset  = random.Range(.4f, 1f);
        properties.circleShaped = random.Bool();

        //mesh generation properties
        island.Size             = properties.islandSize;
        island.minPointRadius   = 6;
        island.trianglesInChunk = 1500;
    }
        public void UnwrapsChannelFlowOkMethodFrame()
        {
            var message = new ChannelFlowOk(
                active: Random.Bool()
                );

            _context.Send(_subject, (Inbound, RawFrame.Wrap(_channelNumber, message)));

            if (_messageReceivedSignal.Wait(timeout: TimeSpan.FromMilliseconds(100)))
            {
                var unwrappedMessage = _unwrappedMessage as ChannelFlowOk;

                Assert.Equal(expected: message.Active, actual: unwrappedMessage.Active);
            }
            else
            {
                // No `ChannelFlowOk` command was received within 100 millis...
                throw new TimeoutException("Timeout occurred before command was received");
            }
        }
Exemple #6
0
        /// <summary>
        /// Gets a full name
        /// </summary>
        public string FindName(string firstName = "", string lastName = "", bool?withPrefix = null, bool?withSuffix = null)
        {
            if (string.IsNullOrWhiteSpace(firstName))
            {
                firstName = FirstName();
            }
            if (string.IsNullOrWhiteSpace(lastName))
            {
                lastName = LastName();
            }

            if (!withPrefix.HasValue && !withSuffix.HasValue)
            {
                withPrefix = Random.Bool();
                withSuffix = !withPrefix;
            }

            return(string.Format("{0} {1} {2} {3}",
                                 withPrefix.GetValueOrDefault() ? Prefix() : "", firstName, lastName, withSuffix.GetValueOrDefault() ? Suffix() : "")
                   .Trim());
        }
Exemple #7
0
        /// <summary>
        /// Gets a full name.
        /// </summary>
        /// <param name="firstName">Use this first name.</param>
        /// <param name="lastName">use this last name.</param>
        /// <param name="withPrefix">Add a prefix?</param>
        /// <param name="withSuffix">Add a suffix?</param>
        public string FindName(string firstName = "", string lastName = "", bool?withPrefix = null, bool?withSuffix = null, Gender?gender = null)
        {
            gender ??= this.Random.Enum <Gender>();
            if (string.IsNullOrWhiteSpace(firstName))
            {
                firstName = FirstName(gender);
            }
            if (string.IsNullOrWhiteSpace(lastName))
            {
                lastName = LastName(gender);
            }

            if (!withPrefix.HasValue && !withSuffix.HasValue)
            {
                withPrefix = Random.Bool();
                withSuffix = !withPrefix;
            }

            var prefix = withPrefix.GetValueOrDefault() ? Prefix(gender) : "";
            var suffix = withSuffix.GetValueOrDefault() ? Suffix() : "";

            return($"{prefix} {firstName} {lastName} {suffix}".Trim());
        }
Exemple #8
0
 public bool Bool()
 {
     return(Random.Bool(random));
 }
Exemple #9
0
 public bool Bool(float probability01)
 {
     return(Random.Bool(probability01, random));
 }
Exemple #10
0
        /// <summary>
        /// Draw a random boolean with equal probability of drawing true or false.
        /// </summary>
        public sealed override bool Bool()
        {
            Switch();

            return(Rand.Bool());
        }
Exemple #11
0
 /// <summary>
 /// Get a street name.
 /// </summary>
 /// <returns></returns>
 public string StreetName()
 {
     return($"{(Random.Bool() ? Name.FirstName() : Name.LastName())} {StreetSuffix()}".Trim());
 }
Exemple #12
0
 /// <inheritdoc />
 public bool Bool()
 {
     return(_random.Bool());
 }