Random Grid Walk Example

Random Grid Walk 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 445 times • Downloaded 95 times • Run 1 time
Download the 'Random Grid Walk 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 is a demo of a basic random walk, constrained to lie on a grid. At each step, the yellow turtle changes its heading randomly, but always in multiples of 90, so the turtle is always facing due north, east, south, or west. At each step, the turtle always lands on the center of a patch.

Two slightly different kinds of walk are demonstrated:

  • In WALK1, the turtle's heading at each time step is completely random.

  • In WALK2, the turtle never makes an immediate about face (180 degree turn). Thus, it will tend to proceed in one direction for longer. This is more similar to how a person or animal might wander.

THINGS TO NOTICE

The monitors show that the turtle's xcor and ycor are always exact multiples of 1.0. That means that the turtle is always on a patch center.

RELATED MODELS

Random Walk Example - shows a freer random walk which does not follow a grid

Comments and Questions

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

Click to Run Model

to setup
  clear-all
  crt 1                                 ;; create one turtle
  [
    set color orange
    set size 3                          ;; make it easier to see
    face one-of neighbors4              ;; face N, E, S, or W
    pen-down                            ;; have it draw its path
  ]
  reset-ticks
end 

to walk1
  ask turtles [
    face one-of neighbors4              ;; face N, E, S, or W
    forward 1                           ;; advance one step
  ]
  tick
end 

to walk2
  ask turtles [
    rt one-of [-90 0 90]                ;; go left, straight, or right
    forward 1                           ;; advance one step
  ]
  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 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 Random Grid Walk Example Download this version
Uri Wilensky about 15 years ago Random Grid Walk Example Download this version

Attached files

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

This model does not have any ancestors.

This model does not have any descendants.