colinsheppard / time

A NetLogo extension that brings date/time utilities and discrete event scheduling to NetLogo
12 stars 13 forks source link

time:schedule-event-shuffled is useless when using with non-agentsets #45

Closed MHX792 closed 8 years ago

MHX792 commented 8 years ago

Hello! First of all: Thank you for this great extension!

I am scheduling a task for several turtles to be executed at the same tick like so: time:schedule-event-shuffled turtle turtle-id task task-name ticks + 1 Unfortunately the tasks get executed in the order they have been added to the schedule and not in a shuffled order as intended.

Any solutions for this?

colinsheppard commented 8 years ago

Hi there, glad to know you're using the extension!

If you want the turtles to execute in random order, you need to call "time:schedule-event-shuffled" just once and pass the entire agent set as the first argument. The way you are currently using this command appears that you are calling it several times on individual turtles. So in the example code provided with the extension, I demonstrate like this:

create-turtles 5
time:schedule-event-shuffled turtles task go-forward 1

If you don't want all of the turtles, you can use "with" to do a subset, something like this:

create-turtles 5
time:schedule-event-shuffled turtles with [who < 3] task go-forward 1

Good luck!

MHX792 commented 8 years ago

Thanks, but this unfortunately doesn't solve my problem. At the time of creating the turtles I don't know yet which tasks should be executed by which turtle. After every tick there will be turtles added to the time:schedule-list and I want them to be executed in a random order. My suggestions: everytime time:schedule-event-shuffled is used on a turtle or turtleset the time:schedule-list should be extended and randomized.