L.P.
L.P.

Reputation: 3

Netlogo- average link length code snippet

I'm trying to monitor the length of my links in Netlogo- but I'm having a hard time getting used to the syntax. Is anyone familiar enough with it to just take the mean of all link-lengths?

Thanks.

Upvotes: 0

Views: 226

Answers (1)

Luke C
Luke C

Reputation: 10291

Using this simple setup:

to setup
  ca
  crt 10 [
    setxy random-pxcor random-pycor
  ]
  ask turtles [
    if not any? my-links [
      create-link-with one-of other turtles
    ]
  ]
  reset-ticks
end

You can use of with [link-length] to return a list of link lengths (try just typing print [link-length] of links in the console), then use mean to take the mean of that list. If you put that in a to-report procedure, you will be able to display the mean-link-length in a "monitor" widget in the "Interface":

to-report mean-link-length
  report mean [link-length] of links
end


enter image description here

Upvotes: 1

Related Questions