how to limit turtle lifespan based on ticks elapsed since creation

188 views
Skip to first unread message

Emily W

unread,
Oct 7, 2021, 8:47:02 AM10/7/21
to netlogo-users
Hi,
is there a way to make turtles die once a certain number of ticks have elapsed since their creation? My model contains a huge number of turtles that are laid down throughout the model to mark a pheromone trail to food. I would like it if they died in order of creation time (oldest die first). I know that evaporate-chemical (based on the ant models in the net logo library) would do the same thing, but the chemical system did not work in my model, so I chose to use turtles instead. 

Thank you so much for any ideas!

Emily Warsavage

unread,
Oct 26, 2021, 5:02:45 PM10/26/21
to Randy Boone, netlogo-users
Hi Randy,
I really like your idea, especially since I have implemented countdowns for other aspects of my model. However, I tried to implement your suggestion, but it didn't work. I think it may be because I create the turtles in question using the hatch-turtles 1 command throughout procedures called by the to go button, instead of creating them once at the beginning of the model. I tried several variations of your suggestion, including setting the lifespan in the setup, and then simply calling [set lifespan lifespan - 1] within each hatch-turtles 1 command, but the number of turtles in question never decreased. Do you have any other suggestions on how to implement your idea? 

Thanks!!
Sincerely,
Emily Warsavage

On Thu, Oct 7, 2021 at 7:08 PM Randy Boone <rboon...@yahoo.com> wrote:
Hi Emily,

When the turtle is created, you may assign it a countdown clock, either a constant value or perhaps a random normal value to give some variability to it.  Then count down each tick, so ...

create-bees 50 [
   set life-span 500 
]

or perhaps 

create-bees 50 [
   set life-span random-normal 500 50
]

And then:

to go
    ...

    ask bees [
        set life-span life-span - 1
        if life-span = 0 [ die ]
    ]
end


Cheers,
Randy


--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/30fe4fcc-1e61-42e8-9e08-5f91963d163fn%40googlegroups.com.

Emily Warsavage

unread,
Nov 1, 2021, 3:10:15 PM11/1/21
to Randy Boone, netlogo-users
Hi Randy,
I really like your idea, especially since I have implemented countdowns for other aspects of my model. However, I tried to implement your suggestion, but it didn't work. I think it may be because I create the turtles in question using the hatch-turtles 1 command throughout procedures called by the to go button, instead of creating them once at the beginning of the model. I tried several variations of your suggestion, including setting the lifespan in the setup, and then simply calling [set lifespan lifespan - 1] within each hatch-turtles 1 command, but the number of turtles in question never decreased. Do you have any other suggestions on how to implement your idea? 

Thanks!!
Sincerely,
Emily Warsavage

Reply all
Reply to author
Forward
0 new messages