env <- simmer()
traj <- trajectory() %>%
set_global("path", 1, mod="+", init=-1) %>%
log_(function() paste("Path", get_global(env, "path"), "selected")) %>%
branch(
function() get_global(env, "path"), continue=c(TRUE, FALSE),
trajectory() %>%
log_("following path 1"),
trajectory() %>%
log_("following path 2")) %>%
log_("continuing after the branch (path 0)")
env %>%
add_generator("dummy", traj, at(0:2)) %>%
run() %>% invisible
Run the code above in your browser using DataCamp Workspace