1

I have been using Netlogo to try to develop a small conceptual model for a volunteer transportation pickup service. The whole concept is that every predetermined amount of time, the turtle agents are "assigned a trip". This is symbolised in the model by their color changing to show one of 4 possible trip types. This "trip" then comes to an end when either the turtle covers the average distance for each type of trip or the number of service hours (the same for each) is depleted. After the trip is complete, the turtle color then changes back to an inactive state (white) and if they have more service hours the assignment is redone. The problem I'm having issues replicating is the trip assignment portion. I have my turtles moving in an arbitrary manner and also a portion of code that is recording their distance as they do so.

I am using this bit of code so far in my go step to achieve what I want:

every buffer-time [ ask drivers [
    
    
    let trip-purpose-prob random-float 1
    if trip-purpose-prob <= 0.34 [ set color red ]
    if trip-purpose-prob > 0.34 and trip-purpose-prob < 0.70 [ set color yellow]
  if trip-purpose-prob >= 0.70 and trip-purpose-prob < 0.96 [ set color green]
    if trip-purpose-prob > 0.97 [ set color blue]
  ]
  ]
 

When I use "every" it is counting the time in real life seconds when I have the time scale of the model based on ticks. Prior to using that it changed the status(color) initially on every run or tick of the go step and so had the turtle's color blinking non-stop.

How would you suggest I put in a distance or time-frame limiter for this portion of the code?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
RMurray24
  • 21
  • 2

1 Answers1

0

every is useless in normal agent-based models; it's sometimes useful when building games in NetLogo.

The typical NetLogo way to make something happen every n ticks is:

if ticks mod n = 0 [
  ...
]
Seth Tisue
  • 29,985
  • 11
  • 82
  • 149
  • Thanks Seth for that. I implemented it into a portion of my code where I used it to create a counter. But more what I wanted to do was to sort of replicate a buffer time. So say a taxi service gets a call on average every 10 seconds. I wanted to put in a slider that allowed me to change that buffer time and thus the frequency with which the trip purposes above are assigned. You're correct "every" doesn't quite allow that. But struggling to figure out the best way to implement it. – RMurray24 Feb 22 '21 at 19:34
  • In `ticks mod n = 0`, `n` could be a slider. – Seth Tisue Feb 26 '21 at 20:00