Beispiel #1
0
class Simulation:
    def __init__(self, initial_vaccinated, initial_infected, initial_healthy,
                 virus, resultsfilename):
        '''Set up the initial simulation values'''

        self.virus = virus
        self.initial_infected = initial_infected
        self.initial_healthy = initial_healthy
        self.initial_vaccinated = initial_vaccinated

        self.population = []

        self.population_size = initial_infected + initial_healthy + initial_vaccinated

        self.total_dead = 0
        self.total_vaccinated = initial_vaccinated

        self.file_writer = FileWriter(resultsfilename)

    def create_population(self):
        '''Creates the population (a list of Person objects) consisting of initial infected people, initial healthy non-vaccinated people, and 
        initial healthy vaccinated people. Adds them to the population list'''

        for i in range(self.initial_infected):
            person = Person(False, virus)
            self.population.append(person)

        for i in range(self.initial_healthy):
            person = Person(False, None)
            self.population.append(person)

        for i in range(self.initial_vaccinated):
            person = Person(True, None)
            self.population.append(person)

    def print_population(self):
        '''Prints out every person in the population and their current attributes'''
        for i in self.population:
            print('alive: ', i.is_alive, 'vaccinated: ', i.is_vaccinated,
                  'infection:', i.infection)

    def get_infected(self):
        '''Gets all the infected people from the population and returns them as a list'''
        infected_population = []
        for i in self.population:
            if (i.infection is not None):
                infected_population.append(i)
        return (infected_population)
        #TODO: finish this method

    def simulation_should_continue(self):
        '''Determines whether the simulation should continue.
        If everyone in the population is dead then return False, the simulation should not continue
        If everyone in the population is vaccinated return False
        If there are no more infected people left and everyone is either vaccinated or dead return False
        In all other cases return True'''
        infected_ppl = int()
        alive_ppl = int()
        vacc_ppl = int()
        dead_ppl = int()
        for i in self.population:
            if (i.is_vaccinated):
                vacc_ppl += 1
            if (i.infection is not None):
                infected_ppl += 1
            if (i.is_alive == True):
                alive_ppl += 1
            else:
                dead_ppl += 1

        self.total_vaccinated = vacc_ppl
        if (alive_ppl < 1 or dead_ppl == len(self.population)):
            self.should_continue = False
        if (len(self.population) == vacc_ppl + dead_ppl):
            self.should_continue = False

    def run(self):
        ''' This method should run the simulation until all requirements for ending
        the simulation are met.
        '''

        self.create_population()
        random.shuffle(self.population)

        self.print_population()

        time_step_counter = 0
        self.should_continue = True

        self.file_writer.init_file(self.virus, self.population_size,
                                   self.initial_vaccinated,
                                   self.initial_healthy, self.initial_infected)

        #keep looping until the simulation ends
        while self.should_continue == True:
            self.simulation_should_continue()
            print(self.total_dead, self.total_vaccinated)
            #save the current infected
            old_infected = self.get_infected()
            self.time_step(old_infected)
            #time step will create newly infected people, just determine the survivial of the previous infected people
            self.determine_survival(old_infected)
            time_step_counter += 1

        print(f'The simulation has ended after {time_step_counter} turns.')
        self.file_writer.write_results(time_step_counter, self.total_dead,
                                       self.total_vaccinated)

    def determine_survival(self, infected):
        '''Check if the current infected people survive their infection
        Call the did_survive_infection() method
        if it returns false then the person is no longer alive, does not have an infection and one is added to total dead
        if it returns true then the person no longer has an infection and is vaccinated, one is added to total vaccinated'''
        for infect in infected:
            if (infect.did_survive_infection()):
                self.total_vaccinated += 1
                infect.infection = None
            else:
                self.total_dead += 1
                infect.is_alive = False
                infect.infection = None

        #TODO: finish this method

    def time_step(self, infected):
        ''' For every infected person interact with a random person from the population 10 times'''

        for infected_person in infected:

            for i in range(10):
                index = random.randint(0, len(self.population) - 1)
                sick_dude = self.population[index]
                if (sick_dude != infected_person):
                    self.interaction(infected_person, sick_dude)
                #TODO: get a random index for the population list
                #TODO: using the random index get a random person from the population
                #TODO: call interaction() with the current infected person and the random person

    def interaction(self, infected, random_person):
        '''If the infected person is the same object as the random_person return and do nothing
        if the random person is not alive return and do nothing
        if the random person is vaccinated return and do nothing
        if the random person is not vaccinated:
            generate a random float between 0 and 1
            if the random float is less then the infected person's virus reproduction number then the random person is infected
            othersie the random person is vaccinated and one is added to the total vaccinated'''

        if (random_person.is_alive == False
                or random_person.is_vaccinated == True):
            return
        else:
            if (random_person.is_vaccinated == False):
                num = float(random.randint(0, 100) / 100)
                if (num < self.virus.reproduction_num):
                    random_person.infection = self.virus
                else:
                    random_person.is_vaccinated == True
            return
Beispiel #2
0
class Simulation:
    def __init__(self, initial_vaccinated, initial_infected, initial_healthy,
                 virus, resultsfilename):
        '''Set up the initial simulation values'''

        self.virus = virus
        self.initial_infected = initial_infected
        self.initial_healthy = initial_healthy
        self.initial_vaccinated = initial_vaccinated

        self.population = []

        self.population_size = initial_infected + initial_healthy + initial_vaccinated

        self.total_dead = 0
        self.total_vaccinated = initial_vaccinated

        self.file_writer = FileWriter(resultsfilename)

    def create_population(self):
        '''Creates the population (a list of Person objects) consisting of initial infected people, initial healthy non-vaccinated people, and 
        initial healthy vaccinated people. Adds them to the population list'''

        for _ in range(self.initial_infected):
            person = Person(False, virus)
            self.population.append(person)

        for _ in range(self.initial_healthy):
            person = Person(False, None)
            self.population.append(person)

        for _ in range(self.initial_vaccinated):
            person = Person(True, None)
            self.population.append(person)

    def print_population(self):
        '''Prints out every person in the population and their current attributes'''
        for person in self.population:
            print(f''' Is person alive? {person.is_alive}
                    Is person vaccinated? {person.is_vaccinated}
                    Is person infected? {person.infection is not None}
             ''')

    def get_infected(self):
        '''Gets all the infected people from the population and returns them as a list'''
        infected_people = []
        for person in self.population:
            if person.infection is not None:
                infected_people.append(person)
        return infected_people

    def simulation_should_continue(self):
        '''Determines whether the simulation should continue.
        If everyone in the population is dead then return False, the simulation should not continue
        If everyone in the population is vaccinated return False
        If there are no more infected people left and everyone is either vaccinated or dead return False
        In all other cases return True'''
        if len(self.population) == self.total_dead:
            return False
        elif len(self.population) == self.total_vaccinated:
            return False
        elif len(self.population) == self.total_vaccinated + self.total_dead:
            return False
        else:
            return True

    def run(self):
        ''' This method should run the simulation until all requirements for ending
        the simulation are met.
        '''

        self.create_population()
        random.shuffle(self.population)

        self.print_population()

        time_step_counter = 0

        self.file_writer.init_file(self.virus, self.population_size,
                                   self.initial_vaccinated,
                                   self.initial_healthy, self.initial_infected)

        # keep looping until the simulation ends
        while self.simulation_should_continue():

            # save the current infected
            old_infected = self.get_infected()
            self.time_step(old_infected)
            # time step will create newly infected people, just determine the survivial of the previous infected people
            self.determine_survival(old_infected)

            time_step_counter += 1

        print(f'The simulation has ended after {time_step_counter} turns.')
        self.file_writer.write_results(time_step_counter, self.total_dead,
                                       self.total_vaccinated)

    def determine_survival(self, infected):
        '''Check if the current infected people survive their infection
        Call the did_survive_infection() method
        if it returns false then the person is no longer alive, does not have an infection and one is added to total dead
        if it returns true then the person no longer has an infection and is vaccinated, one is added to total vaccinated'''
        for person in infected:
            if person.did_survive_infection():
                self.total_vaccinated += 1
            else:
                self.total_dead += 1
        return infected

    def time_step(self, infected):
        ''' For every infected person interact with a random person from the population 10 times'''

        for infected_person in infected:
            for _ in range(10):
                random_person = random.choice(self.population)
                self.interaction(infected_person, random_person)

    def interaction(self, infected_person, random_person):
        '''If the infected person is the same object as the random_person return and do nothing
        if the random person is not alive return and do nothing
        if the random person is vaccinated return and do nothing
        if the random person is not vaccinated:
            generate a random float between 0 and 1
            if the random float is less then the infected person's virus reproduction number then the random person is infected
            othersie the random person is vaccinated and one is added to the total vaccinated'''
        if infected_person == random_person:
            return
        elif random_person.is_alive is False:
            return
        elif random_person.is_vaccinated:
            return
        elif random_person.is_vaccinated is False:
            random_float = random.random()
            if random_float < infected_person.infection.reproduction_num:
                random_person.infection is True
            else:
                random_person.is_vaccinated is True
Beispiel #3
0
class Simulation:
    def __init__(self, initial_vaccinated, initial_infected, initial_healthy,
                 virus, resultsfilename):
        '''Set up the initial simulation values'''

        self.virus = virus
        self.initial_infected = initial_infected
        self.initial_healthy = initial_healthy
        self.initial_vaccinated = initial_vaccinated

        self.population = []

        self.population_size = initial_infected + initial_healthy + initial_vaccinated

        self.total_dead = 0
        self.total_vaccinated = initial_vaccinated

        self.file_writer = FileWriter(resultsfilename)

    def create_population(self):
        '''Creates the population (a list of Person objects) consisting of initial infected people, initial healthy non-vaccinated people, and 
        initial healthy vaccinated people. Adds them to the population list'''

        for i in range(self.initial_infected):
            person = Person(False, virus)
            self.population.append(person)

        for i in range(self.initial_healthy):
            person = Person(False, None)
            self.population.append(person)

        for i in range(self.initial_vaccinated):
            person = Person(True, None)
            self.population.append(person)

    def print_population(self):
        '''Prints out every person in the population and their current attributes'''
        #TODO: finish this method
        for person in self.population:

            print("Person is alive {}".format(person.is_alive))
            print("Person is vaccinated {}".format(person.is_vaccinated))
            print()

    def get_infected(self):
        '''Gets all the infected people from the population and returns them as a list'''
        #TODO: finish this method
        all_persons_infected = []
        for person in self.population:
            if person.infection != None and person.is_alive:
                all_persons_infected.append(person)
        return all_persons_infected

    def simulation_should_continue(self):
        '''Determines whether the simulation should continue.
        If everyone in the population is dead then return False, the simulation should not continue
        If everyone in the population is vaccinated return False
        If there are no more infected people left and everyone is either vaccinated or dead return False
        In all other cases return True'''
        #TODO: finish this method
        if self.total_dead == self.population_size:
            print('test')
            return False

        elif self.total_vaccinated == self.population_size:
            print('test1')
            return False

        elif len(self.get_infected()) == 0:
            print('test2')
            return False

        else:
            print('test3')
            return True

    def run(self):
        ''' This method should run the simulation until all requirements for ending
        the simulation are met.
        '''

        self.create_population()
        random.shuffle(self.population)

        self.print_population()
        #print("Infected", self.get_infected())

        time_step_counter = 0
        should_continue = True

        self.file_writer.init_file(self.virus, self.population_size,
                                   self.initial_vaccinated,
                                   self.initial_healthy, self.initial_infected)

        #keep looping until the simulation ends
        while self.simulation_should_continue():

            print("hello")
            #save the current infected
            old_infected = self.get_infected()
            self.time_step(old_infected)
            #time step will create newly infected people, just determine the survivial of the previous infected people
            self.determine_survival(old_infected)
            time_step_counter += 1

        print(f'The simulation has ended after {time_step_counter} turns.')
        self.file_writer.write_results(time_step_counter, self.total_dead,
                                       self.total_vaccinated)

    def determine_survival(self, infected):
        '''Check if the current infected people survive their infection
        Call the did_survive_infection() method
        if it returns false then the person is no longer alive, does not have an infection and one is added to total dead
        if it returns true then the person no longer has an infection and is vaccinated, one is added to total vaccinated'''
        #TODO: finish this method
        for infected_person in infected:
            if infected_person.did_survive_infection() == False:
                infected_person.infection = None
                infected_person.is_alive = False
                self.total_dead += 1

            elif infected_person.did_survive_infection() == True:
                infected_person.infection = None
                infected_person.is_vaccinated == True
                self.total_vaccinated += 1

    def time_step(self, infected):
        ''' For every infected person interact with a random person from the population 10 times'''

        for infected_person in infected:

            for i in range(10):
                #TODO: get a random index for the population list
                # random_index = randint(0, len(self.population) - 1)

                #TODO: using the random index get a random person from the population
                random_person = random.choice(self.population)

                #TODO: call interaction() with the current infected person and the random person
                self.interaction(infected_person, random_person)

    def interaction(self, infected_person, random_person):
        '''If the infected person is the same object as the random_person return and do nothing
        if the random person is not alive return and do nothing
        if the random person is vaccinated return and do nothing
        if the random person is not vaccinated:
            generate a random float between 0 and 1
            if the random float is less then the infected person's virus reproduction number then the random person is infected
            othersie the random person is vaccinated and one is added to the total vaccinated'''
        #TODO: finish this method
        # for random_person in infected:
        if infected_person is random_person:

            return

        if random_person.is_alive == False:

            return

        if random_person.is_vaccinated == True:
            # print("test5")
            return

        #elif random_person.is_vaccinated == False:
        else:
            random_float = randrange(0.0, 1.0)
            # print("test5")
            if random_float < infected_person.infection.reproduction_num:
                random_person.infection = infected_person.infection
                # print("test6")

            else:
                random_person.is_vaccinated = True
                self.total_vaccinated += 1
class Simulation:

    def __init__(self, initial_vaccinated, initial_infected, initial_healthy, virus, resultsfilename):
        '''Set up the initial simulation values'''

        self.virus = virus
        self.initial_infected = initial_infected
        self.initial_healthy = initial_healthy
        self.initial_vaccinated = initial_vaccinated

        self.population = []

        self.population_size = initial_infected + initial_healthy + initial_vaccinated


        self.total_dead = 0
        self.total_vaccinated = initial_vaccinated

        self.file_writer = FileWriter(resultsfilename)


    def create_population(self):
        '''Creates the population (a list of Person objects) consisting of initial infected people, initial healthy non-vaccinated people, and
        initial healthy vaccinated people. Adds them to the population list'''

        for i in range(self.initial_infected):
        	each_person = Person(False, virus)
        	self.population.append(each_person)

        for i in range(self.initial_healthy):
            each_person = Person(False, None)
            self.population.append(each_person)

        for i in range(self.initial_vaccinated):
            each_person = Person(True, None)
            self.population.append(each_person)

    def print_population(self):
        '''Prints out every person in the population and their current attributes'''
        num = 0
        for each_person in self.population:
            if each_person.infection != None:
                infection = True
            else:
                infection = False
            print(f"id: {str(num)} alive: {str(each_person.is_alive)} infected: {str(infection)} vacinated: {str(each_person.is_vaccinated)}.")
            num += 1

    def get_infected(self):
        '''Gets all the infected people from the population and returns them as a list'''
        infected = []
        for each_person in self.population:
            if each_person.infection != None:
                infected.append(each_person)
                return infected


    def simulation_should_continue(self):
        '''Determines whether the simulation should continue.
        If everyone in the population is dead then return False, the simulation should not continue
        If everyone in the population is vaccinated return False
        If there are no more infected people left and everyone is either vaccinated or dead return False
        In all other cases return True'''
        #TODO: finish this method
        for each_person in self.population:
            if each_person.is_alive == False or each_person.is_vaccinated == True:
                return False
            else:
                return True


    def run(self):
        ''' This method should run the simulation until all requirements for ending
        the simulation are met.
        '''

        self.create_population()
        random.shuffle(self.population)

        self.print_population()

        time_step_counter = 0

        self.file_writer.init_file(self.virus, self.population_size, self.initial_vaccinated, self.initial_healthy, self.initial_infected)

        #keep looping until the simulation ends
        while self.simulation_should_continue():

            #save the current infected
            old_infected = self.get_infected()
            self.time_step(old_infected)
            #time step will create newly infected people, just determine the survivial of the previous infected people
            self.determine_survival(old_infected)

            time_step_counter += 1

        print(f'The simulation has ended after {time_step_counter} turns.')
        self.file_writer.write_results(time_step_counter, self.total_dead, self.total_vaccinated)

    def determine_survival(self, infected):
        for each_person in infected:
            if each_person.did_survive_infection() == False:
                self.total_dead += 1
            else:
                each_person.is_vaccinated = True
                self.total_vaccinated += 1



    def time_step(self, infected):
        ''' For every infected person interact with a random person from the population 10 times'''

        for infected_person in infected:

            for _ in range(10):
                #TODO: get a random index for the population list
                index = random.randint(0, len(self.population)) - 1
                #TODO: using the random index get a random person from the population
                random_person = self.population[index]
                #TODO: call interaction() with the current infected person and the random person
                self.interaction(infected_person, random_person)


    def interaction(self, infected_person, random_person):
        '''If the infected person is the same object as the random_person return and do nothing
        if the random person is not alive return and do nothing
        if the random person is vaccinated return and do nothing
        if the random person is not vaccinated:
            generate a random float between 0 and 1
            if the random float is less then the infected person's virus reproduction number then the random person is infected
            otherwise the random person is vaccinated and one is added to the total vaccinated'''
        #TODO: finish this method
        if infected_person == random_person or random_person.is_alive == False or random_person.is_vaccinated == True:
            pass
        elif random_person.is_vaccinated == False:
            num = random.random()
            if num < self.virus.reproduction_num:
                random_person.infection = self.virus
                return random_person
            else:
                random_person.is_vaccinated = True
                return random_person
Beispiel #5
0
class Simulation:
    def __init__(self, initial_vaccinated, initial_infected, initial_healthy,
                 virus, resultsfilename):
        '''Set up the initial simulation values'''

        self.virus = virus
        self.initial_infected = initial_infected
        self.initial_healthy = initial_healthy
        self.initial_vaccinated = initial_vaccinated

        self.population = []

        self.population_size = initial_infected + initial_healthy + initial_vaccinated

        self.total_dead = 0
        self.total_vaccinated = initial_vaccinated

        self.file_writer = FileWriter(resultsfilename)

    def create_population(self):
        '''Creates the population (a list of Person objects) consisting of initial infected people, initial healthy non-vaccinated people, and 
        initial healthy vaccinated people. Adds them to the population list'''

        for i in range(self.initial_infected):
            person = Person(False, virus)
            self.population.append(person)

        for i in range(self.initial_healthy):
            person = Person(False, None)
            self.population.append(person)

        for i in range(self.initial_vaccinated):
            person = Person(True, None)
            self.population.append(person)

    def print_population(self):
        '''Prints out every person in the population and their current attributes'''
        #TODO: finish this method

    def get_infected(self):
        '''Gets all the infected people from the population and returns them as a list'''
        #TODO: finish this method

    def simulation_should_continue(self):
        '''Determines whether the simulation should continue.
        If everyone in the population is dead then return False, the simulation should not continue
        If everyone in the population is vaccinated return False
        If there are no more infected people left and everyone is either vaccinated or dead return False
        In all other cases return True'''
        #TODO: finish this method

    def run(self):
        ''' This method should run the simulation until all requirements for ending
        the simulation are met.
        '''

        self.create_population()
        random.shuffle(self.population)

        self.print_population()

        time_step_counter = 0
        should_continue = True

        self.file_writer.init_file(self.virus, self.population_size,
                                   self.initial_vaccinated,
                                   self.initial_healthy, self.initial_infected)

        #keep looping until the simulation ends
        while self.simulation_should_continue():

            #save the current infected
            old_infected = self.get_infected()
            self.time_step(old_infected)
            #time step will create newly infected people, just determine the survivial of the previous infected people
            self.determine_survival(old_infected)

            time_step_counter += 1

        print(f'The simulation has ended after {time_step_counter} turns.')
        self.file_writer.write_results(time_step_counter, self.total_dead,
                                       self.total_vaccinated)

    def determine_survival(self, infected):
        '''Check if the current infected people survive their infection
        Call the did_survive_infection() method
        if it returns false then the person is no longer alive, does not have an infection and one is added to total dead
        if it returns true then the person no longer has an infection and is vaccinated, one is added to total vaccinated'''
        #TODO: finish this method

    def time_step(self, infected):
        ''' For every infected person interact with a random person from the population 10 times'''

        for infected_person in infected:

            for i in range(10):
                #TODO: get a random index for the population list
                #TODO: using the random index get a random person from the population
                #TODO: call interaction() with the current infected person and the random person
                pass

    def interaction(self, infected, random_person):
        '''If the infected person is the same object as the random_person return and do nothing
Beispiel #6
0
class Simulation:  
    def __init__(self, initial_vaccinated, initial_infected, initial_healthy, virus, resultsfilename):
        # 'Set up the initial simulation values’
        self.virus = virus
        self.initial_infected = initial_infected
        self.initial_healthy = initial_healthy
        self.initial_vaccinated = initial_vaccinated
        self.population = []
        self.population_size = initial_infected + initial_healthy + initial_vaccinated
        self.total_dead = 0
        self.total_vaccinated = initial_vaccinated
        self.file_writer = FileWriter(resultsfilename)
        #Ben S.


    def create_population(self):    
        # ‘’'Creates the population (a list of Person objects) consisting of initial infected people, initial healthy non-vaccinated people, and 
        # initial healthy vaccinated people. Adds them to the population list’‘'
        
        for i in range(self.initial_infected):
            person = Person(False, virus)
            self.population.append(person)

        for i in range(self.initial_healthy):
            person = Person(False, None)
            self.population.append(person)

        for i in range(self.initial_vaccinated):
            person = Person(True, None)
            self.population.append(person)
            #Ben  S.

            
    def print_population(self):
        # ‘’'Prints out every person in the population and their current attributes’‘'
        #TODO: finish this method
        for person in self.population:
            return person

    
    def get_infected(self):
        # ‘’'Gets all the infected people from the population and returns them as a list’‘'
        #TODO: finish this method
        infected = list()
        for person in self.population:
            if person.is_alive and person.infection:
                infected.append(person)
            return infected

    
    def simulation_should_continue(self):   #
        # ‘’'Determines whether the simulation should continue.
        # If everyone in the population is dead then return False, the simulation should not continue
        # If everyone in the population is vaccinated return False
        # If there are no more infected people left and everyone is either vaccinated or dead return False
        # In all other cases return True’‘'
        # #TODO: finish this method
        vaccinated = 0
        total_infected = 0
        for person in self.population:
            if person.is_alive == False:
                self.total_dead += 1
            if person.is_alive and person.is_vaccinated:
                vaccinated += 1
            if person.infected is not None:
                amount_infected += 1
        if total_infected == 0 and (self.total_dead == self.population_size or self.total_vaccinated):
            return False
        elif self.total_vaccinated == self.population_size:
            return False
        elif self.total_dead == self.population_size:
            return False
        else:
            return True
        # Ben S.
    
    def run(self):
        # ‘’' This method should run the simulation until all requirements for ending the simulation are met'''
        self.create_population()
        random.shuffle(self.population)

        self.print_population()
        
        time_step_counter = 0
        should_continue = True

        self.file_writer.init_file(self.virus, self.population_size, self.initial_vaccinated, self.initial_healthy, self.initial_infected)
        
        #keep looping until the simulation ends
        while self.simulation_should_continue():
           
            #save the current infected
            old_infected = self.get_infected()
            self.time_step(old_infected)
            #time step will create newly infected people, just determine the survivial of the previous infected people
            self.determine_survival(old_infected)
            
            time_step_counter += 1

        print(f’The Simulation has ended after {time_step_counter} turns.‘)
        self.file_writer.write_results(time_step_counter, self.total_dead, self.total_vaccinated)
Beispiel #7
0
class Simulation:
    def __init__(self, initial_vaccinated, initial_infected, initial_healthy,
                 virus, resultsfilename):
        '''Set up the initial simulation values'''

        self.virus = virus
        self.initial_infected = initial_infected
        self.initial_healthy = initial_healthy
        self.initial_vaccinated = initial_vaccinated

        self.population = []

        self.population_size = initial_infected + initial_healthy + initial_vaccinated

        self.total_dead = 0
        self.total_vaccinated = initial_vaccinated

        self.file_writer = FileWriter(resultsfilename)

    def create_population(self):
        '''Creates the population (a list of Person objects) consisting of
        initial infected people, initial healthy non-vaccinated people, and
        initial healthy vaccinated people. Adds them to the population list'''

        for i in range(self.initial_infected):
            person = Person(False, virus)
            self.population.append(person)

        for i in range(self.initial_healthy):
            person = Person(False, None)
            self.population.append(person)

        for i in range(self.initial_vaccinated):
            person = Person(True, None)
            self.population.append(person)

    def print_population(self):
        '''Prints out every person in the population and their current
        attributes'''
        count = 0
        for person in self.population:
            alive_or_not = None
            vac_or_not = None
            if person.is_alive:
                alive_or_not = "alive"
            else:
                alive_or_not = "not alive"
            if person.is_vaccinated:
                vac_or_not = "vaccinated"
            else:
                vac_or_not = "not vaccinated"
            if person.infection is None:
                infected_or_not = "not infected"
            else:
                infected_or_not = "infected"
            print(f"Person {count} is {alive_or_not}, is {vac_or_not}")
            print(f"  and is {infected_or_not}")
            count += 1
            # TODO: test this method

    def get_infected(self):
        '''Gets all the infected people from the population and returns them
        as a list'''
        infected_people = []
        for person in self.population:
            if person.infection is not None:
                infected_people.append(person)
        return infected_people
        # TODO: test this method

    def simulation_should_continue(self):
        '''Determines whether the simulation should continue.
        If everyone in the population is dead then return False, the simulation
        should not continue
        If everyone in the population is vaccinated return False
        If there are no more infected people left and everyone is either
        vaccinated or dead return False
        In all other cases return True'''
        infected = self.get_infected()
        if self.population_size == self.total_dead:
            return False
        elif self.population_size == self.total_vaccinated:
            return False
        elif len(
                infected
        ) == 0 and self.population_size == self.total_vaccinated + self.total_dead:
            return False
        else:
            return True
        # TODO: test this method

    def run(self):
        ''' This method should run the simulation until all requirements for
        ending the simulation are met.
        '''

        self.create_population()
        random.shuffle(self.population)

        self.print_population()

        time_step_counter = 0
        should_continue = True

        self.file_writer.init_file(self.virus, self.population_size,
                                   self.initial_vaccinated,
                                   self.initial_healthy, self.initial_infected)

        # keep looping until the simulation ends
        while self.simulation_should_continue():

            # save the current infected
            old_infected = self.get_infected()
            self.time_step(old_infected)
            # time step will create newly infected people, just determine the
            # survivial of the previous infected people
            self.determine_survival(old_infected)

            time_step_counter += 1

        print(f'The simulation has ended after {time_step_counter} turns.')
        self.file_writer.write_results(time_step_counter, self.total_dead,
                                       self.total_vaccinated)

    def determine_survival(self, infected):
        '''Check if the current infected people survive their infection
        Call the did_survive_infection() method
        if it returns false then the person is no longer alive, does not have
        an infection and one is added to total dead
        if it returns true then the person no longer has an infection and is
        vaccinated, one is added to total vaccinated'''

        for sickie in infected:
            survived = sickie.did_survive_infection()
            if not sickie.did_survive_infection():
                sickie.infection = None
                self.total_dead += 1
                sickie.is_alive = False
            elif sickie.did_survive_infection():
                sickie.is_vaccinated = True
                self.total_vaccinated += 1
                self.infection = None
        # TODO: test this method

    def time_step(self, infected):
        ''' For every infected person interact with a random person from the
        population 10 times'''

        for infected_person in infected:

            for i in range(10):
                # get a random index for the population list
                select = random.randint(0, int(self.population_size) - 1)
                # TODO: using the random index get a random person from the
                # population
                random_person = self.population[select]
                # TODO: call interaction() with the current infected person and
                # the random person
                self.interaction(infected_person, random_person)
                pass

    def interaction(self, infected, random_person):
        '''
        -If the infected person is the same object as the random_person
        return and do nothing
        -if the random person is not alive return and do nothing
        -if the random person is vaccinated return and do nothing
        -if the random person is not vaccinated:
            generate a random float between 0 and 1
            if the random float is less then the infected person's virus
            reproduction number then the random person is infected
            othersie the random person is vaccinated and one is added to the
            total vaccinated'''
        if infected == random_person:
            return
        elif not random_person.is_alive:
            return
        elif random_person.is_vaccinated:
            return
        elif not random_person.is_vaccinated:
            comparitor = random.uniform(0, 1)
            if comparitor < self.virus.reproduction_num:
                random_person.infection = self.virus
            else:
                random_person.is_vaccinated = True
                self.total_vaccinated += 1