breeds [ leader followers ] globals [ choice ] ;;;;;;;;;;;;;;;;;;;;;;;; ;;; Setup Procedures ;;; ;;;;;;;;;;;;;;;;;;;;;;;; to setup ca setup-patches setup-leader setup-followers end to setup-patches ;draw x-axis, y-axis as light gray ask patches [ if (pxcor = 0) [ set pcolor gray - 3 ] if (pycor = 0) [ set pcolor gray - 3 ] ] end to setup-leader create-custom-leader 1 [ set xcor (- screen-edge-x) set ycor (- screen-edge-y) if (show-leader = false) [ ht ] ] end to setup-followers create-custom-followers num-followers [ ;if there are exactly 4 follower turtles, set them up in the four corners of the screen ;otherwise, make the followers locations random set color (color + 10) ifelse (num-followers = 4) [ set xcor-of turtle 1 screen-edge-x set ycor-of turtle 1 screen-edge-y set xcor-of turtle 2 screen-edge-x set ycor-of turtle 2 (- screen-edge-y) set xcor-of turtle 3 (- screen-edge-x) set ycor-of turtle 3 screen-edge-y set xcor-of turtle 4 (- screen-edge-x) set ycor-of turtle 4 (- screen-edge-y) ] [ set xcor ((random (2 * screen-edge-x)) - screen-edge-x) set ycor ((random (2 * screen-edge-x)) - screen-edge-x) ] pd ] end to reveal ask patches [ if (pcolor = (black + 0.1) or pcolor = (gray + 0.1)) [ set pcolor gray ] ] end ;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Runtime Procedures ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;; to go every slowdown * 0.01 [ ; stop if the lead turtle is about to go off the screen if ((xcor-of turtle 0) = screen-edge-x) [ stop ] move-leader move-toward-leader ] end to move-toward-leader ask followers [ set heading towards-nowrap turtle 0 fd step-size ] end to move-leader ; to make a non-random formula active, put it's name in the square brackets next to the ; if (choice = 99) statement (and make sure the RandomFormula switch is set to false) ask leader [ if (choice = 0) [ linear ] ; y = x if (choice = 1) [ quad-up ] ; y = x^2 if (choice = 2) [ quad-down ] ; y = -x^2 if (choice = 3) [ cubic ] ; y = x^3 if (choice = 4) [ logarithm ] ; y = ln x if (choice = 5) [ exponential ] ; y = a^x if (choice = 6) [ sine ] ; y = sin x if (choice = 7) [ cosine ] ; y = cos x if (choice = 8) [ hyperbolic ] ; y = 1/x if (choice = 9) [ horizontal ] ; y = 0 if (choice = 10) [ vertical ] ; x = 0 ] end to mark ifelse (show-trail) [ stamp color ] [ stamp pcolor + 0.1 ] ; 0.1 is not enough to make a visible difference end to linear ;;Leader Procedure set ycor xcor mark set xcor (xcor + 1) end to quad-up ;;Leader Procedure set ycor ((xcor ^ 2) / screen-edge-y) mark set xcor (xcor + 1) end to quad-down ;;Leader Procedure set ycor ((- (xcor ^ 2)) / screen-edge-y) mark set xcor (xcor + 1) end to cubic ;;Leader Procedure set ycor ((xcor ^ 3) / (screen-edge-y ^ 2)) mark set xcor (xcor + 1) end to logarithm ;;Leader Procedure if (xcor <= 0) [ set xcor 1 ] set ycor ((ln (xcor / 10)) * 10) mark set xcor (xcor + 1) end to exponential ;;Leader Procedure locals [ scale-factor ] set scale-factor ((1.1 ^ screen-edge-x) / screen-edge-y) set ycor ((1.1 ^ xcor) / scale-factor) mark set xcor (xcor + 1) end to sine ;;Leader Procedure set ycor (screen-edge-y * (sin (xcor * 4))) mark set xcor (xcor + 1) end to cosine ;;Leader Procedure set ycor (screen-edge-y * (cos (xcor * 4))) mark set xcor (xcor + 1) end to hyperbolic ;;Leader Procedure ifelse (xcor = 0) [ set ycor 0 ] [ set ycor (screen-edge-y / xcor) ] mark set xcor (xcor + 1) end to horizontal ;;Leader Procedure set ycor 0 mark set xcor (xcor + 1) end to vertical ;;Leader Procedure set xcor 0 mark ifelse (ycor = screen-edge-y) [ set xcor screen-edge-x ] [ set ycor (ycor + 1) ] end ; *** NetLogo Model Copyright Notice *** ; ; 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. ; ; Copyright 1998 by Uri Wilensky. All rights reserved. ; ; Permission to use, modify or redistribute this model is hereby granted, ; provided that both of the following requirements are followed: ; a) this copyright notice is included. ; b) this model will not be redistributed for profit without permission ; from Uri Wilensky. ; Contact Uri Wilensky for appropriate licenses for redistribution for ; profit. ; ; This model was converted to NetLogo as part of the project: ; PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN ; CLASSROOMS. The project gratefully acknowledges the support of the ; National Science Foundation (REPP program) -- grant number REC #9814682. ; Converted from StarLogoT to NetLogo, 2001. Updated 2002. ; ; To refer to this model in academic publications, please use: ; Wilensky, U. (1998). NetLogo Pursuit model. ; http://ccl.northwestern.edu/netlogo/models/Pursuit. ; Center for Connected Learning and Computer-Based Modeling, ; Northwestern University, Evanston, IL. ; ; In other publications, please use: ; Copyright 1998 by Uri Wilensky. All rights reserved. See ; http://ccl.northwestern.edu/netlogo/models/Pursuit ; for terms of use. ; ; *** End of NetLogo Model Copyright Notice *** @#$#@#$#@ GRAPHICS-WINDOW 273 7 645 400 90 90 2.0 0 10 1 1 1 CC-WINDOW 273 403 635 523 Command Center BUTTON 5 347 60 380 Go go T 1 T OBSERVER T SLIDER 5 110 128 143 step-size step-size 1.0 5.0 1.0 1.0 1 NIL SLIDER 5 68 128 101 num-followers num-followers 0 50 4 1 1 NIL SWITCH 139 68 266 101 show-leader show-leader 1 1 -1000 SWITCH 139 110 265 143 show-trail show-trail 1 1 -1000 BUTTON 22 183 92 216 Random setup\nset choice (random 11) NIL 1 T OBSERVER T BUTTON 22 216 92 249 Linear setup\nset choice 0 NIL 1 T OBSERVER T BUTTON 98 183 168 216 Quadratic setup\nset choice 1 NIL 1 T OBSERVER T BUTTON 98 216 168 249 -Quadratic setup\nset choice 2 NIL 1 T OBSERVER T BUTTON 98 249 168 282 Cubic setup\nset choice 3 NIL 1 T OBSERVER T BUTTON 98 282 168 315 Logarithmic setup\nset choice 4 NIL 1 T OBSERVER T BUTTON 174 282 254 315 Exponential setup\nset choice 5 NIL 1 T OBSERVER T BUTTON 174 249 254 282 Hyperbolic setup\nset choice 8 NIL 1 T OBSERVER T BUTTON 22 249 92 282 Horizontal setup\nset choice 9 NIL 1 T OBSERVER T BUTTON 22 282 92 315 Vertical setup\nset choice 10 NIL 1 T OBSERVER T BUTTON 174 183 244 216 Sine setup\nset choice 6 NIL 1 T OBSERVER T BUTTON 174 216 244 249 Cosine setup\nset choice 7 NIL 1 T OBSERVER T BUTTON 5 412 60 445 Reveal reveal NIL 1 T OBSERVER T BUTTON 65 347 132 380 Go Once go NIL 1 T OBSERVER T TEXTBOX 5 158 147 176 Equation Setup Buttons: TEXTBOX 5 325 110 343 Execution: TEXTBOX 5 390 264 408 Reveal the Leader's Trail and Position: TEXTBOX 5 39 95 57 Setup Options: SLIDER 136 346 262 379 slowdown slowdown 0.0 50.0 7.0 1.0 1 NIL @#$#@#$#@ WHAT IS IT? ----------- In this model there is one leader turtle and a group of follower turtles. The leader moves along a path according to a preselected formula (such as y = x^2). The followers move toward the leader with each step. The followers update their pursuit path each time the leader moves. Have a little fun -- hide the leader and try to guess the path along which it is moving. Clues to the leader's path are found by observing the paths of the followers. HOW TO USE IT ------------- General Settings: Use the NUM-FOLLOWERS slider to select how many followers will participate in the pursuit. If exactly 4 followers are selected, they will be placed at the four corners of the screen. If a different number is selected, the followers will be placed at random locations on the screen. Use the STEP-SIZE slider to decide how far from its current location a follower will move after each step of the leader. How steps are implemented: - The leader starts at the left edge of the screen. - The leader always moves from left to right by one unit increments along the x-axis. Be aware, for several functions, however, the function is scaled by some factor so that its shape fits well within the graphics window. - The leader's y coordinate is based on the selected formula and the current x coordinate. For example, if the current formula is y = x^2 and the leader's current xcor value is -3, the ycor value will be set to 9. - The follower's heading is set using the TOWARDS-NOWRAP function. - Followers move forward in increments of STEP-SIZE. X and Y Axes: The light gray lines that are drawn once SETUP is pressed are the x-axis and the y-axis. Leader Switches: SHOW-LEADER makes the leader shown or hidden. This switch must be set before SETUP is pressed. When the switch is set to on, the leader will be visible. When the switch is set to off, the leader will be hidden. SHOW-TRAIL, when turned on, causes the leader to stamp at each location determined by its formula. This switch may be turned on and off at any time during the pursuit. When the switch is set to on, the trail will be visible. When the switch is set to off, the trail will be hidden. Press RANDOM or any of the fucntion buttons when all of the above selections have been made. This will create the leader and the selected number of followers. RANDOM chooses a random function for the leader to follow, and is best used with SHOW-LEADER and SHOW-TRAIL turned off so that the function can be guessed based on the movements of the followers. The other buttons choose a specific function for the leader to follow. Press GO-ONCE to make the leader increment its xcor value by one and to make the followers take one step toward the leader. Press GO to make the leader and followers move continuously. To stop them, press the GO button again. The SLOWDOWN slider controls how fast all of the turtles move. Press REVEAL after the model is done to see what the path of the leader was if SHOW-TRAIL was turned off. You can use this to check your guess as to what the function was. RUNNING THE MODEL ----------------- Try starting with 4 followers with a step size of 1. Do not show the leader or the leader's trail. Use settings so that the graphics window is square. Press RANDOM then press GO. See if you can guess the formula the leader is using by observing the path of each follower. For each of the next questions, consider the follow-up questions Why or why not? How can you tell? Does the speed of the leader seem to change over time? Does the speed of a follower seem to change over time? Do all followers travel at the same speed? What can you tell about the leader's formula based on the path of each follower? What traits of each follower's path give you information about the leader's formula? Which of these traits do you find most helpful? Why? To Change the Formula for the Leader: A number of formulas have been stored in the procedures for this model. To explicitly make a given formula active, choose the button for the formula you want instead of RANDOM. See the EXTENDING THE MODEL section for instructions on how to add your own formulas to the model. THINGS TO NOTICE ---------------- There are several characteristics of each follower's path and the leader's trail that are worth noting. Follower Path Slope: What does it mean if the slope of the path is increasing? What does it mean if the slope of the path is decreasing? What does it mean if one section of the path has a steeper slope than another part? What does it mean if the slope of the path is constant? To think about the slope of a path, consider whether the path appears to be going 'uphill' or 'downhill' and consider whether the 'hill' is steep or flat. Follower Path Concavity: What does it mean if the path has a section that is concave up? What does it mean if the path has a section that is concave down? What does it mean if the path has sections of both of these types? What does it mean if the path has neither concave up nor concave down sections? A path that is concave up will be shaped like part of an upright coffee cup. A path that is concave down will be shaped like part of an upside down coffee cup. Relationships Between Paths: Do the paths have any symmetry? Would you expect them to? Why or why not? Distances Between the Leader and a Follower: Once you have determined the formula for the leader, run a simulation with the leader's trail turned on. (Note that there are other suggestions to verify your answer in the THINGS TO TRY section. Make sure you have tried at least some of these before you show the trail. If you show the trail before you are really sure you are right, you might end up spoiling all your fun- there's no going back once you have seen the trail of the leader!) Find a path where a follower seems to get close to the leader only to have the leader appear to speed up and escape from the follower. Why does this happen? What kinds of generalizations can you make about the formulas or relationships for which this happens? How do the distances between the leader's trail stamps relate to the perceived speed of the leader? Leader Stamp Proximity: Depending on the path that the leader is following, the leader's trail stamps may not be evenly spaced. What does it mean when the steps are evenly spaced? What does it mean when the steps are not evenly spaced? What does it mean when the stamps are closer together? What does it mean when the stamps are further apart? THINGS TO TRY ------------- Try moving followers to specific locations after SETUP has been pressed but before GO has been pressed. Make predictions about how different locations would be helpful. What can you learn if a follower starts in any of the following locations? - along the right edge of the screen - along the left edge of the screen - along the top edge of the screen - along the bottom edge of the screen - along the x-axis - along the y-axis - at the origin What is the most helpful first location for a follower? (The location on top of the leader is, of course, out of the question!) What is the most helpful follow-up location for a single follower or for a group of followers? Come up with a strategy for placing followers so that you can determine the path of the leader fairly quickly. Describe your strategy. You may use the command center, or the turtle window to move a follower. The leader is turtle 0, the followers are all turtles with who > 0. Try increasing the number of followers. (Even if you think you have the formula figured out, try using larger NUM-FOLLOWERS values before you show the leader or the leader's trail. ) Why does using a larger NUM-FOLLOWERS value make it easier to guess the leader's formula? Try increasing the STEP-SIZE of the followers. (Even if you think you have the formula figured out, try using larger STEP-SIZE values before you show the leader or the leader's trail. ) Why does using a larger STEP-SIZE value make it easier to guess the leader's formula? The above discussions all involve trying to guess the path of the leader. Alternately, you can know the formula of the leader and try to guess the paths of the followers. If you know a leader's formula and are trying to guess the pattern of the followers' paths, make sure to record you guess before you run the simulation. Compare your predicted results with the actual results. - What reasoning led you to correct predictions? - What assumptions that you made need to be revised? EXTENDING THE MODEL ------------------- To add your own formulas, you need to add a new Leader Procedure to the model (the others are declared at the bottom of the procedures window. Add your formula to the current list. - Within the set of commands you may need to scale the y-axis to keep the leader from wrapping. (See for example, the cubic function.) - You must restrict the domain of the leader if your formula has values for which it would be undefined. (See, for example, the logarithm function.) - Add formula-name to the MOVE-LEADER procedure and add a button for the choice. - Increment the number after 'random' in the RANDOM button code to add your function to the list of possible functions that RANDOM will choose. In this simulation, the leader uses only integer x coordinates. For which formulas might the results be different if the leader moved along smaller intervals? What would happen if the STEP-SIZE of the followers was always set to equal the distance the leader traveled during its most recent step? Adjust the procedures so that rectangular graphics windows do not cause unexpected wrapping. Do any of these changes impact answers to any of the questions asked above? Create leader functions and pick a follower location to get the following shapes in the follower's path: - a straight line with positive slope - a straight line with negative slope - a horizontal line - a vertical line - a loop - a circle - a curve with one "hump" - a curve with two "humps" - a curve with three "humps" - a curve with n "humps" NETLOGO FEATURES ------------------- Switches are used to show or hide information about the leader. Coloring of patches is used to draw x and y axes on the graphics window. The TOWARDS-NOWRAP command is used to orient the followers. CREDITS AND REFERENCES ---------------------- To refer to this model in academic publications, please use: Wilensky, U. (1998). NetLogo Pursuit model. http://ccl.northwestern.edu/netlogo/models/Pursuit. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. In other publications, please use: Copyright 1998 by Uri Wilensky. All rights reserved. See http://ccl.northwestern.edu/netlogo/models/Pursuit for terms of use. @#$#@#$#@ default true 0 Polygon -7566196 true true 150 5 40 250 150 205 260 250 arrow true 0 Polygon -7566196 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 box true 0 Polygon -7566196 true true 45 255 255 255 255 45 45 45 circle true 0 Circle -7566196 true true 35 35 230 person false 0 Circle -7566196 true true 155 20 63 Rectangle -7566196 true true 158 79 217 164 Polygon -7566196 true true 158 81 110 129 131 143 158 109 165 110 Polygon -7566196 true true 216 83 267 123 248 143 215 107 Polygon -7566196 true true 167 163 145 234 183 234 183 163 Polygon -7566196 true true 195 163 195 233 227 233 206 159 spacecraft true 0 Polygon -7566196 true true 150 0 180 135 255 255 225 240 150 180 75 240 45 255 120 135 thin-arrow true 0 Polygon -7566196 true true 150 0 0 150 120 150 120 293 180 293 180 150 300 150 truck-down false 0 Polygon -7566196 true true 225 30 225 270 120 270 105 210 60 180 45 30 105 60 105 30 Polygon -8716033 true false 195 75 195 120 240 120 240 75 Polygon -8716033 true false 195 225 195 180 240 180 240 225 truck-left false 0 Polygon -7566196 true true 120 135 225 135 225 210 75 210 75 165 105 165 Polygon -8716033 true false 90 210 105 225 120 210 Polygon -8716033 true false 180 210 195 225 210 210 truck-right false 0 Polygon -7566196 true true 180 135 75 135 75 210 225 210 225 165 195 165 Polygon -8716033 true false 210 210 195 225 180 210 Polygon -8716033 true false 120 210 105 225 90 210 turtle true 0 Polygon -7566196 true true 138 75 162 75 165 105 225 105 225 142 195 135 195 187 225 195 225 225 195 217 195 202 105 202 105 217 75 225 75 195 105 187 105 135 75 142 75 105 135 105 @#$#@#$#@ NetLogo 2.0beta4 @#$#@#$#@ setup set choice 6 set slowdown 0 repeat 175 [ go ] @#$#@#$#@ @#$#@#$#@