adkane
adkane

Reputation: 1441

How to measure distance covered across patches in NetLogo

I have a model setup in NetLogo where the simulation space is a GIS map with a 20 km radius that I constructed.

The max xcor and ycor are set to 20 and min xcor and ycor -20. This gives a torus of 41 x 41.

I have my agents at the centre of the map at patch 0 0 and want the maximum distance they can cover as the 20 km i.e. the extent of the GIS map.

ask turtles [
set heading 360
fd 1 ]

Am I right in saying if I iterate this code 20 times they'll be at the centre of the last patch (xcor 0 ycor 20) which isn't quite 20 km?

If that's right, how do I code it up so the agents move the appropriate distance. I feel like I'm trying to square a circle here.

I should say I can add the following line to get a patch scale that comes out at about 975.6

set patch-scale (item 1 gis:world-envelope - item 0 gis:world-envelope ) / world-width

If I multiply the patch scale by the world width I get 40000 which looks right given the radius of the circle is 20 km.

Thanks

Upvotes: 0

Views: 398

Answers (1)

Alan
Alan

Reputation: 9610

globals [km]

to test
  ca
  let extent 40 ;desired world-width, in kilometers
  set km (world-width / extent)
  crt 1 [set heading 360]
  ask turtle 0 [fd (20 * km)]
end

Upvotes: 1

Related Questions