Exemplo n.º 1
0
        public void NextPosition_ReturnsPositionsWithinBoundsAndAllPossiblePositionsAreGeneratedEventually()
        {
            var rng             = new RandomNumberGenerator(9438);
            var results         = new List <Position>();
            var bounds          = new Bounds(-1, -1, 4, 4);
            var possibleResults = new[]
            {
                new Position(-1, -1), new Position(+0, -1), new Position(+1, -1), new Position(+2, -1),
                new Position(-1, +0), new Position(+0, +0), new Position(+1, +0), new Position(+2, +0),
                new Position(-1, +1), new Position(+0, +1), new Position(+1, +1), new Position(+2, +1),
                new Position(-1, +2), new Position(+0, +2), new Position(+1, +2), new Position(+2, +2)
            };

            for (int i = 0; i < 200; i++)
            {
                var result = rng.NextPosition(bounds);
                results.Add(result);
            }

            foreach (Position result in results)
            {
                possibleResults.Should().Contain(result);
            }
            foreach (Position possibleResult in possibleResults)
            {
                results.Should().Contain(possibleResult);
            }
        }
Exemplo n.º 2
0
        public TestGrid(int xSize, int ySize, GridDensity density, bool hasWalls, int?seed = null)
        {
            _density  = density;
            _hasWalls = hasWalls;
//			_noise = seed == null ? new Noise2D() : new Noise2D(seed.Value);
            XSize        = xSize;
            YSize        = ySize;
            MinPosition  = new Position(0, 0);
            Bounds       = new Bounds(MinPosition.x, MinPosition.y, xSize, ySize);
            _walkability = GenerateWalkabilityMatrix(xSize, ySize);
        }