Lattice-Walking Turtles Example

Lattice-Walking Turtles Example preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

code example 

Tagged by Reuven M. Lerner about 11 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 547 times • Downloaded 75 times • Run 1 time
Download the 'Lattice-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 "hex"
  ;; create a hex grid of nodes
  ask patches
  [ sprout-nodes 1
    [ set color gray - 3.5 ;; dark gray
      set size 1.2
      ;; shift even columns down
      if pxcor mod 2 = 0
      [ set ycor ycor - 0.5 ] ] ]
  ;; connect the nodes to make a lattice
  ask nodes
  [ ifelse pxcor mod 2 = 0
      [ create-links-with nodes-on patches at-points [[0 1] [1 0] [1 -1]] ]
      [ create-links-with nodes-on patches at-points [[0 1] [1 1] [1 0]] ] ]
  ask links [ hide-link ]
  ;; put some "walker" turtles on the lattice
  create-walkers 20 [
    set color red
    set location one-of nodes
    move-to location
  ]
  reset-ticks
end 

to go
  ask walkers [
    set-location one-of [link-neighbors] of location
  ]
  tick
end 

to set-location [new-location]  ;; walker procedure
  set location new-location
  face new-location  ;; not strictly necessary, but improves the visuals a bit
  move-to new-location
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 almost 11 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky over 11 years ago Updated version tag Download this version
Uri Wilensky about 12 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky almost 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky almost 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky almost 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky almost 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky almost 14 years ago Model from NetLogo distribution Download this version
Uri Wilensky almost 14 years ago Lattice-Walking Turtles Example Download this version
Uri Wilensky almost 14 years ago Lattice-Walking Turtles Example Download this version

Attached files

File Type Description Last updated
Lattice-Walking Turtles Example.png preview Preview for 'Lattice-Walking Turtles Example' almost 11 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.