run_sim: Run a simulation

Description Usage Arguments Value Examples

View source: R/simulation.R

Description

Run a simulation

Usage

1

Arguments

x

A simulation created with agent_sim()

debug

Optionally, print calculation step info to the console to aid in debugging task errors

Value

The original simulation, with a populated simulation$history$log

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#Example simulation in which each agent prints its own id to the console
init_pop <- tibble::tibble(
  id = c(1:50),
  x = runif(50, 0, 1),
  y = runif(50, 0, 1)
  )

agent_task <- function(agent, population){
  print(agent$id)
  agent
  }

sim <- agents_from_param_table(init_pop) %>%
  set_task(agent_task) %>%
  agent_sim(100) %>%
  run_sim()

neilcharles/agentSim documentation built on Oct. 31, 2020, 11:23 a.m.