Class Host

Inheritance Relationships

Base Type

Derived Types

Class Documentation

class Host : public Organism

Subclassed by Bacterium, EfficientHost, PGGHost

Public Functions

Host(emp::Ptr<emp::Random> _random, emp::Ptr<SymWorld> _world, emp::Ptr<SymConfigBase> _config, double _intval = 0.0, emp::vector<emp::Ptr<Organism>> _syms = {}, emp::vector<emp::Ptr<Organism>> _repro_syms = {}, double _points = 0.0)

The constructor for the host class

~Host()

Input: None

Output: None

Purpose: To delete the memory used by a host’s symbionts when the host is deleted.

Host(const Host&) = default

Input: None

Output: None

Purpose: To force a copy constructor to be generated by the compiler.

Host(Host&&) = default

Input: None

Output: None

Purpose: To force a move constructor to be generated by the compiler

Host() = default

Input: None

Output: None

Purpose: To tell the compiler to use its default generated variants of the constructor

Host &operator=(const Host&) = default

Input: None

Output: None

Purpose: To force a copy assignment operator to be generated by the compiler.

Host &operator=(Host&&) = default

Input: None

Output: None

Purpose: To force a move assignment operator to be generated by the compiler.

bool operator==(const Host &other) const

Input: An object of host to be compared to the current host.

Output: To boolean representing if thing1 == &thing2

Purpose: To override the bool operator == to return (thing1 == &thing2)

bool operator!=(const Host &other) const

Input: An object of host, and the address of the thing it is being compared to.

Output: To boolean representing if *thing1 == thing2

Purpose: To override the bool operator != to return !(*thing1 == thing2)

std::string const GetName()

Input: None

Output: Name of class as string, Host

Purpose: To know which subclass the object is

double GetIntVal() const

Input: None

Output: The double representing host’s interaction value

Purpose: To get the double representing host’s interaction value

emp::vector<emp::Ptr<Organism>> &GetSymbionts()

Input: None

Output: A vector of pointers to the organisms that are the host’s syms.

Purpose: To get the vector containing pointers to the host’s symbionts.

emp::vector<emp::Ptr<Organism>> &GetReproSymbionts()

Input: None

Output: A vector of pointers to the organisms that are the host’s repro syms.

Purpose: To get the vector containing pointers to the host’s repro syms.

double GetPoints()

Input: None

Output: The double representing a host’s points.

Purpose: To get the host’s points.

double GetResInProcess()

Input: None

Output: The double representing res_in_process

Purpose: To get the value of res_in_process

bool IsHost()

Input: None

Output: The bool representing if an organism is a host.

Purpose: To determine if an organism is a host.

void SetIntVal(double _in)

Input: A double representing the host’s new interaction value.

Output: None

Purpose: To set a host’s interaction value.

void SetSymbionts(emp::vector<emp::Ptr<Organism>> _in)

Input: A vector of pointers to organisms that will become a host’s symbionts.

Output: None

Purpose: To set a host’s symbionts to the input vector of organisms.

void SetPoints(double _in)

Input: A double representing a host’s new point value.

Output: None

Purpose: To set a host’s points.

void ClearSyms()

Input: None

Output: None

Purpose: To clear a host’s symbionts.

void ClearReproSyms()

Input: None

Output: None

Purpose: To clear a host’s repro symbionts.

void SetDead()

Input: None

Output: None

Purpose: To kill a host.

void SetResInProcess(double _in)

Input: The double to be set as res_in_process

Output: None

Purpose: To set the value of res_in_process

bool GetDead()

Input: None

Output: boolean

Purpose: To determine if a host is dead.

int GetAge()

Input: None

Output: an int representing the current age of the Host

Purpose: To get the Host’s age.

void SetAge(int _in)

Input: An int of what age the Host should be set to

Output: None

Purpose: To set the Host’s age for testing purposes.

void GrowOlder()

Input: None

Output: None

Purpose: Increments age by one and kills it if too old.

double StealResources(double _intval)

Input: The interaction value of the symbiont that is eligible to steal resources from the host.

Output: The double representing the amount of resources that are actually stolen from the host.

Purpose: To determine if a host’s symbiont is eligible to steal resources from the host.

void AddPoints(double _in)

Input: The double representing the number of points to be incremented onto a host’s points.

Output: None

Purpose: To increment a host’s points by the input value.

int AddSymbiont(emp::Ptr<Organism> _in)

Input: The pointer to the organism that is to be added to the host’s symbionts.

Output: The int describing the symbiont’s position ID, or 0 if it did not successfully get added to the host’s list of symbionts.

Purpose: To add a symbionts to a host’s symbionts

bool SymAllowedIn()

Input: None

Output: A bool representing if a symbiont will be allowed to enter a host.

Purpose: To determine if a symbiont will be allowed into a host. If phage exclusion is off, this function will always return true. If phage exclusion is on, then there is a 1/2^n chance of a new phage being allowed in, where n is the number of existing phage.

void AddReproSym(emp::Ptr<Organism> _in)

Input: A pointer to the organism to be added to the host’s symbionts.

Output: None

Purpose: To add a repro sym to the host’s symbionts.

bool HasSym()

Input: None

Output: A bool representing if a host has any symbionts.

Purpose: To determine if a host has any symbionts, though they might be corpses that haven’t been removed yet.

emp::Ptr<Organism> MakeNew()

Input: None.

Output: A new host with same properties as this host.

Purpose: To avoid creating an organism via constructor in other methods.

emp::Ptr<Organism> Reproduce()

Input: None.

Output: A new host baby of the current host, mutated.

Purpose: To create a new baby host and reset this host’s points to 0.

void Mutate()

Input: None

Output: None

Purpose: To mutate a host’s interaction value. This is called on newly generated hosts to allow for evolution to occur.

void DistribResources(double resources)

Input: The double representing the number of resources to be distributed to the host and its symbionts and the position of the host in the world.

Output: None

Purpose: To distribute resources to a host and its symbionts. In the event that the host has no symbionts, the host gets all resources not allocated to defense or given to absent partner. Otherwise, the resource is split into equal chunks for each symbiont

double HandleEctosymbiosis(double resources, size_t location)

Input: The total resources recieved by the host and its location in the world.

Output: The resources remaining after the host maybe does ectosymbiosis.

Purpose: To handle ectosymbiosis.

bool GetDoEctosymbiosis(size_t location)

Input: The location of this host in the world.

Output: A bool value representing whether this host should interact with a parallel sym

Purpose: To determine whether a host should interact with a parallel sym

void DistribResToSym(emp::Ptr<Organism> sym, double sym_piece)

Input: The sym to whom resources are distributed and the resources it might recieve.

Output: None

Purpose: To distribute resources between sym and host depending on their interaction values.

void Process(emp::WorldPosition pos)

Input: The size_t value representing the location of the host.

Output: None

Purpose: To process the host, meaning determining eligibility for reproduction, checking for vertical transmission, removing dead syms, and processing alive syms.

Protected Attributes

double interaction_val = 0

Purpose: Represents the interaction value between the host and symbiont. A negative interaction value represent antagonism, while a positive one represents mutualism. Zero is a neutral value.

int age = 0

Purpose: Represents the number of updates the host has lived through; at birth is set to 0.

emp::vector<emp::Ptr<Organism>> syms = {}

Purpose: Represents the set of symbionts belonging to a host. This can be set with SetSymbionts(), and symbionts can be added with AddSymbiont(). This can be cleared with ClearSyms()

emp::vector<emp::Ptr<Organism>> repro_syms = {}

Purpose: Represents the set of in-progress “reproductive” symbionts belonging to a host. These are symbionts that aren’t yet active. Symbionts can be added with AddReproSymb(). This can be cleared with ClearSyms()

double points = 0

Purpose: Represents the resource points possessed by a host. This is what hosts must collect to reproduce.

double res_in_process = 0

Purpose: Represents the resources that could be in the process of being stolen.

emp::Ptr<emp::Random> random = NULL

Purpose: Represents an instance of random.

emp::Ptr<SymWorld> my_world = NULL

Purpose: Represents the world that the hosts are living in.

emp::Ptr<SymConfigBase> my_config = NULL

Purpose: Represents the configuration settings for a particular run.

bool dead = false

Purpose: Represents if a host is alive. This is set to true when a host is killed.