This is an object that represents a villager (agent).
as_table()Represents the current state of the agent as a tibble
get_age()Returns age in terms of years
get_gender()get_days_sincelast_birth()Get the number of days since the agent last gave birth
initialize()Create a new agent
propagate()Runs every day
Create a new agent
identifierA unique identifier that can be used to identify and find the agent
first_nameThe agent's first name
last_nameThe agent's last name
ageThe agent's age
mother_idThe identifier of the agent's mother
father_idThe identifier of the agent's father
professionThe agent's profession
partnerThe identifier of the agent's partner
genderThe agent's gender
aliveA boolean flag that represents whether the villager is alive or dead
childrenA list of children identifiers
healthA percentage value of the agent's current health
new()Used to created new agent objects.
agent$new(
identifier = NA,
first_name = NA,
last_name = NA,
age = 0,
mother_id = NA,
father_id = NA,
partner = NA,
children = vector(mode = "character"),
gender = NA,
profession = NA,
alive = TRUE,
health = 100
)identifierThe agent's identifier
first_nameThe agent's first name
last_nameThe agent's last name
ageThe age of the agent
mother_idThe identifier of the agent's mother
father_idThe identifier of the agent' father
partnerThe identifier of the agent's partner
childrenAn ordered list of of the children from this agent
genderThe gender of the agent
professionThe agent's profession
aliveBoolean whether the agent is alive or not
healthA percentage value of the agent's current health
A new agent object A function that returns true or false whether the villager dies This is run each day
is_alive()agent$is_alive()A boolean whether the agent is alive (true for yes) Gets the number of days from the last birth. This is also the age of the most recently born agent
get_days_since_last_birth()agent$get_days_since_last_birth()The number of days since last birth Connects a child to the agent. This method ensures that the 'children' vector is ordered.
add_child()agent$add_child(child)childThe agent object representing the child
None Returns a data.frame representation of the agent
as_table()I hope there's a more scalable way to do this in R; Adding every new attribute to this function isn't practical
agent$as_table()The village_state holds a copy of all of the villagers at each timestep; this method is used to turn the agent properties into the object inserted in the village_state.
A data.frame representation of the agent
clone()The objects of this class are cloneable with this method.
agent$clone(deep = FALSE)deepWhether to make a deep clone.
This class acts as an abstraction for handling villager-level logic. It can take a number of functions that run at each timestep. It also has an associated