Ask Ordering Example
Model was written in NetLogo 5.0.4
•
Viewed 1395 times
•
Downloaded 161 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
Agentsets in NetLogo are always in random order. This code example demonstrates that visually. It also shows how to make the turtles execute in a particular order if you want.
NETLOGO FEATURES
sort
and sort-by
are used to specify ordering.
View updates are set to "continuous", so when you slow the model down far enough you can see the turtles moving one at a time.
Comments and Questions
Click to Run Model
to setup clear-all create-turtles floor (world-width / 3) [ set xcor 1 + who * 3 ;; space out the turtles in order by who number set color color - 2 ;; darker set size 1 + random-float 3 set heading 0 set label who ] reset-ticks end ;;; three different version of GO to go-random ask turtles [ fd 1 ] tick end to go-by-who-number foreach sort turtles [ ask ? [ fd 1 ] ] tick end to go-by-size foreach sort-by [[size] of ?1 > [size] of ?2] turtles [ ask ? [ fd 1 ] ] 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.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Ask Ordering Example.png | preview | Preview for 'Ask Ordering Example' | over 12 years ago, by Uri Wilensky | Download |
This model does not have any ancestors.
This model does not have any descendants.