0

I would like to control the timing of turtle generation with a decrement-timer using variables obtained from the gamma distribution. The following is sample program syntax.

to setup-turtles
   set number-of-turtles 0
   set-default-shape turtles "circle"
   set gamma-A 0
end

to go
   let numle count [turtles-at 0 0] of patch min-pxcor 0
   if numle = 0 [
   if gamma-A = 0 [
   set gamma-A random-gamma (α) (β)
   create-car
   ask turtles [
     set gamma-A gamma-A - 1
     set number-of-turtles number-of-turtles + 1
   ]
   ]
   ]
   tick
end

If the patch at the left end of the road is empty and the decrement-timer is 0, it will generate a turtle. Then it activates the decrement- timer. The road starts at the left end and ends at the right end. However, with this syntax, it is not possible to generate the second and subsequent turtles. I would be pleased if you give me advice. Thank you.

Severin Pappadeux
  • 18,636
  • 3
  • 38
  • 64
goodgest
  • 418
  • 3
  • 10
  • 2
    Hard to say without seeing all code required (I can't run this as-is), but it looks like you only set "gamma-A" to 0 in your `setup-turtles`. Since your `set gamma-A gamma-A - 1` only runs *if* "gamma-A" 0 at the start of that block, the condition is not satisfied once `go` has run once after `setup-turtles`. Additionally, unless `random-gamma` **happens** to generate an integer, you're not going to get back to 0 exactly- you probably want `if gamma-A <= 0` or something similar. – Luke C Jun 08 '17 at 17:49
  • Thank you for your comment. I'm sorry I could not post detailed code due to confidentiality. However, I got a hint from your comment. I improved the setting of gamma-A < 1 and if statement slightly changed, then this problem was solved. Again thank you very much! – goodgest Jun 09 '17 at 00:59
  • Right on, glad you sorted it out! – Luke C Jun 09 '17 at 01:06

0 Answers0