Scatter Example

Scatter Example preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

(This model has yet to be categorized with any tags)
Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 308 times • Downloaded 73 times • Run 0 times
Download the 'Scatter Example' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

This code example shows three ways to scatter turtles across the world. One way scatters them evenly across the world. The second way scatters them in a circle. The third puts them on the center of random patches.

THINGS TO NOTICE

With SCATTER2, the density of turtles in the center is higher than the edges.

With all three scatter methods, sometimes turtles can land on the same patch. If you want to create turtles on patch centers and restrict them to one turtle per patch, the easiest way is not to create the turtles and then move them to the patches, but directly ask the patches to create the turtles, as follows:

  ask n-of 300 patches [ sprout 1 ]

RELATED MODELS

Scatter

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

;; setup clears all and then creates a lot of turtles

to setup
  clear-all
  crt 300
end 

;; scatter1 sets the x and y coordinates of each
;; turtle randomly

to scatter1
  setup
  ask turtles [
    setxy random-xcor random-ycor
  ]
end 

;; scatter2 sends the turtles forward a random amount in random directions
;; using "jump" instead of "fd" makes it happen faster

to scatter2
  setup
  ask turtles [
    rt random 360
    jump random-float max-pxcor
  ]
end 

to scatter3
  setup
  ask turtles [
    move-to one-of patches   ;; go to the center of a random patch
  ]
end 


; Public Domain:
; To the extent possible under law, Uri Wilensky has waived all
; copyright and related or neighboring rights to this model.

There are 10 versions of this model.

Uploaded by When Description Download
Uri Wilensky over 12 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky almost 13 years ago Updated version tag Download this version
Uri Wilensky over 13 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky about 15 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky about 15 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky about 15 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky about 15 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky about 15 years ago Model from NetLogo distribution Download this version
Uri Wilensky about 15 years ago Scatter Example Download this version
Uri Wilensky about 15 years ago Scatter Example Download this version

Attached files

File Type Description Last updated
Scatter Example.png preview Preview for 'Scatter Example' over 12 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.