# Random Walk 360

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)

## WHAT IS IT?

In this model the turtles engage in a "random walk." Each turtle walks one step away from its current location in a different random direction at each clock tick. This movement is known as walking a 360-gon "lattice." A lattice is a set of points on the plane (or in space) that form a grid on which turtles walk.

As the simulation continues, one can expect the turtles to become more spread out. Will they ever return home (to their point of origin at 0 0)? Observe the kinds of patterns that develop as the turtles move.

## HOW TO USE IT

General Settings

Use the NUM-TURTLES slider to select how many turtles will participate in the random walk.

Use the STEP-SIZE slider to decide how far from its current location a turtle will move on each step.

How steps are implemented: if STEP-SIZE is set to n it will add (n * cos(theta)) to its current xcor value and it will add (n * sin(theta)) to its current ycor value. It will have moved n patch units from its current location. (Why?)

Each of the above movements would be considered a single "pace."

### Distance Rings

Set DRAW-RINGS to ON to draw the x-axis, y-axis, and a set of concentric circles about the point (0 0). This switch must be set prior to pressing SETUP.

Use the RING-RADIUS slider to set the incremental distance between the distance rings.

### Plots

"Average Distance"

- measures the average distance over all turtles, from home (the origin at 0,0) to their current coordinates.

"Average X-Distance"

- measures the average distance over all turtles along the x-axis away from the origin (x = 0).

"Std.Dev. of Distance"

- measures the standard deviation of all turtles' true distance from home to their current position. NetLogo's standard deviation primitive is used.

Note that xcor and ycor values are stored in such a way that turtles are tracked even if they move outside the boundaries of the world. These 'out of bounds' values are used to measure distances. They are stored at turtle variable xc (for xcor) and yc (for ycor).

Distances are either zero or positive.

### Buttons

Press SETUP when all of the above selections have been made. This will create the selected number of turtles at the bottom center of the world.

Press GO-ONCE to make the turtles move one pace.

Press GO to make the turtles move continuously. To stop the turtles, press the GO button again.

## THINGS TO NOTICE

Try starting with 500 turtles with a step size of 1. If you want to show distance rings, try setting the radius increment to 20.

Press SETUP then press GO.

The turtles all start at (0,0) (home).

Think about how you would define an 'average' turtle and an 'average' walk.

Where would you expect an average turtle to end up at a given time? Why?

Will all turtles eventually return home? If so, how many paces would you expect a turtle to travel before it returned to home? Why?

What kinds of calculations or measurements would you use in trying to answer these questions?

Two characteristics of the plots you see are their smoothness and their slope.

To think about smoothness of the plots, notice how much the lines move up and down over time.

To think about slope of the plots, consider whether the plot appears to be going 'uphill' or 'downhill' and consider whether the 'hill' is steep or flat.

What do you notice about the smoothness and slope of the plots?

- Are they smooth? Why or why not?
- Are they steep? Why or why not?
- For a given plot, is its steepness the same at the far edges and at the center? Why or why not?

Does the plot have any symmetry? Would you expect it to? Why?

Does a single line plot ever change between positive and negative slopes? Why or why not? If it does, what does that mean?

## THINGS TO TRY

Try to answer the following questions before running the simulations. Record your predictions. Compare your predicted results with the actual results.

- What reasoning led you to correct predictions?
- What assumptions that you made need to be revised?

Try different numbers of turtles while keeping all other slider values the same.

- What happens to the plot's smoothness and slope when the number of turtles is increased?
- What happens to the plot's smoothness and slope when the number of turtles is decreased?
- Does the simulation finish faster or slower than the first model?

Try different numbers of steps while keeping all other slider values the same.

- What happens to the plot's smoothness and slope when the number of steps is increased?
- What happens to the plot's smoothness and slope when the number of turtles is decreased?
- Does the simulation finish faster or slower than the first model?

How do your answers to the above questions compare to the average values calculated for all turtles in a given simulation?

## EXTENDING THE MODEL

In this simulation, turtles can only move based on integer values of heading. Change the model so that any value of heading between 0 and 360 degrees is possible.

Does this change the amount of time it would take for a turtle to return home? How? Why?

How does this change impact answers to other questions asked above?

One of the plots measures the average x-distance away from the origin over all turtles. Obviously, it could have measured the y-distance instead. Watch the plot under one run of the model, and then change the procedure so that it measures y-distance. How do the plots differ?

Create a new monitor called home-turtles. Have it display the number of turtles at (or very near) home. Create a plot to display this information.

## NETLOGO FEATURES

Since NetLogo does not allow the world to be unbounded, the special code below is needed for this model to simulate the behavior, instead of stopping at the edge of the world the turtles hide themselves when they have moved outside the world.

```
set xc xc + (step-size * dx)
set yc yc + (step-size * dy)
; hide turtles who have moved out of the world
ifelse patch-at (xc - xcor) (yc - ycor) = nobody
[ ht ]
[ st
set xcor xc
set ycor yc ]
set dist sqrt (xc * xc + yc * yc)
```

Stamping of turtle shapes is used to draw a polar coordinate grid in the drawing layer.

## HOW TO CITE

If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software:

- Wilensky, U. (1997). NetLogo Random Walk 360 model. http://ccl.northwestern.edu/netlogo/models/RandomWalk360. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.
- Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.

## COPYRIGHT AND LICENSE

Copyright 1997 Uri Wilensky.

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.

This model was created as part of the project: CONNECTED MATHEMATICS: MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL MODELS (OBPML). The project gratefully acknowledges the support of the National Science Foundation (Applications of Advanced Technologies Program) -- grant numbers RED #9552950 and REC #9632612.

This model was converted to NetLogo as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. The project gratefully acknowledges the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227. Converted from StarLogoT to NetLogo, 2001.

## Comments and Questions

turtles-own [ xc ; unwrapped xcor yc ; unwrapped ycor dist ; distance from home using xc, yc ] to setup clear-all ; if the user so chooses, draw rings around (0, 0) to give a sense of how far turtles have traveled ; the furthest in-view distance from home is world-width * sqrt (2) / 2 if draw-rings? [ ;; draw the rings by making ring shape turtles that stamp their shape ;; and then go away crt floor (world-width * sqrt 2 / (ring-radius * 2)) [ set color gray - 1 set shape "ring" set size ring-radius * 2 * (who + 1) stamp die ] ;; draw X and Y axes crt 1 [ set heading 0 set color gray - 1 set shape "line" set size world-height stamp rt 90 set size world-width stamp die ] ] crt num-turtles reset-ticks end to go ask turtles [ ; head in a random direction rt random-float 360 set xc xc + (step-size * dx) set yc yc + (step-size * dy) ; hide turtles who have moved out of the world ifelse patch-at (xc - xcor) (yc - ycor) = nobody [ ht ] [ st set xcor xc set ycor yc ] set dist sqrt (xc * xc + yc * yc) ] tick end ; Copyright 1997 Uri Wilensky. ; See Info tab for full copyright and license.

There are 11 versions of this model.

## Attached files

File | Type | Description | Last updated | |
---|---|---|---|---|

Random Walk 360.png | preview | Preview for 'Random Walk 360' | almost 10 years ago, by Uri Wilensky | Download |

This model does not have any ancestors.

This model does not have any descendants.