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; }
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]); }
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]); } }
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]); } }
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); }
private char GetRandomUpperCaseLetter() { int randomCharIndex = randomizer.Get('A', 'Z'); return((char)randomCharIndex); }
public static void Main() { Console.WriteLine(PseudoRandom.Get()); }
static void Main() { PseudoRandom r = new PseudoRandom(); Console.WriteLine(r.Get()); }