Calculating average number of movement steps for dead turtles

12 views
Skip to first unread message

J

unread,
Jun 5, 2024, 9:51:47 PMJun 5
to netlogo-users
Hello, 
 
I have a turtle variable in my model called realized-dispersal-distance that tallies the number of movement steps (1 step = 1 cell-length) that an individual takes before it either settles in suitable habitat or dies. To calculate the mean on this value across turtles in each time step I typed "mean [realized-dispersal-distance] of turtles" into the reporter box of the Behaviourspace tool. However, this  only calculates the average number of movement steps for individuals that survive. Is there a way to calculate the number of movement steps for the individuals that die as well?

I have included my code below. Thanks in advance for your help!

if (dispersal-mode = "Active - SRW" or dispersal-mode = "Active - CRW")
     [
      repeat dispersal-distance
      [
        fd 1
        set realized-dispersal-distance realized-dispersal-distance + 1  
        set heading heading + wrapped-cauchy rw-p
        if (pcolor = green and not any? other turtles-here with [age > 0])
           [
            set count-successful-settlement count-successful-settlement + 1
            set age age + 1
            stop
           ]
         if pcolor = brown
          [
           if random-float 1 < dispersal-mortality-matrix
            [
             set count-dead-matrix count-dead-matrix + 1
             die
            ]
          ]
        ]
         ifelse (pcolor = green and not any? other turtles-here with [age > 0])
          [
           set count-successful-settlement count-successful-settlement + 1
           set age age + 1
           stop
          ]
         [
          set count-dead-settlement count-dead-settlement + 1
          die
         ]
     ]

Jessica

Pradeesh Kumar K V

unread,
Jun 8, 2024, 8:52:06 AMJun 8
to netlogo-users
I think you could add the realized-dispersal-distance of a turtle to a list before it dies. At the end of the run, this list can be combined with the realized-dispersal-distance of all surviving turtles. 

I made a test code to check this (given below) and it seems to work:

globals [dead-turtles-distance]
turtles-own [distance-travelled]


to setup
ca
reset-ticks

;set pcolor of few patches to red
ask n-of 20 patches
[
set pcolor red
]

;initialize list
set dead-turtles-distance []

;create 100 turtles and initialize distance-travelled to 0
create-turtles 100
[
set distance-travelled 0
]
end

to go

;specify criteria for stopping a run
if ticks >= 100
[
foreach [distance-travelled] of turtles [x -> set dead-turtles-distance lput x dead-turtles-distance] ;consolidate lists
stop
]

ask turtles
[
if random-float 1 < 0.5
[
lt 90 ;turn left
]
fd 1 ;move forward
set distance-travelled distance-travelled + 1 ;update distance travelled

if pcolor = red
[
set dead-turtles-distance lput distance-travelled dead-turtles-distance ;update the dead-turtles-distance list whenever a turtle dies
die
]
]
tick
end

--
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/1c50003f-5b4a-404e-8d4b-fbd3467d8a72n%40googlegroups.com.

J

unread,
Jun 10, 2024, 3:25:21 PMJun 10
to Pradeesh Kumar K V, netlogo-users
Thanks Pradeesh! I was thinking a list was probably the way to go. Much appreciated.

Jessica



--
Jessica Lockhart

Reply all
Reply to author
Forward
0 new messages