def reweigh_pathogen_for_city(self):
        """
        Reweighs properties of pathogens for the city in which they are
        :return: city specific pathogen weights as dict whereby key is city name and value is pathogen object
        """

        tmp_dict = {}
        for city in self.game.cities_list:
            if city.outbreak:
                pathogen = self.weighted_pathogens[city.outbreak.pathogen.name]

                pat_scale = Scalegroup({
                    'lethality': pathogen.lethality,
                    'infectivity': pathogen.infectivity,
                    'mobility': pathogen.mobility,
                    'duration': pathogen.duration
                })
                # Collect city features
                anti_vac = city.has_event(events.AntiVaccinationism)
                vacc_dep = bool(city.deployed_vaccines)
                med_dep = bool(city.deployed_medication)
                city_hyg = city.hygiene

                # The higher the more mobile
                city_mob = city.mobility
                # The higher the longer the outbreak is alive
                outbreak_lifetime = h_utils.since_round_percentage(
                    self.game.round, city)

                # If outbreak_lifetime exists longer then the duration becomes more important because kill is sooner
                pat_scale.increase_on_dependency(
                    'duration', outbreak_lifetime * pat_scale.influence_lvl2)
                # Increase mobility of the city, increases mobility of the pathogen
                pat_scale.increase_on_dependency(
                    'mobility', city_mob * pat_scale.influence_lvl2)

                if vacc_dep:
                    pat_scale.sg['infectivity'] = 0
                else:
                    pat_scale.increase_on_dependency(
                        'infectivity',
                        int(anti_vac) * pat_scale.influence_lvl1)
                    pat_scale.decrease_on_dependency(
                        'infectivity', city_hyg * pat_scale.influence_lvl2)
                    pat_scale.decrease_on_dependency(
                        'infectivity',
                        int(med_dep) * pat_scale.influence_lvl2)

                pat_scale.rescale()

                # Add pathogen to dict
                tmp_dict[city.name] = Pathogen(pathogen.name,
                                               pat_scale.sg['infectivity'],
                                               pat_scale.sg['mobility'],
                                               pat_scale.sg['duration'],
                                               pat_scale.sg['lethality'],
                                               transformation=False)

        return tmp_dict
Example #2
0
    def __init__(self, pathogen: dict, round: int):
        """Initializes a new BT object

        Arguments:
            pathogen {dict} -- Dictionary of the Pathogen Object
            round {int} -- Round when this event occurred
        """
        self.pathogen = Pathogen.from_dict(pathogen)
        super().__init__('bioTerrorism', round)
Example #3
0
    def __init__(self, pathogen: dict, sinceRound: int):
        """Creates a new object

        Arguments:
            pathogen {dict} -- Pathogen medicated against
            sinceRound {int} -- [description]
        """
        self.pathogen = Pathogen.from_dict(pathogen)
        super().__init__("vaccineAvailable", sinceRound)
Example #4
0
    def __init__(self, pathogen: dict, round: int):
        """Creates a new object

        Arguments:
            pathogen {dict} -- Pathogen medicated against
            round {int} -- Round the pathogen has been encountered in
        """
        self.pathogen = Pathogen.from_dict(pathogen)
        super().__init__("pathogenEncountered", round)
Example #5
0
    def __init__(self, pathogen: dict, round: int):
        """Creates a new object

        Arguments:
            pathogen {dict} -- Pathogen medicated against
            round {int} -- [description]
        """
        self.pathogen = Pathogen.from_dict(pathogen)
        super().__init__("medicationDeployed", round)
    def __init__(self, pathogen: dict, sinceRound: int, untilRound):
        """Creates a new object

        Arguments:
            pathogen {dict} -- Pathogen medicated
            sinceRound {int} -- Round started
            untilRound {[type]} -- Round it will be finished
        """
        self.pathogen = Pathogen.from_dict(pathogen)
        self.untilRound = untilRound
        super().__init__("medicationInDevelopment", sinceRound)
Example #7
0
    def __init__(self, pathogen, sinceRound, prevalence):
        """Creates a new object

        Arguments:
            pathogen {Pathogen} -- Pathogen Object
            sinceRound {int} -- Number of Round in which the outbreak started
            prevalence {float} -- Fraction as float between 0 and 1, % of infected citizens in the city
        """
        self.pathogen = Pathogen.from_dict(pathogen)
        self.prevalence = prevalence
        super().__init__("outbreak", sinceRound)
    def __init__(self, pathogen: dict, sinceRound: int, untilRound):
        """Create a new object

        Arguments:
            pathogen {dict} -- Pathogen to vax against
            sinceRound {int} -- Started development
            untilRound {[type]} -- When it will be finished
        """
        self.pathogen = Pathogen.from_dict(pathogen)
        self.untilRound = untilRound
        super().__init__("vaccineInDevelopment", sinceRound)
    def reweigh_pathogens(self):
        """
        Reweighs the properties of pathogens according to the game state
        :return: dict of pathogen names associated to a reweighed pathogen object
        """

        tmp_dict = {}
        for pathogen in self.relevant_pathogens:
            pat_scale = Scalegroup({
                'lethality': 1,
                'infectivity': 1,
                'mobility': 1,
                'duration': 1
            })

            # Apply base bias (lethality stays the same)
            pat_scale.apply_bias('infectivity', 0.9)
            pat_scale.apply_bias('duration', 0.8)
            pat_scale.apply_bias('mobility', 0.6)

            # Collect Game Feature
            infected_citz = self.game.get_percentage_of_infected(pathogen)
            immune_citz = self.game.get_percentage_of_immune(pathogen)
            # Influences
            pat_scale.increase_on_dependency(
                'infectivity', infected_citz * pat_scale.influence_lvl3)
            pat_scale.increase_on_dependency(
                'lethality', infected_citz * pat_scale.influence_lvl3)
            pat_scale.decrease_on_dependency(
                'infectivity', immune_citz * pat_scale.influence_lvl2)

            pat_scale.increase_on_dependency(
                'mobility', pathogen.infectivity * pat_scale.influence_lvl3)
            # Infectivity is more important the longer the duration
            pat_scale.increase_on_dependency(
                'infectivity', pathogen.duration * pat_scale.influence_lvl3)
            # The shorter the duration the more important is lethality
            pat_scale.increase_on_dependency('lethality',
                                             (1 - pathogen.duration) *
                                             pat_scale.influence_lvl3)

            pat_scale.rescale()
            tmp_dict[pathogen.name] = Pathogen(pathogen.name,
                                               pat_scale.sg['infectivity'],
                                               pat_scale.sg['mobility'],
                                               pat_scale.sg['duration'],
                                               pat_scale.sg['lethality'],
                                               transformation=False)

        return tmp_dict