private void Configure(CoViD.CL.Locations locations) { // ATTENTION: do not create a new Rnd. Use the static variable. var rnd = Person.Rnd; var antibodyGrowth = ((decimal)rnd.Next(10, 40)) / (decimal)1000; var antibodyDecay = ((decimal)rnd.Next(0, 12)) / (decimal)1000; var virusGrowth = ((decimal)rnd.Next(20, 40)) / (decimal)1000; var mobility = (byte)rnd.Next(0, 255); this.Configure(locations, virusGrowth, antibodyGrowth, antibodyDecay, mobility); }
/// <summary> /// /// </summary> /// <param name="locations"></param> /// <param name="virusGrowth"></param> /// <param name="antibodyGrowth"></param> /// <param name="antibodyDecay"></param> /// <param name="deadThreshold"></param> /// <param name="mobility"></param> public Person( CoViD.CL.Locations locations, Vi.Types.Percentage virusGrowth, Vi.Types.Percentage antibodyGrowth, Vi.Types.Percentage antibodyDecay, Vi.Types.Percentage deadThreshold, byte mobility ) { this.Configure(locations, virusGrowth, antibodyGrowth, antibodyDecay, mobility); }
private void Initialize() { this.InitializeStatusStrip(); var radius = (int)udRadius.Value; var people = 1; byte steps = (byte)udSteps.Value; this.TicksMax = (int)udTicks.Value; CoViD.CL.Person.IsolationThreshold = (byte)this.udIsolation.Value; this.regionL.SetXY(radius, "People"); this.regionR.SetXY(radius, "Contamination"); var tv = (this.TicksMax / 1); this.xyViruses.SetXY( 0, tv, "0", tv.ToText(), "Ticks", 0, 1, "0", 1.ToText(), "" ); // ------------------------------------------------------------------------------------- // var population = new CoViD.CL.Population(); for (int i = 0; i < people; i++) { var locations = new CoViD.CL.Locations(radius, steps); var person = new CoViD.CL.Person(locations); person.Sneeze += this.Person_Sneeze; person.Inhale += this.Person_Inhale; population.Add(person); } // ------------------------------------------------------------------------------------- // var hospitals = new CoViD.CL.Hospitals() { new CoViD.CL.Hospital(new CoViD.CL.Point(radius, radius), 500) }; this.Grid = new CoViD.CL.Grid(radius, population, hospitals); this.Grid.Remove += this.Grid_Remove; this.Grid.Add += this.Grid_Add; // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // // Simulate the sneeze of the first infected person. This creates a contaminated grid this.Grid.Contaminate(1000, new CoViD.CL.Point(0, 0)); // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // }
private void ud_Click(object sender, EventArgs e) { var virusGrowth = (decimal)(udVirusesGrowth.Value / 100); var antibodyGrowth = (decimal)(udAntibodiesGrowth.Value / 100); var antibodyDecay = (decimal)(udAntibodiesDecay.Value / 100); var deadThreshold = (decimal)0.95; byte mobility = 100; var locations = new CoViD.CL.Locations(); var person = new CoViD.CL.Person(locations, virusGrowth, antibodyGrowth, antibodyDecay, deadThreshold, mobility); Loop(person); }
/// <summary> /// /// </summary> /// <param name="locations"></param> /// <param name="virusGrowth"></param> /// <param name="antibodyGrowth"></param> /// <param name="antibodyDecay"></param> /// <param name="mobility"></param> private void Configure(CoViD.CL.Locations locations, Vi.Types.Percentage virusGrowth, Vi.Types.Percentage antibodyGrowth, Vi.Types.Percentage antibodyDecay, byte mobility) { this.Locations = locations; this.SIR = SIRStates.Susceptible; this.State = States.Susceptible; this.AntibodyGrowth = antibodyGrowth; this.AntibodyDecay = antibodyDecay; this.VirusGrowth = virusGrowth; this.DeadThreshold = ((float)Person.Rnd.Next(72, 100, 3)) / (float)100; //this.DeadThreshold = (float)((float)Person.Rnd.Next(50000, 100000) / 100000F); this.Age = Person.Rnd.Next(0, 100, 4); this.AntibodyGrowthRatio = (decimal)1 + antibodyGrowth.Value; this.AntibodyDecayRatio = (decimal)1 - antibodyDecay; this.VirusGrowthRatio = (decimal)1 + virusGrowth.Value; this._VirusGrowthRatio = this.VirusGrowthRatio; this.Mobility = mobility; }
/// <summary> /// /// </summary> /// <param name="locations"></param> public Person(CoViD.CL.Locations locations) { this.Configure(locations); }
private void Initialize() { this.InitializeStatusStrip(); var radius = (int)this.INICoViD.Radius; ; var people = this.INICoViD.People; byte steps = this.INICoViD.Steps; ; this.TicksMax = this.INICoViD.Ticks; ; this.tsPeople.Text = people.ToText(); this.tsIsolation.Text = this.INICoViD.Isolation.ToText(); this.regionL.SetXY(radius, "People"); this.regionR.SetXY(radius, "Contamination"); this.xySIR.SetXY( 0, this.TicksMax, "0", this.TicksMax.ToText(), "Ticks", 0, people, "0", people.ToText(), "" ); int deltaMax = 10; /// (int)Math.Round((double)(people / (double)10)); this.xyDSIR.SetXY( 0, this.TicksMax, "0", this.TicksMax.ToText(), "Ticks", -deltaMax, deltaMax, (-deltaMax).ToText(), deltaMax.ToText(), "" ); var y2Max = 4 * (radius / 100) * (radius / 100); this.xyContaminated.SetXY( 0, this.TicksMax, "0", this.TicksMax.ToText(), "Ticks", 0, y2Max, "0", y2Max.ToText(), "Contaminated grids" ); this.xyPerformances.SetXY( 0, this.TicksMax, "0", this.TicksMax.ToText(), "Ticks", 0, 150, "0", 150.ToText(), "Milliseconds" ); // ------------------------------------------------------------------------------------- // this.regionL.Cartesian.Clear(); this.regionR.Cartesian.Clear(); Application.DoEvents(); // ------------------------------------------------------------------------------------- // var population = new CoViD.CL.Population(); var locations0 = new CoViD.CL.Locations(radius, steps); var p0 = new CoViD.CL.Person(locations0); for (int i = 0; i < people; i++) { var locations = new CoViD.CL.Locations(radius, steps); var person = new CoViD.CL.Person(locations); person.Sneeze += this.Person_Sneeze; person.Inhale += this.Person_Inhale; population.Add(person); } // ------------------------------------------------------------------------------------- // var hospitals = new CoViD.CL.Hospitals(){ new CoViD.CL.Hospital(new CoViD.CL.Point(radius, radius), 500) }; this.Grid = new CoViD.CL.Grid(radius, population, hospitals); this.Grid.Remove += this.Grid_Remove; this.Grid.Add += this.Grid_Add; this.Contaminate(); }