village {villager} | R Documentation |
Village
Description
This is an object that represents the state of a village at a particular time.
Details
This class acts as a type of record that holds the values of the different village variables. This class can be subclassed to include more variables that aren't present.
Methods
initialize()
Creates a new village
propagate()
Advances the village a single time step
set_initial_state()
Initializes the initial state of the village
Public fields
name
An optional name for the village
initial_condition
A function that sets the initial state of the village
current_state
The village's current state
previous_state
The village's previous state
models
A list of functions or a single function that should be run at each timestep
model_data
Optional data that models may need
agent_mgr
The manager that handles all of the agents
resource_mgr
The manager that handles all of the resources Initializes a village
Methods
Public methods
Method new()
This method is meant to set the variables that are needed for a village to propagate through time.
Usage
village$new( name, initial_condition, models = list(), agent_class = villager::agent, resource_class = villager::resource )
Arguments
name
An optional name for the village
initial_condition
A function that gets called on the first time step
models
A list of functions or a single function that should be run at each time step
agent_class
The class that's being used to represent agents
resource_class
The class being used to describe the resources Propagates the village a single time step
Method propagate()
Usage
village$propagate(current_step)
Arguments
current_step
The current time step
Details
This method is used to advance the village a single time step. It should NOT be used to set initial conditions. See the set_initial_state method.
Returns
None Runs the user defined function that sets the initial state of the village
Method set_initial_state()
Runs the initial condition model
Usage
village$set_initial_state()
Method clone()
The objects of this class are cloneable with this method.
Usage
village$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.