Ejemplo n.º 1
0
        //this is the main method:
        public void UpdateVirusesStateOfThePatient(PatientStatistics o_PatientStatistics)
        {
            GenerateReproducmentProbability(); // determine what is the real probability by the parameters of number of viruses compared to the number of cells times the given growth constant
            int NumberOfVirusesThatReproduced = 0;

            foreach (Virus virus in VirusPopulation)
            {
                bool DoesTheVirusReproduced = virus.UpdateSelfStateAndCheckWhetherToReproduce(ReproducmentProbability, VirusDisconnectionProbability);
                if (DoesTheVirusReproduced)
                {
                    NumberOfVirusesThatReproduced++;
                }
            }
            // at the end of this phase, we add the new viruses that have been reproduced:
            for (int i = 0; i < NumberOfVirusesThatReproduced; i++)
            {
                VirusPopulation.Add(new Virus());
            }


            // at the end, lets make a new record for our statistics object:
            PatientDayRecord patientDayRecord = new PatientDayRecord(CalculateNumberOfAliveViruses(), CalculateNumberOfDeadViruses());

            o_PatientStatistics.DaysRecords.Add(patientDayRecord);
        }
Ejemplo n.º 2
0
        public void UpdateVirusesStateOfThePatient(PatientStatistics o_PatientStatistics)
        {
            GenerateReproducmentProbability();                   // determine what is the real probability by the parameters of number of viruses compared to the number of cells times the given growth constant
            List <Virus> ReproducedViruses = new List <Virus>(); // the viruses that have been reproduced in one (this) phase

            foreach (Virus virus in VirusPopulation)
            {
                Virus newVirus = virus.UpdateSelfStateAndCheckWhetherToReproduce(ReproducmentProbability);
                if (newVirus != null)
                {
                    ReproducedViruses.Add(newVirus);
                }
            }
            // at the end of this phase, we add the new viruses that have been reproduced:
            if (ReproducedViruses.Count > 0)
            {
                VirusPopulation.AddRange(ReproducedViruses);
            }
            // a day (iteration) has passed, so:
            ADayPass();
            // at the end, lets make a new record for our statistics object:
            PatientDayRecord patientDayRecord = new PatientDayRecord(CalculateNumberOfAliveViruses(), CalculateNumberOfDeadViruses());

            o_PatientStatistics.DaysRecords.Add(patientDayRecord);
        }