Skip to contents

Factory function for creating a LearningStrategy

Usage

make_learning_strategy(
  partner_selection,
  interaction,
  model_step = NULL,
  label = "unlabelled"
)

Arguments

partner_selection

Function to select a partner for any focal_agent in the model.

interaction

Function for interaction between any focal_agent and partner in the model.

model_step

Step function for model run after all agents select partner and interact.

label

Character label for this strategy.

Value

A LearningStrategy instance containing social update functions and a metadata-friendly label.

Examples

success_bias_strategy <- make_learning_strategy(
  partner_selection = success_bias_select_teacher,
  interaction = success_bias_interact,
  label = "Success-biased"
)
# Mock a partner selection, interaction, and model step to show custom use.
mock_selection <- function (focal_agent) NULL
mock_interaction <- function (focal_agent, partner, model) NULL
mock_model_step <- function (model) NULL
mock_strategy <- make_learning_strategy(mock_selection, mock_interaction,
                                        mock_model_step, label = "mock")
# Note make_learning_strategy wraps the R6 class constructor:
mock_strategy_2 <- LearningStrategy$new(mock_selection, mock_interaction,
                                        mock_model_step, mock_strategy)