Walking
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
Each student defines the motion of a walking character by setting its velocity on their client over time intervals. The students have 9 different intervals for which they can set the velocity. They can then send these velocities to their characters, where they see the character walking its route over the 9 intervals. This is designed to help students understand the accumulation of distance as a function of time. This can serve as a jumping off point for advanced concepts ranging from derivatives and integrals to wave mechanics.
For further documentation, see the Participatory Simulations Guide found at http://ccl.northwestern.edu/ps/
HOW IT WORKS
Each student has control of nine sliders, one for each interval over a period of time, the sliders determine the velocity of the character, walker, assigned to the student. Once instructions have been given and students have made selected their velocities for each time interval you can run the simulation. The walkers will move across the view at the indicated rates possibly leaving behind a trail to make it easier to see the change in position over time.
There are two possible clients for this activity, one with a view and one without. Walking includes the view, Walking Alternate does not.
HOW TO USE IT
To start the activity press the SETUP button and then press LOGIN. Have the students login and identify their location in the view. Students can then change the velocities of their character by moving the interval sliders on the client. To run the entire set of nine intervals press the GO button, to move forward only one interval at a time press the STEP button. You may leave the LOGIN button pressed at all times if you wish.
To reset the clock and reset the walkers to their initial positions, that is a position that was randomly selected at login, press the SETUP button. If you just want to reset the clocks and allow the walkers to continue from their current positions press the RESET-CLOCK button. To reset walkers to a new random position press the SET-RANDOM-POSITIONS button. To set the position of all walkers to the same place select the location by setting the WALKER-POSITION slider and press the SET-UNIFORM-POSITIONS button.
By default the velocities and positions for all walkers are plotted in the POSITION V INTERVAL and VELOCITY V INTERVAL plots. If you want to plot only one walker press the PICK-WALKER-TO-PLOT button and select a walker from the list, or select "everybody" to plot all walkers again.
There are a few settings that will help you and the participants to visualize the simulation. SIMULATION-SPEED adjusts how quickly to move through the intervals during GO. When SHOW-USER-ID? is true, all the turtles show their user-id as its label otherwise no label is shown. When FOOTPRINTS? is true the walkers leave a trail of footprints behind them, the footprints fade over time so you can track how long ago you were at each position. When TRAILS? is true the walkers change the pcolor along their path as they move indicating whether they are moving in a positive or negative direction. When ANIMATION? is true the walkers are animated like a flipbook as they move across the world.
THINGS TO NOTICE
Notice if a walker moves more than 1 position during an interval, it equally divides the amount of time spent traveling through each position.
THINGS TO TRY
Have your walker sit at x = 3 during the fourth time segment. What is the same and different between the solutions? Encourage students to come up with unique solutions.
Have students coordinate to make a traveling or a standing wave.
Have each student set their walker to have a velocity of +2 during the fourth time interval.
Have each student set their velocities so that the walker starts and ends in the same position.
EXTENDING THE MODEL
A real person may not move at a constant speed. He or she may build speed gradually until they have reached a constant speed. Then before reaching their destination, they will slow down. Try to make this happen as a part of the model.
NETLOGO FEATURES
This activity uses incremental turtle shapes in order to simulate an animation.
RELATED MODELS
Function
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. and Stroup, W. (2006). NetLogo HubNet Walking model. http://ccl.northwestern.edu/netlogo/models/HubNetWalking. 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 2006 Uri Wilensky and Walter Stroup.
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.
Comments and Questions
;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Variable declarations ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;; globals [ ;;clock ;; keeps track of the number of times modulus total-intervals through the go procedure num-intervals ;; the number of time intervals a walker can move ;; variables for leaving a trail up-trail-color ;; color of the trail left behind by an walker as it moves upwards down-trail-color ;; color of the trail left behind by an walker as it moves downwards ;; plotting variables walker-to-plot ;; the walker to plot if plot-all-walkers? is false ] breed [ footprints footprint ] breed [ walkers walker ] walkers-own [ user-id ;; the name of the client corresponding to this turtle my-xcor ;; the unwrapped horizontal position of a turtle xcor-initial ;; the initial horizontal position of a turtle interval ;; the current interval a turtle is moving through velocity ;; current velocity of an walker velocities ;; list of velocities one for each interval base-shape ;; either person-forward- or person-backward- so when we are animating ;; we just tack on the frame number to form the name of the appropriate shape shape-counter ;; keep track of where in the animation we are so it looks smooth ] footprints-own [ base-color ;; keep track of the color so we know when it has faded enough to entirely disappear ] patches-own [ base-pcolor ;; the original color of the patch before any trail was drawn on it ] ;;;;;;;;;;;;;;;;;;;;;; ;; Setup Procedures ;; ;;;;;;;;;;;;;;;;;;;;;; to startup hubnet-reset setup-vars setup-patches set-default-shape walkers "person-forward-1" set-default-shape footprints "footprint" setup end to setup reset-ticks cd setup-patches ask walkers [ pu set-position xcor-initial ] ask footprints [ die ] my-setup-plots end to reset-clock reset-ticks cd setup-patches ask walkers [ set-position xcor pu ] ask footprints [ die ] my-setup-plots end to set-random-positions reset-ticks setup-patches ask walkers [ set-position random-pxcor ] ask footprints [ die ] my-setup-plots end to set-uniform-positions reset-ticks setup-patches ask walkers [ set-position walker-position ] ask footprints [ die ] my-setup-plots end to set-position [x] set heading 90 set xcor x set interval 0 set my-xcor xcor st show-or-hide-id-labels end ;; set up the patches to have the floor numbers down the left side of the ;; view and color all even floor a gray color to setup-patches clear-output cp ;; give the floors some color to be able to distinguish one floor from another ask patches with [ pxcor mod 2 = 0 ] [ set pcolor gray - 2 ] ask patches with [ pxcor = 0 ] [ set pcolor gray - 1 ] ;; label each row of pycors with a floor number ask patches with [ pycor = min-pycor ] [ set plabel pxcor ] ask patches [ set base-pcolor pcolor ] end ;; set variables to initial values to setup-vars reset-ticks set num-intervals 9 set up-trail-color green set down-trail-color red ;; by default have the walker to plot be nobody set walker-to-plot "everybody" end ;;;;;;;;;;;;;;;;;;;;;;;; ;; Runtime Procedures ;; ;;;;;;;;;;;;;;;;;;;;;;;; ;; move the walkers one interval to go if ticks >= num-intervals [ stop ] ;; see if there are any messages waiting before ;; we start moving listen-clients ;; we want to move to a new interval after delay seconds ;; where delay is a function of simulation speed every delay [ if ticks < num-intervals [ ask walkers [ show-or-hide-id-labels ;; keep labels in sync with the switches assign-values ;; set the walkers' velocity to the appropriate value move-walkers ;; move the walkers by their velocity for this interval ] do-plotting ;; depending on the visualizations used ;; we may have to do some fading at the end of each move. if trails? [ ask patches with [ pcolor != base-pcolor ] [ fade-trail ] ] if footprints? [ ask footprints [ set color color - 0.4 if color < base-color - 5 [ die ] ] ] tick ] ] end ;; calculate the delay in seconds based on the simulation speed to-report delay ifelse simulation-speed <= 0 [ report ln (10 / 0.001) ] [ report ln (10 / simulation-speed) ] end to show-or-hide-id-labels ;; turtle procedure ifelse show-user-id? [ set label word user-id " " ] [ set label "" ] end ;; set the student selected walker velocity for the current interval to assign-values ;; turtle procedure ifelse interval >= length velocities [ set velocity 0 ] [ set velocity item interval velocities ] end to move-walkers ;; turtle procedure let delta-pos 0 let speed abs velocity if velocity != 0 [ set delta-pos (velocity / speed ) ] ;; each step is divided into smaller steps ;; so we get the appearance of motion, and differing ;; velocities let inner-tick 0 ;; depending on whether the person is moving ;; forward or back change the shape to reflect the movement ifelse velocity >= 0 [ set base-shape "person-forward-"] [ set base-shape "person-backward-" ] if not animation? [ set shape word base-shape "1" ] ;; reduce the "frames" per step so we get smoother movement ;; the distance and relative speed they move is the ;; same only there are more intermediate positions ;; and shapes displayed. set delta-pos delta-pos / 4 set speed speed * 4 while [ inner-tick < speed ] [ ;; divide the amount of time till the next interval into equal amounts ;; so as to be able to make the motion of an walker smooth every ( delay / speed ) [ if trails? [ ;; change the patch color as we move ifelse velocity > 0 [ set pcolor up-trail-color ] [ set pcolor down-trail-color ] ] ;; set the true x-coord to the new position, even if it goes outside the world set my-xcor (my-xcor + delta-pos) ;; if the new position is outside the world ;; hide the turtle, it's out of the view ;; otherwise show the turtle and move there. ifelse patch-at (my-xcor - xcor) 0 != nobody [ st set xcor my-xcor ] [ ht ] set inner-tick inner-tick + 1 if animation? [ ;; increment the shape to the next shape in the ;; series to create the illusion of motion. set shape (word base-shape shape-counter) set shape-counter ((shape-counter + 1) mod 9) + 1 ] display ] ] if footprints? [ ;; make a shape where we landed. ;; we can't use stamp shape because we want them to fade. hatch-footprints 1 [ set base-color color set label "" set color color - 0.4 ;; make sure the footprint faces in the ;; direction the walker is headed ifelse [velocity] of myself >= 0 [ set heading 90 ] [ set heading 270 ] ] ] set interval interval + 1 end ;; have any trails fade back to the base color of the patch to fade-trail ;; patch procedure set pcolor pcolor - 0.4 if (pcolor mod 10 = 0) [ set pcolor base-pcolor ] end ;;;;;;;;;;;;;;;;;;;;;;; ;; HubNet Procedures ;; ;;;;;;;;;;;;;;;;;;;;;;; to listen-clients while [ hubnet-message-waiting? ] [ hubnet-fetch-message ifelse hubnet-enter-message? [ setup-walker display ] [ ifelse hubnet-exit-message? [ remove-walker display ] [ ask walkers with [ user-id = hubnet-message-source ] [ execute-cmd hubnet-message-tag ] ] ] ] end to execute-cmd [ cmd ] ifelse cmd = "interval-1" [ set-velocity 0 ][ ifelse cmd = "interval-2" [ set-velocity 1 ][ ifelse cmd = "interval-3" [ set-velocity 2 ][ ifelse cmd = "interval-4" [ set-velocity 3 ][ ifelse cmd = "interval-5" [ set-velocity 4 ][ ifelse cmd = "interval-6" [ set-velocity 5 ][ ifelse cmd = "interval-7" [ set-velocity 6 ][ ifelse cmd = "interval-8" [ set-velocity 7 ] [ if cmd = "interval-9" [ set-velocity 8 ] ] ] ] ] ] ] ] ] end to set-velocity [index] set velocities replace-item index velocities hubnet-message end to setup-walker let p one-of patches with [ pxcor = 0 and pycor > (min-pycor + 1) and not any? walkers-on patches with [ pycor = [pycor] of myself ] ] ifelse p = nobody [ user-message "A user tried to join but there is no more space for another user." ] [ create-walkers 1 [ set user-id hubnet-message-source set velocities [0 0 0 0 0 0 0 0 0] set heading 0 set interval 0 set color 5 + 10 * random 14 set xcor-initial random-pxcor setxy xcor-initial [pycor] of p set my-xcor xcor set label-color yellow show-or-hide-id-labels set shape-counter 1 set base-shape "person-forward-" ] my-setup-plots ] end to remove-walker ask walkers with [ user-id = hubnet-message-source ] [ die ] my-setup-plots end ;;;;;;;;;;;;;;;;;;;;;;;;; ;; Plotting Procedures ;; ;;;;;;;;;;;;;;;;;;;;;;;;; ;; plot the positions and velocities for the walkers in the appropriate plot to do-plotting ;; walker-to-plot is a string ;; assume we are plotting everyone let guys-to-plot walkers ;; if we're not get the agentset that includes the agents ;; we're plotting, right now it can only be one but the code ;; is simpler this way. if walker-to-plot != "everybody" [ set guys-to-plot walkers with [ user-id = walker-to-plot ] ] ask guys-to-plot [ set-current-plot "Position vs. Intervals" set-current-plot-pen user-id plot my-xcor set-current-plot "Velocity vs. Intervals" set-current-plot-pen user-id plot velocity ] plot-x-axis "Velocity vs. Intervals" plot-x-axis "Position vs. Intervals" end ;; plots a black line at the x-axis of the plot this-plot to plot-x-axis [ this-plot ] set-current-plot this-plot set-current-plot-pen "x-axis" plotxy plot-x-min 0 plotxy plot-x-max 0 end to pick-walker-to-plot set walker-to-plot user-one-of "Please select the walker to plot" (fput "everybody" sort [user-id] of walkers ) end ;; setup the position and velocity plot to my-setup-plots clear-all-plots ask walkers [ set-current-plot "Position vs. Intervals" setup-pens false set-current-plot "Velocity vs. Intervals" setup-pens true ;; make sure to plot the initial position set-current-plot "Position vs. Intervals" set-current-plot-pen user-id plot my-xcor ] plot-x-axis "Velocity vs. Intervals" plot-x-axis "Position vs. Intervals" end ;; create pens for each of the existing walkers and color the pens to be the same color as ;; their corresponding walker. if bars? is true, set the pen mode to be 1 for bar mode. to setup-pens [ bars? ] create-temporary-plot-pen user-id if bars? [ set-plot-pen-mode 1 ] set-plot-pen-color color end ; Copyright 2006 Uri Wilensky and Walter Stroup. ; See Info tab for full copyright and license.
There are 7 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Walking.png | preview | Preview for 'Walking' | over 11 years ago, by Uri Wilensky | Download |
This model does not have any ancestors.
This model does not have any descendants.