public IHttpActionResult PutPopulationType(string id, PopulationType populationType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != populationType.PopulationType1) { return(BadRequest()); } db.Entry(populationType).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PopulationTypeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public Population(Civilization civlization, Upkeep upkeep, Beliefs beliefs, PopulationType startingType) { Civilization = civlization; Upkeep = upkeep; Beliefs = beliefs; PopulationType = startingType; }
public IHttpActionResult PostPopulationType(PopulationType populationType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.PopulationTypes.Add(populationType); try { db.SaveChanges(); } catch (DbUpdateException) { if (PopulationTypeExists(populationType.PopulationType1)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = populationType.PopulationType1 }, populationType)); }
void SetupPopulatedTilesArray() { populatedTiles = new PopulationType[columns][]; for (int i = 0; i < populatedTiles.Length; i++) { populatedTiles[i] = new PopulationType[rows]; } }
private void SetupPopulatedTilesArray() { populatedTiles = new PopulationType[roomWidth][]; for (int i = 0; i < populatedTiles.Length; i++) { populatedTiles[i] = new PopulationType[roomHeight]; } }
public IHttpActionResult GetPopulationType(string id) { PopulationType populationType = db.PopulationTypes.Find(id); if (populationType == null) { return(NotFound()); } return(Ok(populationType)); }
public ResourceSegment(PopulationType type, PlayerBoard board) { var msg = "Storage: {0}[placeholder]</br>Production: {1}</br>Next Production: {2}"; msg = String.Format(msg, board.GetStorage(type), board.GetProduction(type), board.GetNextProduction(type)); if (type == PopulationType.Money) msg= msg.Replace("[placeholder]", "</br>Production less upkeep: " + (board.GetProduction(PopulationType.Money) - board.GetUpkeep()).ToString()); else msg = msg.Replace("[placeholder]", ""); Description = msg; Name = type.ToString(); }
public Faction(FactionSdo sdo) { Religions = new Dictionary <string, int>(); EntitiesWithFluff = new List <Entity>(); PopType = sdo.PopType; FactionReputation = sdo.FactionReputation; Citizens = new List <Entity>(); EntitiesWithFluff = new List <Entity>(); Name = sdo.Name; Population = sdo.Population; Leader = EntitySdo.ConvertToEntity(sdo.Leader); if (Leader == null) { Debug.Log($@"Leader missing for faction {Name}"); } foreach (var id in sdo.CitizenIds) { if (!WorldData.Instance.Entities.ContainsKey(id)) { continue; } var citizen = WorldData.Instance.Entities[id]; citizen.Faction = this; Citizens.Add(citizen); } foreach (var id in sdo.EntitiesWithFluffIds) { if (!WorldData.Instance.Entities.ContainsKey(id)) { continue; } var entity = WorldData.Instance.Entities[id]; EntitiesWithFluff.Add(entity); } if (Leader != null && !WorldData.Instance.Entities.ContainsKey(Leader.Id)) { WorldData.Instance.Entities[Leader.Id] = Leader; } if (!EntitiesWithFluff.Contains(Leader)) { EntitiesWithFluff.Add(Leader); } }
public IHttpActionResult DeletePopulationType(string id) { PopulationType populationType = db.PopulationTypes.Find(id); if (populationType == null) { return(NotFound()); } db.PopulationTypes.Remove(populationType); db.SaveChanges(); return(Ok(populationType)); }
public void RunEvolution() { GeneticAlgorithmParameters parameters = new GeneticAlgorithmParameters( populationSize: 10, mutationRate: 0.3, mutationAmplitute: 0.5); //PopulationType specimenType = PopulationType.Arithmetic1D; PopulationType specimenType = PopulationType.Arithmetic15D; PopulationSetting populationSetting; switch (specimenType) { case (PopulationType.Arithmetic1D): populationSetting = new Arithmetic1DPopulation((s) => (Math.Pow(s.Genes[0] - 10, 2) + 5)); break; case (PopulationType.Arithmetic2D): populationSetting = new Arithmetic2DPopulation((s) => (Math.Pow((s.Genes[0] + 2 * s.Genes[1] - 7), 2) + Math.Pow((2 * s.Genes[0] + s.Genes[1] - 5), 2))); break; case (PopulationType.Arithmetic15D): populationSetting = new Arithemtic15DPopulation((s) => GetResultOfFitFunctionForMultidimensionalFucntion(s)); break; default: throw new Exception("Тип особей, для которых запускается симуляция, не задан! Завершение работы..."); } geneticAlgorithm = new GeneticAlgorithm(parameters, populationSetting); for (int i = 0; i < 5000; i++) { geneticAlgorithm.NewGeneration(); //Console.WriteLine(); //Console.WriteLine("Поколение: " + geneticAlgorithm.GenerationNum); //ShowPopulation(geneticAlgorithm.CurrentGeneration); //ShowBestInGeneration(geneticAlgorithm.CurrentGeneration, populationSetting); } ShowBestOfAllTime(geneticAlgorithm.allGenerations, populationSetting); }
public bool HasAdvancedTechnology(PopulationType type) { return HasTechnology("Advanced " + type.ToString()); }
public PopulationSquare(PopulationType type) { Type = type; }
private void LogNetProductionBefore(PopulationType popType) { _beforeLog = GetProduction(popType); if(popType==PopulationType.Money) _beforeLog -= GetUpkeep(); }
private void LogNetProductionAfter(PopulationType popType) { var after = GetProduction(PopulationType.Money); if(popType==PopulationType.Money) after -= GetUpkeep(); AddLogLine("Net " + popType+ " Production: " + SignedNumber(_beforeLog, after)); }
private void AdjustPop(PopulationType type, int adjust) { LogNetProductionBefore(type); PopulationsCubes[type] += adjust; LogNetProductionAfter(type); }
public void SetStorage(PopulationType type, int value) { Storage[type] = value; }
public void RemovePop(PopulationType type) { AdjustPop(type, -1); }
public int GetStorage(PopulationType type) { return Storage[type]; }
public bool CanSupportPopulation(PopulationType type) { return((double)this.MaxPopulationMod[(int)type] > 0.0); }
public String GetCurrentStorageDescription(PopulationType type) { return String.Format("{0} Storage: {1}", type, GetStorage(type)); }
public String GetCurrentProductionDescription(PopulationType type) { return String.Format("Net {0} Production: {1}", type.ToString(), GetNetProduction(type)); }
public void AdjustStorage(PopulationType type, int adjustment) { var before = Storage[type]; Storage[type] += adjustment; var after = Storage[type]; AddLogLine(type.ToString() + " Storage: " + SignedNumber(before, after)); }
public void AddPopulationCube(PopulationType type) { if (type == PopulationType.Unknown) throw new NotImplementedException(); PopulationsCubes[type]++; }
public int GetNetProduction(PopulationType t) { if (t == PopulationType.Money) { return GetProduction(PopulationType.Money) - GetUpkeep(); } else return GetProduction(t); }
public Job(PopulationType jobType, int totalSlots) { JobType = jobType; TotalJobSlots = totalSlots; }
public int GetProduction(PopulationType type) { return GetProductionLevel(PopulationsCubes[type]); }
private void PickPopulationType() { var roll = Random.Range(0, 100); PopType = roll <= 40 ? PopulationType.MixedSpecies : PopulationType.Monospecies; }