puzzle4
No preview image
Model was written in NetLogo 4.1.2
•
Viewed 91 times
•
Downloaded 18 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?
This code example is a demo of a basic random walk. At each step, the yellow turtle changes its heading randomly.
THINGS TO NOTICE
The turtle's pen is down, so it leaves a trail behind it in the drawing.
RELATED MODELS
Random Grid Walk Example - the same except that the random walk is constrained to lie on a grid
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
to box clear-all crt 1 ;; create one turtle [ face one-of neighbors4 set color yellow set size 2 ;; make it easier to see pen-down ;; have it draw its path repeat 4 [ fd 15 rt 90 ] ] end ;; declare a global variable, halfedge, to be used when the box center is at (0,0) globals [halfedge] to setup-center ca ;; clear everything ;; set halfedge as edge divided by two. in case edge is an odd number, ;; halfedge get the integer value of the division. set halfedge int (edge / 2) ask patches[ ;; if patches are between (-halfedge,-halfedge) to (-halfedge,halfedge)... if (pxcor = (- halfedge) and pycor >= (- halfedge) and pycor <= (0 + halfedge) ) [set pcolor blue] ;; ... draws left edge in blue ;; if patches are between (halfedge,-halfedge) to (halfedge,halfedge)... if ( pxcor = (0 + halfedge) and pycor >= (- halfedge) and pycor <= (0 + halfedge) ) [set pcolor blue] ;; ... draws right edge in blue ;; if patches are between (-halfedge,-halfedge) to (halfedge,-halfedge)... if ( pycor = (- halfedge) and pxcor >= (- halfedge) and pxcor <= (0 + halfedge) ) [set pcolor blue] ;; ... draws bottom edge in blue ;; if patches are between (-halfedge,halfedge) to (halfedge,halfedge)... if ( pycor = (0 + halfedge) and pxcor >= (- halfedge) and pxcor <= (0 + halfedge) ) [set pcolor blue] ;; ... draws upper edge in blue ] end
There is only one version of this model, created over 13 years ago by soheir othman.
Attached files
No files
This model does not have any ancestors.
This model does not have any descendants.