Beispiel #1
0
 public PatientArrival(string patientId, string hospitalId, IDisease disease, DateTime arrivalTime)
 {
     PatientId = patientId;
       HospitalId = hospitalId;
       Disease = disease;
       ArrivalTime = arrivalTime;
 }
Beispiel #2
0
    // https://neherlab.org/covid19/about
    public void CalculateInfectionRates(IDisease disease)
    {
        susceptibleChange  = -disease.beta * susceptible * infected / population;
        exposedChange      = disease.beta * susceptible * infected / population - exposed / disease.tl;
        infectedChange     = exposed / disease.tl - infected / disease.ti;
        hospitalizedChange = (1 - disease.m) * infected / disease.ti + (1 - disease.f) * critical / disease.tc - hospitalized / disease.th;
        criticalChange     = disease.c * hospitalized / disease.th - critical / disease.tc;
        recoveredChange    = disease.m * infected / disease.ti + (1 - disease.c) * hospitalized / disease.th;
        deadChange         = disease.f * critical / disease.tc;

        susceptible  += susceptibleChange;
        exposed      += exposedChange;
        infected     += infectedChange;
        hospitalized += hospitalizedChange;
        critical     += criticalChange;
        recovered    += recoveredChange;
        dead         += deadChange;

        susceptible  = Mathf.Clamp(susceptible, 0, population);
        exposed      = Mathf.Clamp(exposed, 0, population);
        infected     = Mathf.Clamp(infected, 0, population);
        hospitalized = Mathf.Clamp(hospitalized, 0, population);
        critical     = Mathf.Clamp(critical, 0, population);
        recovered    = Mathf.Clamp(recovered, 0, population);
        dead         = Mathf.Clamp(dead, 0, population);

        susceptibleHistory.Add(susceptible);
        infectedHistory.Add(exposed + infected + hospitalized + critical);
        recoveredHistory.Add(recovered);
        deadHistory.Add(dead);
    }
Beispiel #3
0
 public PatientArrival(string patientId, string hospitalId, IDisease disease, DateTime arrivalTime)
 {
     PatientId   = patientId;
     HospitalId  = hospitalId;
     Disease     = disease;
     ArrivalTime = arrivalTime;
 }
Beispiel #4
0
        private static string GetName(IDisease disease)
        {
            var name =
                $"{disease.Name.Secondary?.Ru} {disease.Name.PrimaryPrefix?.Ru}{disease.Name.Primary?.Ru} {disease.Name.Subject?.Ru}";

            return(name);
        }
Beispiel #5
0
        public void HoldDisease(IDisease disease)
        {
            if (!_diseases.Contains(disease))
            {
                _diseases.Add(disease);
            }

            Changed?.Invoke(this, EventArgs.Empty);
        }
        public void Infect(IDisease disease)
        {
            var currentProcess = _diseaseList.SingleOrDefault(x => x.Disease == disease);

            if (currentProcess is null)
            {
                currentProcess = new DiseaseProcess(disease);
                _diseaseList.Add(currentProcess);
            }
        }
Beispiel #7
0
        public DiseaseSymptomCondition(IDisease disease, DiseaseSymptom symptom)
        {
            if (disease is null)
            {
                throw new ArgumentNullException(nameof(disease));
            }

            Symptom = symptom ?? throw new ArgumentNullException(nameof(symptom));

            _diseases = new List<IDisease>();

            HoldDisease(disease);
        }
        private static void AddDiseaseEffectForSymptom(
            IConditionsModule сonditionModule,
            IDisease disease,
            DiseaseSymptom symptom)
        {
            var currentSymptomEffect = сonditionModule.Items.OfType <DiseaseSymptomCondition>()
                                       .SingleOrDefault(x => x.Symptom == symptom);

            if (currentSymptomEffect is null)
            {
                // При создании эффекта уже фиксируется болезнь, которая его удерживает.
                currentSymptomEffect = new DiseaseSymptomCondition(disease, symptom);
                сonditionModule.Add(currentSymptomEffect);
            }
            else
            {
                currentSymptomEffect.HoldDisease(disease);
            }
        }
        private static void UpdatePowerDown(
            IConditionsModule сonditionModule,
            IDisease disease,
            DiseaseSymptom[] symptoms,
            float currentPower,
            float symptomPowerSegment)
        {
            var activeSymptomCount = (int)Math.Floor(currentPower / symptomPowerSegment);

            // Начинаем снимать все эффекты, которые за пределами количества.

            var symptomLowerIndex = activeSymptomCount;

            for (var i = symptomLowerIndex; i < symptoms.Length; i++)
            {
                var currentSymptom = symptoms[i];
                RemoveDiseaseEffectForSimptom(сonditionModule, disease, currentSymptom);
            }
        }
Beispiel #10
0
        private void CountInfectionInScore(IActor targetActor, IDisease disease)
        {
            if (targetActor is MonsterPerson)
            {
                // Для монстров не считаем достижения.
                return;
            }

            // Сервис подсчёта очков - необязательная зависимость.
            if (ScoreManager is null)
            {
                return;
            }

            // Каждую болезнь фиксируем только один раз
            if (!ScoreManager.Scores.Diseases.Any(x => x == disease))
            {
                ScoreManager.Scores.Diseases.Add(disease);
            }
        }
        private static void RemoveDiseaseEffectForSimptom(
            IConditionsModule сonditionModule,
            IDisease disease,
            DiseaseSymptom symptom)
        {
            var currentSymptomEffect = сonditionModule.Items.OfType <DiseaseSymptomCondition>()
                                       .SingleOrDefault(x => x.Symptom == symptom);

            if (currentSymptomEffect is null)
            {
                // Просто игнорируем этот эффект.
                // Ткущий метод может вызываться несколько раз и для симптомов, которые ушли в предыдущих итерациях.
                return;
            }

            currentSymptomEffect.ReleaseDisease(disease);

            if (!currentSymptomEffect.Diseases.Any())
            {
                сonditionModule.Remove(currentSymptomEffect);
            }
        }
Beispiel #12
0
        private static void UpdatePowerUp(IEffectsModule personEffects, IDisease disease, DiseaseSymptom[] symptoms,
                                          float currentPower, float symptomPowerSegment)
        {
            if (currentPower <= 0.25f)
            {
                // Симптомы начинаю проявляться после 25% силы болезни.
                return;
            }

            // Рассчитываем количество симптомов, которые должны быть при текущей силе болезни.

            var activeSymptomCount = (int)Math.Ceiling((currentPower - 0.25f) / symptomPowerSegment);

            // Начинаем проверять, есть ли эффекты на все эти симптомы
            // или добавлены ли болезни симптомов в список болезней эффектов.

            for (var i = 0; i < activeSymptomCount; i++)
            {
                var currentSymptom = symptoms[i];
                AddDiseaseEffectForSymptom(personEffects, disease, currentSymptom);
            }
        }
Beispiel #13
0
    public virtual void UpdateTick(IDisease disease)
    {
        ticks++;
        if (ticks == 50)
        {
            ticks = 0;
            seconds++;
            foreach (var state in states)
            {
                state.CalculateInfectionRates(disease);
            }

            foreach (var state in states)
            {
                if (random.NextDouble() <= state.infected * chanceOfInfectedToTravel * chanceOfTravellerToInfect)
                {
                    state.neighbouring[random.Next(state.neighbouring.Count)].Infect();
                }
            }
            daysText.text = string.Format("Tag: {0}", Mathf.Floor(seconds / (Constants.timeScale * 2f)));


            currentBudget += (int)(satisfaction * (population / 1000000f));
            satisfaction  -= 1f;
            satisfaction   = Mathf.Clamp(satisfaction, 0f, Mathf.Infinity);

            //Debug.Log(string.Format("Current Budget: {0}", (Constants.timeScale * 2f)));

            susceptibleHistory.Add(susceptible);
            infectedHistory.Add(exposed + infected + hospitalized + critical);
            recoveredHistory.Add(recovered);
            deadHistory.Add(dead);

            graph.UpdateLines();
        }
    }
Beispiel #14
0
        public void ReleaseDisease(IDisease disease)
        {
            _diseases.Remove(disease);

            Changed?.Invoke(this, EventArgs.Empty);
        }
Beispiel #15
0
 public DiseaseProcess(IDisease disease)
 {
     Disease = disease ?? throw new ArgumentNullException(nameof(disease));
 }
Beispiel #16
0
 public void AddDisease(IDisease disease)
 {
     _diseases.Add(disease);
 }
        public void RemoveDisease(IDisease disease)
        {
            var currentProcess = _diseaseList.SingleOrDefault(x => x.Disease == disease);

            _diseaseList.Remove(currentProcess);
        }
Beispiel #18
0
 private static void SetMonsterInfection(IPerson monster, IDisease disease)
 {
     monster.GetModule <IDiseaseModule>().Infect(disease);
 }