예제 #1
0
        public MainViewModel()
        {
            AggregateFormationConfig = new AggregateFormationConfig();
            FilmFormationConfig      = new FilmFormationConfig();
            SimulationProperties     = new SimulationProperties();

            LoggingViewModel = new LoggingViewModel();
            StatusViewModel  = new StatusViewModel(LoggingViewModel);

            AggFormationControlViewModel = new AggFormationControlViewModel(
                AggregateFormationConfig,
                SimulationProperties,
                StatusViewModel,
                LoggingViewModel);

            FilmFormationControlViewModel = new FilmFormationControlViewModel(
                FilmFormationConfig,
                SimulationProperties,
                AggFormationControlViewModel,
                StatusViewModel,
                LoggingViewModel);

            FilmAnalysisControlViewModel = new FilmAnalysisControlViewModel();

            ActivateItem(AggFormationControlViewModel);
        }
예제 #2
0
 private void Validate(SimulationProperties simulationProperties)
 {
     if (simulationProperties == null)
     {
         throw new ArgumentNullException(nameof(simulationProperties));
     }
     if (!simulationProperties.PlayerPropertiesCollection.Any())
     {
         throw new ArgumentException("No players added to simulation properties");
     }
     foreach (var playerProperties in simulationProperties.PlayerPropertiesCollection)
     {
         if (playerProperties.PlayerStrategy == null)
         {
             throw new ArgumentException("No player strategy specified");
         }
     }
     if (simulationProperties.MaximumBetForTable < simulationProperties.MinimumBetForTable)
     {
         throw new ArgumentException("Maximum table bet is less than minimum table bet");
     }
     if (simulationProperties.MaximumPlayersForTable < 1)
     {
         throw new ArgumentException("Maximum players for table must be greater than zero");
     }
     if (simulationProperties.NumberOfDecksInShoe < 1)
     {
         throw new ArgumentException("Number of decks in simulation properties must be greater than zero");
     }
 }
예제 #3
0
 public StatisticReader(SimulationProperties simulationProperties, SystemProperties systemProperties, string inputFolderPath, string outoutFilePath)
 {
     this.simulationProperties = simulationProperties;
     this.systemProperties     = systemProperties;
     this.inputFolderPath      = inputFolderPath;
     this.outputFilePath       = outoutFilePath;
 }
 private void SetUpProperties()
 {
     properties = new SimulationProperties()
     {
         ScopeWidth        = (int)StructureImage.Width,
         ScopeHeight       = (int)StructureImage.Height,
         NumberOfGrains    = Converters.StringToInt(NumberOfGrainsTextBox.Text),
         NeighbourhoodType = ChooseNeighbourhoodType(),
         Inclusions        = new InclusionsProperties()
         {
             AreEnable      = (bool)EnableInclusionsCheckBox.IsChecked,
             Amount         = Converters.StringToInt(AmountOfInclusionsTextBox.Text),
             Size           = Converters.StringToInt(SizeOfInclusionsTextBox.Text),
             CreationTime   = ChooseCreationTime(),
             InclusionsType = ChooseInclusionsType()
         },
         GrowthProbability         = Converters.StringToInt(GrowthProbabilityTextBox.Text),
         StructureType             = ChooseStructureType(),
         NumberOfRemainingGrains   = Converters.StringToInt(NumberOfRemainingGringTextBox.Text),
         GrainBoundariesProperties = new GrainBoundariesProperties()
         {
             GrainsBoundariesOption           = ChooseGrainBoundariesOption(),
             NumberOfGrainsToSelectBoundaries = Converters.StringToInt(NumberOfGrainsBoundariesTextBox.Text),
             GrainBoundarySize = Converters.StringToInt(BoundarySizeTextBox.Text)
         },
         AdvancedMethodType = ChooseAdvancedMethodType()
     };
 }
        public void When_Running_Simulations_Should_Save_Simulations_Statistics_In_Repository()
        {
            var mockStatisticsRepository     = new Mock <IPlayerSimulationStatisticsRepository>();
            var mockSimulationsOutputHandler = new Mock <ISimulationsOutputHandler>();

            _sut = new SimulationsRunner(mockStatisticsRepository.Object, mockSimulationsOutputHandler.Object, new TableSimulationFactory());
            var mockPlayer = new Mock <IPlayer>();

            mockPlayer.Setup(mp => mp.HandHistory).Returns(new List <IPlayerHand> {
                GetHandHistoryHand()
            });
            mockPlayer.Setup(mp => mp.StartingCash).Returns(100);
            var simulationProperties = new SimulationProperties
            {
                MaximumBetForTable         = 100,
                MinimumBetForTable         = 10,
                MaximumPlayersForTable     = 2,
                NumberOfDecksInShoe        = 2,
                PlayerPropertiesCollection = new List <PlayerProperties>
                {
                    new PlayerProperties {
                        PlayerStrategy = new BasicMinimumPlayerStrategy().GetType(), StartingCash = 100
                    }
                }
            };

            _sut.Load(simulationProperties);
            _sut.Run(2);

            mockStatisticsRepository.Verify(msr => msr.Save(It.IsAny <List <PlayerSimulationsStatistics> >()));
        }
        public Scope ChangeStructure(SimulationProperties properties)
        {
            var        grainsPoints = new List <Point>();
            Point      actRandCoord = new Point(0, 0);
            List <int> prevRandIds  = new List <int>();

            for (int i = 0; i < properties.NumberOfRemainingGrains.Value; i++)
            {
                prevRandIds.Add(baseScope.StructureArray[actRandCoord.X, actRandCoord.Y].Id);
                do
                {
                    actRandCoord = StructureHelpers.RandomCoordinates(baseScope.Width, baseScope.Height, random);
                }while (prevRandIds.IndexOf(baseScope.StructureArray[actRandCoord.X, actRandCoord.Y].Id) != -1);
                grainsPoints.Add(actRandCoord);
            }
            var remainingGrains = GetRemainingGrains(grainsPoints);

            // class 5: CA -> CA
            // class 9: CA -> MC, MC -> MC, MC -> CA
            switch (properties.StructureType)
            {
            case StructureType.Dualphase:
                // dual phase - remaining grains should have id and color changed to the same one
                ChangeGrainsIntoSecondPhase(remainingGrains);
                return(GeterateDualphaseStructure(remainingGrains, properties));

            case StructureType.Substructure:
                // substructure - remaining grains shoudld have the same id and color as in base structure
                return(GenerateSubstructure(remainingGrains, properties));

            default:
                return(null);
            }
        }
예제 #7
0
        public void Read_file_properties()
        {
            var properties = SimulationProperties.FromFileName("occupanciesbinary_637297463816335541_100_48_0.8");

            Assert.Equal(100, properties.CellSize);
            Assert.Equal(48, properties.ChainSize);
            Assert.Equal(0.8M, properties.FillFactor);
        }
        public IActionResult BlackjackSimSetup()
        {
            var simulationProperties =
                new SimulationProperties {
                PlayerPropertiesCollection = new List <PlayerProperties>()
            };

            return(View(simulationProperties));
        }
예제 #9
0
 public void Load(SimulationProperties simulationProperties)
 {
     _simulationProperties = simulationProperties;
     _playerSimulationsTotalsCollection = new List <PlayerSimulationsTotals>();
     foreach (var player in _simulationProperties.PlayerPropertiesCollection)
     {
         _playerSimulationsTotalsCollection.Add(new PlayerSimulationsTotals(player.PlayerStrategy.Name,
                                                                            player.StartingCash));
     }
 }
예제 #10
0
        public void Create_filename_from_file_properties()
        {
            var properties = new SimulationProperties
            {
                CellSize   = 100,
                ChainSize  = 48,
                FillFactor = 0.8M
            };
            var fileName = properties.FormatAsFileName();

            Assert.Equal("100_48_0.8", fileName);
        }
        public void When_Player_Properties_Collection_Is_Empty_Should_Throw_Exception()
        {
            var simulationProperties = new SimulationProperties
            {
                MaximumBetForTable         = 10,
                MaximumPlayersForTable     = 2,
                MinimumBetForTable         = 5,
                NumberOfDecksInShoe        = 2,
                PlayerPropertiesCollection = new List <PlayerProperties>()
            };

            Assert.ThrowsException <ArgumentException>(() => _tableSimulationFactory.CreateTableSimulationFrom(simulationProperties));
        }
예제 #12
0
 public FilmFormationControlViewModel(
     IFilmFormationConfig filmFormationConfig,
     SimulationProperties simProp,
     AggFormationControlViewModel aggFormationControlViewModel,
     StatusViewModel statusViewModel,
     LoggingViewModel loggingViewModel)
 {
     FilmFormationConfig          = filmFormationConfig;
     SimProp                      = simProp;
     FilmFormationConfigViewModel = new FilmFormationConfigViewModel(FilmFormationConfig);
     AggFormationControlViewModel = aggFormationControlViewModel;
     _statusViewModel             = statusViewModel;
     _loggingViewModel            = loggingViewModel;
 }
        public void When_Number_Of_Decks_Less_Than_One_Should_Throw_Exception()
        {
            var simulationProperties = new SimulationProperties
            {
                MaximumBetForTable         = 10,
                MaximumPlayersForTable     = 0,
                MinimumBetForTable         = 5,
                NumberOfDecksInShoe        = 0,
                PlayerPropertiesCollection = new List <PlayerProperties> {
                    new PlayerProperties
                    {
                        PlayerStrategy = new BasicMinimumPlayerStrategy().GetType(), StartingCash = 100
                    }
                }
            };

            Assert.ThrowsException <ArgumentException>(() => _tableSimulationFactory.CreateTableSimulationFrom(simulationProperties));
        }
        public void When_Given_Valid_Simulation_Properties_Should_Return_Table_Simulation_Object()
        {
            var simulationProperties = new SimulationProperties
            {
                MaximumBetForTable         = 10,
                MaximumPlayersForTable     = 2,
                MinimumBetForTable         = 5,
                NumberOfDecksInShoe        = 1,
                PlayerPropertiesCollection = new List <PlayerProperties> {
                    new PlayerProperties
                    {
                        PlayerStrategy = new BasicMinimumPlayerStrategy().GetType(), StartingCash = 100
                    }
                }
            };

            Assert.IsInstanceOfType(_tableSimulationFactory.CreateTableSimulationFrom(simulationProperties), typeof(ITableSimulation));
        }
        public SimulationProperties GetSimulationProperties()
        {
            var simulationProperties = new SimulationProperties
            {
                MaximumBetForTable         = TABLE_MAXIMUM_BET,
                MinimumBetForTable         = TABLE_MINIMUM_BET,
                MaximumPlayersForTable     = TABLE_MAX_PLAYERS,
                NumberOfDecksInShoe        = NUMBER_OF_DECKS_IN_SHOE,
                PlayerPropertiesCollection = new List <PlayerProperties>
                {
                    new PlayerProperties
                    {
                        PlayerStrategy = new BasicMinimumPlayerStrategy().GetType(), StartingCash = PLAYER_STARTING_CASH
                    }
                }
            };

            return(simulationProperties);
        }
예제 #16
0
        public ITableSimulation CreateTableSimulationFrom(SimulationProperties simulationProperties)
        {
            Validate(simulationProperties);

            var tableSettings = new TableSettings(simulationProperties.MinimumBetForTable,
                                                  simulationProperties.MaximumBetForTable, simulationProperties.MaximumPlayersForTable);
            var cardDeck        = new ShoeOfStandardDecksOfCards(new BlackjackCardValueAssigner(), simulationProperties.NumberOfDecksInShoe);
            var dealer          = new Dealer(cardDeck, new GameManager(), new StandardDealerStrategy());
            var tableSimulation = new TableSimulation(dealer, tableSettings);

            foreach (var playerProperties in simulationProperties.PlayerPropertiesCollection)
            {
                var strategy = (IPlayerStrategy)playerProperties.PlayerStrategy.GetConstructors()[0].Invoke(null);
                var player   = new Player(playerProperties.StartingCash, strategy);
                tableSimulation.Seat(player);
            }

            return(tableSimulation);
        }
예제 #17
0
        protected override Task Context()
        {
            _solverSettingsMapper               = A.Fake <SolverSettingsMapper>();
            _outputSchemaMapper                 = A.Fake <OutputSchemaMapper>();
            _outputSelectionMapper              = A.Fake <OutputSelectionsMapper>();
            _parameterMapper                    = A.Fake <ParameterMapper>();
            _compoundPropertiesMapper           = A.Fake <CompoundPropertiesMapper>();
            _advancedParameterMapper            = A.Fake <AdvancedParameterMapper>();
            _eventMappingMapper                 = A.Fake <EventMappingMapper>();
            _observerSetMappingMapper           = A.Fake <ObserverSetMappingMapper>();
            _curveChartMapper                   = A.Fake <SimulationTimeProfileChartMapper>();
            _processMappingMapper               = A.Fake <ProcessMappingMapper>();
            _simulationFactory                  = A.Fake <ISimulationFactory>();
            _executionContext                   = A.Fake <IExecutionContext>();
            _simulationModelCreator             = A.Fake <ISimulationModelCreator>();
            _simulationBuildingBlockUpdater     = A.Fake <ISimulationBuildingBlockUpdater>();
            _modelPropertiesTask                = A.Fake <IModelPropertiesTask>();
            _simulationRunner                   = A.Fake <ISimulationRunner>();
            _populationAnalysisChartMapper      = A.Fake <PopulationAnalysisChartMapper>();
            _simulationParameterOriginIdUpdater = A.Fake <ISimulationParameterOriginIdUpdater>();
            _logger             = A.Fake <ILogger>();
            _containerTask      = A.Fake <IContainerTask>();
            _entityPathResolver = A.Fake <IEntityPathResolver>();

            sut = new SimulationMapper(_solverSettingsMapper, _outputSchemaMapper,
                                       _outputSelectionMapper, _compoundPropertiesMapper, _parameterMapper,
                                       _advancedParameterMapper, _eventMappingMapper, _observerSetMappingMapper, _curveChartMapper,
                                       _populationAnalysisChartMapper, _processMappingMapper,
                                       _simulationFactory, _executionContext, _simulationModelCreator,
                                       _simulationBuildingBlockUpdater, _modelPropertiesTask,
                                       _simulationRunner, _simulationParameterOriginIdUpdater,
                                       _logger, _containerTask, _entityPathResolver
                                       );

            _project    = new PKSimProject();
            _individual = new Individual {
                Name = "IND", Id = "IND"
            };
            _compound = new Compound {
                Name = "COMP", Id = "COMP"
            };
            _observerSet = new ObserverSet {
                Name = "OBS_SET", Id = "OBS_SET"
            };
            _protocol = new SimpleProtocol {
                Name = "PROT", Id = "PROT"
            };
            _inductionProcess = new InductionProcess().WithName("Interaction process");
            _compound.AddProcess(_inductionProcess);


            _event = new PKSimEvent {
                Name = "Event"
            };
            _population = new RandomPopulation()
            {
                Name = "POP"
            };
            _observedData = new DataRepository("OBS_ID").WithName("OBS");
            _project.AddBuildingBlock(_individual);
            _project.AddBuildingBlock(_compound);
            _project.AddBuildingBlock(_event);
            _project.AddBuildingBlock(_population);
            _project.AddBuildingBlock(_observerSet);
            _project.AddObservedData(_observedData);

            _simulationProperties = new SimulationProperties
            {
                ModelProperties = new ModelProperties
                {
                    ModelConfiguration = new ModelConfiguration {
                        ModelName = "4Comp"
                    }
                }
            };
            _interactionSelection = new InteractionSelection {
                ProcessName = _inductionProcess.Name
            };
            _noInteractionSelection = new InteractionSelection {
                MoleculeName = "CYP2D6"
            };

            _simulationProperties.InteractionProperties.AddInteraction(_interactionSelection);
            _simulationProperties.InteractionProperties.AddInteraction(_noInteractionSelection);

            _settings      = new SimulationSettings();
            _rootContainer = new Container().WithName("Sim");
            _model         = new OSPSuite.Core.Domain.Model {
                Root = _rootContainer
            };

            _individualSimulation = new IndividualSimulation
            {
                Name               = "S1",
                Properties         = _simulationProperties,
                SimulationSettings = _settings,
                Description        = "Simulation Description",
                Model              = _model
            };

            _simulationTimeProfile         = new SimulationTimeProfileChart();
            _snapshotSimulationTimeProfile = new CurveChart();
            _individualSimulation.AddAnalysis(_simulationTimeProfile);

            A.CallTo(() => _curveChartMapper.MapToSnapshot(_simulationTimeProfile)).Returns(_snapshotSimulationTimeProfile);


            _populationSimulation = new PopulationSimulation
            {
                Properties         = _simulationProperties,
                SimulationSettings = _settings,
                Model = _model
            };

            _advancedParameterCollection       = new AdvancedParameterCollection();
            _populationSimulationAnalysisChart = new BoxWhiskerAnalysisChart();
            _populationSimulation.SetAdvancedParameters(_advancedParameterCollection);
            _populationSimulation.AddAnalysis(_populationSimulationAnalysisChart);
            _populationSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("IndTemplateId", PKSimBuildingBlockType.Individual)
            {
                BuildingBlock = _individual
            });

            _snapshotPopulationAnalysisChart = new Snapshots.PopulationAnalysisChart();

            A.CallTo(() => _populationAnalysisChartMapper.MapToSnapshot(_populationSimulationAnalysisChart)).Returns(_snapshotPopulationAnalysisChart);

            _snapshotInteraction = new CompoundProcessSelection();
            A.CallTo(() => _processMappingMapper.MapToSnapshot(_interactionSelection)).Returns(_snapshotInteraction);
            _snapshotInteraction.CompoundName = _compound.Name;
            _snapshotInteraction.Name         = _inductionProcess.Name;

            _noSelectionSnapshotInteraction = new CompoundProcessSelection();
            A.CallTo(() => _processMappingMapper.MapToSnapshot(_noInteractionSelection)).Returns(_noSelectionSnapshotInteraction);
            _noSelectionSnapshotInteraction.MoleculeName = _noInteractionSelection.MoleculeName;

            _compoundProperties         = new CompoundProperties();
            _snapshotCompoundProperties = new Snapshots.CompoundProperties {
                Name = _compound.Name
            };
            _individualSimulation.Properties.AddCompoundProperties(_compoundProperties);

            _eventMapping = new EventMapping();
            _individualSimulation.EventProperties.AddEventMapping(_eventMapping);

            _observerSetMapping = new ObserverSetMapping();
            _individualSimulation.ObserverSetProperties.AddObserverSetMapping(_observerSetMapping);

            A.CallTo(() => _compoundPropertiesMapper.MapToSnapshot(_compoundProperties, _project)).Returns(_snapshotCompoundProperties);


            _eventSelection = new EventSelection
            {
                Name = _event.Name,
            };

            _observerSetSelection = new ObserverSetSelection
            {
                Name = _observerSet.Name,
            };

            _individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("IndTemplateId", PKSimBuildingBlockType.Individual)
            {
                BuildingBlock = _individual,

                Altered = true
            });

            _individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("CompTemplateId", PKSimBuildingBlockType.Compound)
            {
                BuildingBlock = _compound
            });

            _individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("ProtTemplateId", PKSimBuildingBlockType.Protocol)
            {
                BuildingBlock = _protocol
            });

            _individualSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("ObserveSetTemplateId", PKSimBuildingBlockType.ObserverSet)
            {
                BuildingBlock = _observerSet
            });

            _populationSimulation.AddUsedBuildingBlock(new UsedBuildingBlock("PopTemplateId", PKSimBuildingBlockType.Population)
            {
                BuildingBlock = _population
            });


            _individualSimulation.AddUsedObservedData(_observedData);

            A.CallTo(() => _eventMappingMapper.MapToSnapshot(_eventMapping, _project)).Returns(_eventSelection);
            A.CallTo(() => _observerSetMappingMapper.MapToSnapshot(_observerSetMapping, _project)).Returns(_observerSetSelection);

            _outputSelectionSnapshot = new OutputSelections();
            A.CallTo(() => _outputSelectionMapper.MapToSnapshot(_individualSimulation.OutputSelections)).Returns(_outputSelectionSnapshot);

            A.CallTo(() => _processMappingMapper.MapToModel(_snapshotInteraction, _inductionProcess)).Returns(_interactionSelection);

            return(_completed);
        }
        public static Scope InitCAStructure(SimulationProperties properties, Random random, Scope baseScope = null, List <int> remainingIds = null)
        {
            Scope scope;

            if (baseScope != null)
            {
                scope = baseScope;
            }
            else
            {
                scope = new Scope(properties.ScopeWidth, properties.ScopeHeight)
                {
                    IsFull = false
                };
            }

            AddBlackBorder(scope);

            for (int i = 1; i < scope.Width - 1; i++)
            {
                for (int j = 1; j < scope.Height - 1; j++)
                {
                    if (scope.StructureArray[i, j] == null)
                    {
                        scope.StructureArray[i, j] = new Grain()
                        {
                            Id    = 0,
                            Color = Color.White
                        };
                    }
                }
            }

            if (properties.Inclusions.AreEnable && (properties.Inclusions.CreationTime == InclusionsCreationTime.Beginning))
            {
                var inclusions = new Inclusions(properties.Inclusions, random);
                scope = inclusions.AddInclusionsAtTheBegining(scope);
            }

            var id = 1;

            for (int grainNumber = 0; grainNumber < properties.NumberOfGrains; grainNumber++)
            {
                Point coordinates;
                do
                {
                    coordinates = RandomCoordinates(scope.Width, scope.Height, random);
                }while (scope.StructureArray[coordinates.X, coordinates.Y].Id != 0);

                scope.StructureArray[coordinates.X, coordinates.Y].Color = RandomColor(random);

                if (remainingIds != null)
                {
                    while (remainingIds.Any(i => i.Equals(id)))
                    {
                        id++;
                    }
                    scope.StructureArray[coordinates.X, coordinates.Y].Id = id + 1;
                }
                else
                {
                    scope.StructureArray[coordinates.X, coordinates.Y].Id = grainNumber + 1;
                }
            }

            return(scope);
        }
예제 #19
0
 public void Init()
 {
     _simulationProperties = new SimulationProperties();
 }
        private Scope GenerateSubstructure(List <Dictionary <Point, Grain> > remainingGrains, SimulationProperties properties)
        {
            // prepare base scope with remaining grains
            remainingIds = new List <int>();
            var scope = new Scope(baseScope.Width, baseScope.Height);

            foreach (var grain in remainingGrains)
            {
                foreach (var g in grain)
                {
                    scope.StructureArray[g.Key.X, g.Key.Y] = g.Value;
                    if (remainingIds.IndexOf(g.Value.Id) == -1)
                    {
                        remainingIds.Add(g.Value.Id);
                    }
                }
            }

            Scope prevScope = StructureHelpers.InitCAStructure(properties, random, scope, remainingIds);
            var   newScope  = new Scope(prevScope.Width, prevScope.Height);

            //if (properties.AdvancedMethodType == AdvancedMethodType.AdvancedMC)
            //{
            //    // MC
            //    while (newScope == null || MC.ItertionsPerformed < MCProperties.NumberOfSteps)
            //    {
            //        newScope = MC.Grow(prevScope, remainingIds);
            //        prevScope = newScope;
            //    }
            //}
            //else
            //{
            // CA
            while (newScope == null || !newScope.IsFull)
            {
                newScope  = CA.Grow(prevScope, properties.NeighbourhoodType, properties.GrowthProbability, remainingIds);
                prevScope = newScope;
            }
            //}

            newScope.IsFull = true;
            StructureHelpers.UpdateBitmap(newScope);
            return(newScope);
        }
        private Scope GeterateDualphaseStructure(List <Dictionary <Point, Grain> > remainingGrains, SimulationProperties properties)
        {
            Scope prevScope;

            if (properties.AdvancedMethodType == AdvancedMethodType.AdvancedMC)
            {
                prevScope = StructureHelpers.GenerateEmptyStructure(properties.ScopeWidth, properties.ScopeHeight);
            }
            else
            {
                prevScope = StructureHelpers.InitCAStructure(properties, random);
            }
            var newScope = new Scope(prevScope.Width, prevScope.Height);

            if (properties.AdvancedMethodType == AdvancedMethodType.AdvancedMC)
            {
                // MC
                while (newScope == null || MC.ItertionsPerformed < MCProperties.NumberOfSteps)
                {
                    newScope  = MC.Grow(prevScope);
                    prevScope = newScope;
                }
            }
            else
            {
                // CA
                while (newScope == null || !newScope.IsFull)
                {
                    newScope  = CA.Grow(prevScope, properties.NeighbourhoodType, properties.GrowthProbability);
                    prevScope = newScope;
                }
            }

            // add second phase
            foreach (var grain in remainingGrains)
            {
                foreach (var g in grain)
                {
                    newScope.StructureArray[g.Key.X, g.Key.Y] = g.Value;
                }
            }

            newScope.IsFull = true;
            StructureHelpers.UpdateBitmap(newScope);
            return(newScope);
        }