示例#1
0
        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 //
        }
示例#2
0
		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();

		}