Link-Walking Turtles Example

Link-Walking Turtles Example preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

code example 

Tagged by Reuven M. Lerner over 4 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 3361 times • Downloaded 174 times • Run 12 times
Download the 'Link-Walking Turtles 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.)


Comments and Questions

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

Click to Run Model

breed [nodes node]
breed [walkers walker]

walkers-own [location]  ;; holds a node

to setup
  clear-all
  set-default-shape nodes "circle"
  ;; create a random network
  create-nodes 30 [ set color blue ]
  ask nodes [ create-link-with one-of other nodes ]
  ;; lay it out so links are not overlapping
  repeat 500 [ layout ]
  ;; leave space around the edges
  ask nodes [ setxy 0.95 * xcor 0.95 * ycor ]
  ;; put some "walker" turtles on the network
  create-walkers 5 [
    set color red
    set location one-of nodes
    move-to location
  ]
  reset-ticks
end 

to layout
  layout-spring nodes links 0.5 2 1
end 

to go
  ask links [ set thickness 0 ]
  ask walkers [
    let new-location one-of [link-neighbors] of location
    ;; change the thickness of the link I just crossed over
    ask [link-with new-location] of location [ set thickness 0.5 ]
    face new-location  ;; not strictly necessary, but improves the visuals a bit
    move-to new-location
    set location new-location
  ]
  tick
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 4 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky almost 5 years ago Updated version tag Download this version
Uri Wilensky almost 6 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky over 7 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 7 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 7 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 7 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 7 years ago Model from NetLogo distribution Download this version
Uri Wilensky over 7 years ago Link-Walking Turtles Example Download this version
Uri Wilensky over 7 years ago Link-Walking Turtles Example Download this version

Attached files

File Type Description Last updated
Link-Walking Turtles Example.png preview Preview for 'Link-Walking Turtles Example' over 4 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.