예제 #1
0
 private static ILayer CreateLayerWithStyleOnLayer(MRect?envelope, int count = 25)
 {
     return(new Layer("Style on Layer")
     {
         DataSource = new MemoryProvider <PointFeature>(RandomPointGenerator.GenerateRandomPoints(envelope, count).ToFeatures()),
         Style = CreateBitmapStyle("Images.ic_place_black_24dp.png")
     });
 }
예제 #2
0
        public void CanGenerateUniquePointIfProvidedPointToExclude()
        {
            var randomGenerator = new RandomPointGenerator(maxSize);
            var pointToExclude  = new Point(0, 0);
            var point           = randomGenerator.NextPoint(pointToExclude);

            point.Should().NotBeSameAs(pointToExclude);
        }
예제 #3
0
 public void Setup(LocalBlackboard localBlackboard)
 {
     if (TryGetComponent(out RandomPointGenerator temp))
     {
         _randMovePoint = temp;
         _randMovePoint.Setup(localBlackboard);
     }
 }
예제 #4
0
        public void CanGenerateNewPoint()
        {
            var randomGenerator = new RandomPointGenerator(maxSize);
            var point           = randomGenerator.NextPoint();

            point.Should().BeOfType <Point>();
            point.X.Should().BeInRange(minSize, maxSize - 1);
            point.Y.Should().BeInRange(minSize, maxSize - 1);
        }
예제 #5
0
        public void generatePointTest()
        {
            RandomPointGenerator gen  = new RandomPointGenerator();
            PlaneProjector       proj = new PlaneProjector();

            Point p = gen.generatePoint(3);

            //Assert.IsTrue(proj.isAddingToOne(p));
        }
예제 #6
0
 private static IEnumerable <IFeature> GenerateRandomFeatures(MRect?envelope, int count, IStyle style)
 {
     return(RandomPointGenerator.GenerateRandomPoints(envelope, count, 123)
            .Select(p => new PointFeature(p)
     {
         Styles = new List <IStyle> {
             style
         }
     }).ToList());
 }
예제 #7
0
 private static ILayer CreateStylesLayer(MRect?envelope)
 {
     return(new MemoryLayer
     {
         Name = "Styles Layer",
         Features = CreateDiverseFeatures(RandomPointGenerator.GenerateRandomPoints(envelope, 25)),
         Style = null,
         IsMapInfoLayer = true
     });
 }
예제 #8
0
 private static ILayer CreateAtlasLayer(MRect?envelope)
 {
     return(new MemoryLayer
     {
         Name = AtlasLayerName,
         Features = CreateAtlasFeatures(RandomPointGenerator.GenerateRandomPoints(envelope, 1000)),
         Style = null,
         IsMapInfoLayer = true
     });
 }
예제 #9
0
        public static Map CreateMap()
        {
            var map = new Map();

            map.Layers.Add(OpenStreetMap.CreateTileLayer());
            var provider = RandomPointGenerator.CreateProviderWithRandomPoints(map.Extent);

            map.Layers.Add(CreateStackedLabelLayer(provider, LabelColumn));
            map.Layers.Add(CreateLayer(provider));
            return(map);
        }
예제 #10
0
        protected PointFinder(uint minimum, uint maximum, string outputDirectory, string outputFile, RandomPointGenerator pointGenerator)
        {
            _minimum         = minimum;
            _maximum         = maximum;
            _outputDirectory = outputDirectory;
            _outputFile      = outputFile;

            _pointGenerator = pointGenerator;

            _log = LogManager.GetLogger(GetType());
        }
예제 #11
0
        public void EasyProducterConsumerWithThreadingChannel()
        {
            IProducer <Point>        producer            = FILL_ME_IN;
            IConsumerFactory <Point> computeProbaFactory = FILL_ME_IN;
            // no change required from here
            var randomPointGenerator = new RandomPointGenerator(producer);

            var(piEvaluator, consumer) = (new PiEvaluatorFactory(computeProbaFactory)).CreateInstance();
            Task consumerTask;
            Task producerTask;

            consumerTask = consumer.StartConsume();
            producerTask = randomPointGenerator.GeneratePoints(10_000_000).ContinueWith(t => consumer.StopConsume());
            Task.WaitAll(consumerTask, producerTask);
            Assert.True(Math.Abs(piEvaluator.Pi - 3.1415) < epsilon);
        }
예제 #12
0
        public static Map CreateMap()
        {
            var provider          = RandomPointGenerator.CreateProviderWithRandomPoints(new MRect(-100, -100, 100, 100), 20, 0);
            var layer             = CreateLayer(provider);
            var stackedLabelLayer = CreateStackedLabelLayer(provider, LabelColumn);

            var map = new Map
            {
                BackColor = Color.FromString("WhiteSmoke"),
                Home      = n => n.NavigateTo(layer.Extent !.Grow(layer.Extent.Width * 0.3))
            };

            map.Layers.Add(stackedLabelLayer);
            map.Layers.Add(layer);

            return(map);
        }
예제 #13
0
        public static Map CreateMap()
        {
            var random            = new Random(6);
            var features          = RandomPointGenerator.CreateRandomFeatures(new MRect(-100, -100, 100, 100), 20, random);
            var layer             = CreateLayer(features);
            var stackedLabelLayer = CreateStackedLabelLayer(features, LabelColumn);

            var map = new Map
            {
                BackColor = Color.FromString("WhiteSmoke"),
                Home      = n => n.NavigateTo(layer.Extent !.Grow(layer.Extent.Width * 0.3))
            };

            map.Layers.Add(stackedLabelLayer);
            map.Layers.Add(layer);

            return(map);
        }
예제 #14
0
    public void Generate()
    {
        var startTime = DateTime.Now;

        // generate the partitioning
        if (!_pointMap)
        {
            _pointMap = GetComponent <RandomPointGenerator>();
        }
        _pointMap.Generate();
        GenerateVoronoi(_pointMap.Points, _pointMap.PointWidth, _pointMap.PointHeight);
        Debug.Log("map generated in : " + (DateTime.Now - startTime).TotalMilliseconds);
        startTime = DateTime.Now;
        // apply the map the geomtry "meshes"
        if (GetComponent <GenerateGeometry>() && GetComponent <GenerateGeometry>().isActiveAndEnabled)
        {
            GetComponent <GenerateGeometry>().Generate();
        }

        Debug.Log("polygons generated in : " + (DateTime.Now - startTime).TotalMilliseconds);
    }
예제 #15
0
        /// <summary>
        /// Handles the initialization of game-specific options.
        /// </summary>
        /// <param name="options">Contains the user's desired game options</param>
        public void Initialize(GameOptions options)
        {
            // Get the map size that will be used for the current game.
            mapSize = MapGenerator.SetMapSize(options.MapSize);

            // Configure the round timer and hook up the event handler.
            timer         = new RoundTimer(options.Difficulty);
            timer.OnTick += (source, e) => ExecuteCycle();

            // Set up collision detection.
            colDetector = new CollisionDetector(mapSize);

            // Initialize the random point and food generators.
            randomPointGenerator = RandomPointGenerator.Create(mapSize);
            foodGenerator        = new FoodGenerator(randomPointGenerator);

            // Initialize the game map.
            map = MapGenerator.GenerateMap(mapSize, options.TileStyle);

            // Place the snek and food at their initial locations.
            snek = new Snekk(MapGenerator.GenerateStartingPoint(mapSize));
            food = foodGenerator.Generate(snek.GetSegmentLocations());
        }
예제 #16
0
        private void FindPoints(Options options)
        {
            var arguments = DeserializeArguments <PointFinderArguments>(options.ConfigurationFilepath);

            RandomPointGenerator generator;

            switch (arguments.SelectionStrategy)
            {
            case PointSelectionStrategy.Random:
                generator = new RandomPointGenerator();
                break;

            case PointSelectionStrategy.BulbsExcluded:
                generator = new BulbsExcludedPointGenerator();
                break;

            case PointSelectionStrategy.EdgesWithBulbsExcluded:
                generator = new EdgeAreasWithBulbsExcludedPointGenerator(arguments.InputDirectory, arguments.InputEdgeFilename);
                break;

            case PointSelectionStrategy.BulbsOnly:
                generator = new BulbsOnlyPointGenerator();
                break;

            case PointSelectionStrategy.EdgesAndBulbsOnly:
                generator = new EdgeAreasAndBulbsPointGenerator(arguments.InputDirectory, arguments.InputEdgeFilename);
                break;

            default:
                throw new ArgumentException();
            }

            PointFinder finder;

            switch (arguments.SelectionStrategy)
            {
            case PointSelectionStrategy.Random:
            case PointSelectionStrategy.BulbsExcluded:
            case PointSelectionStrategy.EdgesWithBulbsExcluded:
                finder = new BuddhabrotPointFinder(arguments.MinimumThreshold, arguments.MaximumThreshold, arguments.OutputDirectory, arguments.OutputFilenamePrefix, generator);
                break;

            case PointSelectionStrategy.BulbsOnly:
            case PointSelectionStrategy.EdgesAndBulbsOnly:
                finder = new MandelbrotPointFinder(arguments.MinimumThreshold, arguments.MaximumThreshold, arguments.OutputDirectory, arguments.OutputFilenamePrefix, generator);
                break;

            default:
                throw new ArgumentException();
            }

            System.Console.WriteLine("Press <ENTER> to stop...");

            Task.Factory.StartNew(() =>
            {
                System.Console.ReadLine();
                finder.Stop();
            });

            finder.Start();
        }
예제 #17
0
 public MandelbrotPointFinder(uint minimum, uint maximum, string outputDirectory, string outputFile, RandomPointGenerator pointGenerator)
     : base(minimum, maximum, outputDirectory, outputFile, pointGenerator)
 {
 }
예제 #18
0
 public static MemoryProvider <IFeature> CreateMemoryProviderWithDiverseSymbols(MRect?envelope, int count = 100)
 {
     return(new MemoryProvider <IFeature>(CreateSvgFeatures(RandomPointGenerator.GenerateRandomPoints(envelope, count))));
 }
예제 #19
0
 private void Start()
 {
     _pointMap = GetComponent <RandomPointGenerator>();
 }