Example #1
0
        public void SpawnAtRandomLocation()
        {
            int x            = random.Get(2, gridSize - 2);
            int y            = random.Get(2, gridSize - 2);
            var newRandomPos = new Vector2D(x * blockSize, y * blockSize);
            var newDrawArea  = new Rectangle(newRandomPos, new Size(blockSize));

            DrawArea = newDrawArea;
        }
Example #2
0
        public static Color GetRandomBrightColor()
        {
            var r = (byte)PseudoRandom.Get(128, 256);
            var g = (byte)PseudoRandom.Get(128, 256);
            var b = (byte)PseudoRandom.Get(128, 256);

            return(new Color(r, g, b));
        }
        public void RandomFloatSanityTest()
        {
            var random = new PseudoRandom();
            const int Max = 10;
            var wasChosen = new bool[Max];
            const int Trials = Max * 1000;
            for (int i = 0; i < Trials; i++)
                wasChosen[(int)random.Get(0.0f, Max)] = true;

            for (int i = 0; i < Max; i++)
                Assert.IsTrue(wasChosen[i]);
        }
Example #4
0
        public void RandomIntSanityTest()
        {
            const int Max       = 10;
            var       wasChosen = new bool[Max];
            const int Trials    = Max * 1000;

            for (int i = 0; i < Trials; i++)
            {
                wasChosen[PseudoRandom.Get(0, Max)] = true;
            }

            for (int i = 0; i < Max; i++)
            {
                Assert.IsTrue(wasChosen[i]);
            }
        }
Example #5
0
        public void RandomFloatSanityTest()
        {
            var       random    = new PseudoRandom();
            const int Max       = 10;
            var       wasChosen = new bool[Max];
            const int Trials    = Max * 1000;

            for (int i = 0; i < Trials; i++)
            {
                wasChosen[(int)random.Get(0.0f, Max)] = true;
            }
            for (int i = 0; i < Max; i++)
            {
                Assert.IsTrue(wasChosen[i]);
            }
        }
Example #6
0
        public void CreateLogos()
        {
            var randomizer = new PseudoRandom();
            var factory    = new LogoFactory(Resolve <ScreenSpace>());
            var logos      = new List <Logo>();
            var n          = randomizer.Get(10, 100);

            for (int i = 0; i < n; i++)
            {
                var logo = factory.Create();
                if (logo != null)
                {
                    logos.Add(logo);
                }
            }
            Assert.IsTrue(logos.Count == n);
        }
Example #7
0
        private char GetRandomUpperCaseLetter()
        {
            int randomCharIndex = randomizer.Get('A', 'Z');

            return((char)randomCharIndex);
        }
Example #8
0
 public static void Main()
 {
     Console.WriteLine(PseudoRandom.Get());
 }
Example #9
0
    static void Main()
    {
        PseudoRandom r = new PseudoRandom();

        Console.WriteLine(r.Get());
    }