Exemplo n.º 1
0
		private Cell GetRandomEmptyCell()
		{
			IRandom random = new DotNetRandom();

			while (true)
			{
				int x = random.Next(width - 1);
				int y = random.Next(height - 1);
				if (_map.IsWalkable(x, y))
				{
					return _map.GetCell(x, y);
				}
			}
		}
Exemplo n.º 2
0
        public void Restore_AfterGeneratingThreeNumbers_RegeneratesSameThreeNumbers()
        {
            IRandom random = new DotNetRandom();
             for ( int i = 0; i < 25; i++ )
             {
            random.Next( 1000 );
             }
             RandomState state = random.Save();
             int first = random.Next( 1000 );
             int second = random.Next( 1000 );
             int third = random.Next( 1000 );

             random.Restore( state );

             Assert.AreEqual( first, random.Next( 1000 ) );
             Assert.AreEqual( second, random.Next( 1000 ) );
             Assert.AreEqual( third, random.Next( 1000 ) );
        }