public Carnivore(Random rng, Position pos = null, IAnimalParams customParameters = null) : base(rng, pos) { if (customParameters is null) { Params = new CarnivoreParams(); } else { Params = customParameters; } var norm = new MathNet.Numerics.Distributions.Normal(Params.BirthWeight, Params.BirthSigma); Weight = norm.Sample(); }
public void OverloadParameters(int index, string type, IAnimalParams parameters) { if (type.ToUpper() == "HERBIVORE" || type.ToUpper() == "H") { if (parameters.GetType().Name != "HerbivoreParams") { throw new Exception($"Wrong Parameter type ({parameters.GetType()}) for Herbivore"); } Herbivores[index].Params = parameters; return; } if (type.ToUpper() == "CARNIVORE" || type.ToUpper() == "C") { if (parameters.GetType().Name != "CarnivoreParams") { throw new Exception($"Wrong Parameter type ({parameters.GetType()}) for Carnivore"); } Carnivores[index].Params = parameters; return; } throw new Exception($"Unable to overload parameters. \nInput was: INDEX - {index} TYPE - {type} PARAMETERS - {parameters}"); }
public void OverloadParameters(IAnimal animal, IAnimalParams parameters) { int writemorecodehere; animal.Params = parameters; }