protected override void Harvest()
 {
     log.WriteLine("Run Mode1 harvesting ...");
     ClearHarvested();
     GenerateNewPrescriptions(sosielData);
     foreach (var agent in Agents)
     {
         var areas = sheParameters.AgentToManagementAreaList
                     .First(map => map.Agent.Equals(agent.Id)).ManagementAreas
                     .Select(ma => Areas.First(area => area.Key.Equals(ma)).Value);
         foreach (var area in areas)
         {
             var key = HarvestResults.GetKey(ModeId, agent, area);
             //Debugger.Launch();
             if (sosielData.SelectedDecisions.ContainsKey(key))
             {
                 var selectedPrescriptionNames = sosielData.SelectedDecisions[key];
                 log.WriteLine($"\t\t{key}: decisions: {string.Join(",", selectedPrescriptionNames)}");
                 var selectedPrescriptions = _prescriptions.Where(
                     p => selectedPrescriptionNames.Contains(p.Name));
                 var harvestManager =
                     new HarvestManager(area, selectedPrescriptions, _harvestPrescriptionName, _siteCohorts);
                 _harvested[key] = harvestManager.Harvest();
                 log.WriteLine($"\t\t{key}: harvested {harvestManager.HarvestedSitesNumber} sites");
             }
             else
             {
                 log.WriteLine($"\t\t{key}: harvested 0 sites (no decision found)");
             }
         }
     }
     log.WriteLine("Mode 1: Harvesting finished.");
 }
        protected override HarvestResults AnalyzeHarvestingResult()
        {
            var results = new HarvestResults();

            foreach (var agent in Agents)
            {
                var areas = sheParameters.AgentToManagementAreaList
                            .First(map => map.Agent == agent.Id).ManagementAreas
                            .Select(ma => Areas.First(area => area.Key == ma).Value);
                foreach (var area in areas)
                {
                    var key = HarvestResults.GetKey(1, agent, area);
                    results.ManagementAreaBiomass[key]         = 0;
                    results.ManagementAreaMaturityPercent[key] = 0;

                    double manageAreaMaturityProportion = 0;
                    foreach (var stand in area.ManagementArea)
                    {
                        double standMaturityProportion = 0;
                        foreach (var site in stand)
                        {
                            double siteBiomass  = 0;
                            double siteMaturity = 0;

                            foreach (var species in PlugIn.ModelCore.Species)
                            {
                                var cohorts = _siteCohorts[site][species];
                                if (cohorts == null)
                                {
                                    continue;
                                }
                                double siteSpeciesMaturity = 0;
                                foreach (var cohort in cohorts)
                                {
                                    siteBiomass += cohort.Biomass;
                                    if (cohort.Age >= PlugIn.ModelCore.Species[species.Name].Maturity)
                                    {
                                        siteSpeciesMaturity += cohort.Biomass;
                                    }
                                }
                                siteMaturity += siteSpeciesMaturity;
                            }

                            var siteMaturityProportion = Math.Abs(siteBiomass) < 0.0001
                                ? 0 : (siteMaturity / siteBiomass) * 2;
                            results.ManagementAreaBiomass[key] += siteBiomass;
                        }
                        standMaturityProportion      /= stand.Count();
                        manageAreaMaturityProportion += standMaturityProportion;
                    }

                    manageAreaMaturityProportion              /= area.ManagementArea.StandCount;
                    results.ManagementAreaBiomass[key]         = results.ManagementAreaBiomass[key] / 100 * PlugIn.ModelCore.CellArea;
                    results.ManagementAreaHarvested[key]       = _harvested[key] * PlugIn.ModelCore.CellArea;
                    results.ManagementAreaMaturityPercent[key] = 100 * manageAreaMaturityProportion;
                }
            }
            return(results);
        }
Example #3
0
        public Sale CreateNewSale(Employee employee, Guid tableAreaId, Guid tableId, Guid terminlaAreaId, Guid terminalId, int covers)
        {
            var tableArea    = Areas.First(tArea => tArea.Id == tableAreaId);
            var table        = tableArea.GetTable(tableId);
            var terminalArea = Areas.First(termArea => termArea.Id == terminlaAreaId);

            return(terminalArea.CreateANewSale(employee, table, terminalId, covers));
        }
Example #4
0
        public OperationResult Update(AreaModel model)
        {
            var entity = Areas.First(t => t.Id == model.Id);

            entity.Name        = model.Name;
            entity.Description = model.Description;
            entity.ParentId    = model.ParentId;

            AreaRepository.Update(entity);
            return(new OperationResult(OperationResultType.Success, "更新成功"));
        }
 private void ClearHarvested()
 {
     foreach (var agent in Agents)
     {
         PlugIn.ModelCore.UI.WriteLine($"ClearHarvested: agent {agent.Id}");
         var areas = sheParameters.AgentToManagementAreaList
                     .First(map => map.Agent.Equals(agent.Id))
                     .ManagementAreas.Select(ma => Areas.First(area => area.Key.Equals(ma)).Value);
         foreach (var area in areas)
         {
             var key = HarvestResults.GetKey(1, agent, area);
             _harvested[key] = 0.0;
         }
     }
 }
        protected override HarvestResults AnalyzeHarvestingResult()
        {
            // Report all zeros
            var results = new HarvestResults();

            foreach (var agent in Agents)
            {
                var areas = sheParameters.AgentToManagementAreaList
                            .First(map => map.Agent == agent.Id).ManagementAreas
                            .Select(ma => Areas.First(area => area.Key == ma).Value);
                foreach (var area in areas)
                {
                    var key = HarvestResults.GetKey(ModeId, agent, area);
                    results.ManagementAreaBiomass[key]         = 0;
                    results.ManagementAreaMaturityPercent[key] = 0;
                    results.ManagementAreaBiomass[key]         = 0;
                    results.ManagementAreaHarvested[key]       = 0;
                    results.ManagementAreaMaturityPercent[key] = 0;
                }
            }
            return(results);
        }
Example #7
0
        public void StartServer()
        {
            //load the config first...
            Config = _getMudConfigFromFile();


            //get things started
            //load up the areas...
            Console.WriteLine("Loading areas...");
            Areas = Repo.LoadAreas( Config );

            Console.WriteLine("Loading accounts...");
            Accounts = Repo.LoadAccounts( Config );

            Console.WriteLine("Loading help files...");
            Helps = Repo.LoadHelps( Config );

            Console.WriteLine("Loading command files...");
            Commands = Repo.LoadCommands( Config );

            Console.WriteLine("Prepping JInt environment...");
            Engine = new Engine(cfg => {
                cfg.DebugMode();
               // cfg.AddObjectConverter(new PlayerCharacterConverter()); //From Character to JsValue
                });
            Engine.SetValue("HELPS", Helps.ToArray());
            Engine.SetValue("DO_COMMAND", new Action<PlayerCharacter, string>(InputParser.ParsePlaying));
            Engine.SetValue("__log", new Action<object>(Console.WriteLine));
            Engine.SetValue("ADMIN_RESTART", new Action(StartServer));
            Engine.SetValue("MUD", this);

            //Calculate this just once...
            StartingRoom = Areas.First( a => a.Rooms.Exists( r => r.Vnum == Config.RoomVnumForNewPlayers ) )
                    .Rooms.First( r => r.Vnum == Config.RoomVnumForNewPlayers );
            
        }
Example #8
0
 private Area this[Guid areaId]
 {
     get { return(Areas.First(a => a.Id == areaId)); }
 }
 public override string ToString()
 {
     return(OverworldTeleport.ToString() + "->" + Areas.First().Map.MapId.ToString() + (Done ? " - Done" : ""));
 }