;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Variable declarations ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;; globals [ grid-x-inc ;; the amount of patches in between two roads in the x direction grid-y-inc ;; the amount of patches in between two roads in the y direction acceleration ;; the constant that controls how much a car speeds up or slows down by if it is to accelerate or decelerate phase ;; keeps track of the phase clock ;; keeps track of the total times thru the go procedure num-cars-stopped ;; the number of cars that are stopped during a single pass thru the go procedure old-display-which-metric ;; holds the value of display-which-metric for the last time through the go procedure ;; patch agentsets intersections ;; agentset containing the patches that are intersections roads ;; agentset containing the patches that are roads ;; string and list variables that hold data passed accumulated in the model run wait-data ;; list that holds the average wait time of the cars for each pass through the go procedure stopped-data ;; list that holds the number of stopped of the cars for each pass through the go procedure speed-data ;; list that holds the average speed of the cars for each pass through the go procedure time-data ;; list that holds the value of clock for each pass through the go procedure ;;quick start instructions variables quick-start ;; the current quickstart instruction displayed in the quickstart monitor qs-item ;; the index of the current quickstart instruction qs-items ;; the list of quickstart instructions ] turtles-own [ speed ;; the speed of the turtle up-car? ;; this will be true if the turtle moves downwards and false if it moves to the right wait-time ;; the amount of time since the last time a turtle has moved ] patches-own [ intersection? ;; this is true if the patch is at the intersection of two roads accident? ;; this is true if a crash has occurred at this intersection. this will never be true for a non-intersection patch green-light-up? ;; this is true if the green light is above the intersection. otherwise, it is false. this is only true for patches that are intersections. my-row ;; this holds the row of the intersection counting from the upper left corner of the graphics window. it is -1 for patches that are not intersections. my-column ;; this holds the column of the intersection counting from the upper left corner of the graphics window. it is -1 for patches that are not intersections. user-id ;; this holds the user-id that corresponds to the intersection. it is -1 for patches that are not intersections. my-phase ;; this holds the phase for the intersection. it is -1 for patches that are not intersections. ] ;;;;;;;;;;;;;;;;;;;;; ;; Setup Functions ;; ;;;;;;;;;;;;;;;;;;;;; to startup setup true setup-quick-start hubnet-set-client-interface "COMPUTER" [ "clients/Gridlock client.nlogo" ] hubnet-reset end ;; Initialize the display by giving the global and patch variables initial values. ;; Create num-cars of turtles if there are enough road patches for one turtle to be created per road patch. ;; Setup the plots ;; All code in setup is done if full-setup? is true. If it is false, then it doesn't clear the information ;; about the users; users still retain the same light that they had before. ;; "setup false" is done by the re-run button. to setup [full-setup?] cc if full-setup? ;; We only want to clear the patches if the we are doing a full-setup [ clear-patches ] clear-turtles clear-all-plots setup-globals full-setup? ;; First we ask the patches to draw themselves and set up a few variables setup-patches full-setup? set-default-shape turtles "car" if (number > count roads) [ user-message "There are too many cars for the amount of road. " + "Either increase the amount of roads by increasing the GRID-SIZE-X " + "or GRID-SIZE-Y sliders, or decrease the number of cars by lowering " + "the NUMBER slider.\nThe setup has stopped." stop ] ;; Now create the turtles and have each created turtle call the functions setup-cars and set-car-color cct number [ setup-cars set-car-color record-data ] ;; give the turtles an initial speed ask turtles [ set-car-speed ] update-list-info setup-plots end ;; Initialize the global variables to appropriate values to setup-globals [full-setup?] set phase 0 set clock 0 set num-cars-stopped 0 if full-setup? [ set grid-x-inc screen-size-x / grid-size-x set grid-y-inc screen-size-y / grid-size-y ] ;; initialize the lists and string for HubNet set wait-data [] set stopped-data [] set speed-data [] set time-data [] ;; don't make acceleration 0.1 since we could get a rounding error and end up on a patch boundary set acceleration 0.099 end ;; Make the patches have appropriate colors, setup the roads and intersections agentsets, ;; and initialize the traffic lights to one setting to setup-patches [full-setup?] if full-setup? [ ;; initialize the patch-own variables and color the patches to a base-color ask patches [ set intersection? false set accident? false set green-light-up? true set my-row -1 set my-column -1 set user-id -1 set my-phase -1 set pcolor brown + 3 ] ;; initialize the global variables that hold patch agentsets set roads patches with [ (floor ((pxcor + screen-edge-x - floor(grid-x-inc - 1)) mod grid-x-inc) = 0) or (floor ((pycor + screen-edge-y) mod grid-y-inc) = 0) ] set intersections roads with [ (floor ((pxcor + screen-edge-x - floor(grid-x-inc - 1)) mod grid-x-inc) = 0) and (floor ((pycor + screen-edge-y) mod grid-y-inc) = 0) ] ask roads [ set pcolor white ] ] setup-intersections full-setup? end ;; Give the intersections appropriate values for the intersection?, my-row, and my-column ;; patch variables. Make all the traffic lights start off so that the lights are red ;; horizontally and green vertically. to setup-intersections [full-setup?] ask intersections [ set intersection? true set green-light-up? true set my-phase 0 if full-setup? [ set my-row floor ((pycor + screen-edge-y) / grid-y-inc ) set my-column floor ((pxcor + screen-edge-x) / grid-x-inc ) ] set-signal-colors ] end ;; Initialize the turtle variables to appropriate values and place the turtle on an empty road patch. to setup-cars ;; turtle procedure set speed 0 set wait-time 0 put-on-empty-road ifelse intersection? [ ifelse random 2 = 1 [ set up-car? true ] [ set up-car? false ] ] [ ifelse (floor ((pxcor + screen-edge-x - floor(grid-x-inc - 1)) mod grid-x-inc) = 0) [ set up-car? true ] [ set up-car? false ] ] ifelse up-car? [ set heading 180 ] [ set heading 90 ] end ;; Find a road patch without any turtles on it and place the turtle there. to put-on-empty-road ;; turtle procedure locals [road] set road random-one-of roads setxy (pxcor-of road) (pycor-of road) if any? other-turtles-here [ put-on-empty-road ] end ;; Initialize the plots to setup-plots set-current-plot "Stopped Cars" set-plot-y-range 0 number plot num-cars-stopped set-current-plot "Average Wait Time of Cars" plot mean values-from turtles [wait-time] set-current-plot "Average Speed of Cars" set-plot-y-range 0 speed-limit plot mean values-from turtles [speed] end ;; give the user some information about what the setup button does so they can ;; know whether they want to proceed before actually doing the setup to setup-prompt if user-yes-or-no? ("The SETUP button should only be used when starting " + "over with a new group (such as a new set of students) since " + "all data is lost. Use the RE-RUN button for continuing with " + "an existing group." + "\n\nDo you really want to setup the model?") [ setup true ] end ;;;;;;;;;;;;;;;;;;;;;;; ;; Runtime Functions ;; ;;;;;;;;;;;;;;;;;;;;;;; ;; receives information from the clients and runs the simulation to go every delay [ ;; get commands and data from the clients listen-clients ;; clear any accidents from the last time thru the go procedure clear-accidents ;; if there are any intersections that are to switch automatically, have them change their color set-signals set num-cars-stopped 0 ;; set the turtles speed for this time thru the procedure, move them forward their speed, ;; record data for plotting, and set the color of the turtles ;; to an appropriate color based on their speed ask turtles [ set-car-speed fd speed record-data set-car-color ] ;; crash the cars if crash? is true if crash? [ crash-cars ] ;; update the information in the lists of plot data update-list-info ;; update the plots with the new information from this pass thru the procedure do-plotting ;; update the clock and the phase clock-tick ] end ;; reports the amount of seconds by which to slow the model down to-report delay ifelse simulation-speed <= 0 [ report ln (10 / 0.001) ] [ report ln (10 / simulation-speed) ] end ;; have the traffic lights change color if phase equals each intersections' my-phase to set-signals locals [ intersections-to-change ] ifelse auto? [ set intersections-to-change intersections with [phase = floor ((my-phase * ticks-per-cycle) / 100)] ] [ set intersections-to-change intersections with [user-id = -1 and phase = floor ((my-phase * ticks-per-cycle) / 100)] ] ask intersections-to-change [ set green-light-up? (not green-light-up?) set-signal-colors ] end ;; This procedure checks the variable green-light-up? at each intersection and sets the ;; traffic lights to have the green light up or the green light to the left. to set-signal-colors ;; intersection (patch) procedure ifelse power? [ ifelse green-light-up? [ set (pcolor-of patch-at -1 0) red set (pcolor-of patch-at 0 1) green ] [ set (pcolor-of patch-at -1 0) green set (pcolor-of patch-at 0 1) red ] ] [ set (pcolor-of patch-at -1 0) white set (pcolor-of patch-at 0 1) white ] end ;; set any intersection's color that had an accident back to white and make accident? false to clear-accidents if crash? [ ask patches with [accident?] [ set pcolor white set accident? false ] ] end ;; set the turtles' speed based on whether they are at a red traffic light or the speed of the ;; turtle (if any) on the patch in front of them to set-car-speed ;; turtle procedure ifelse pcolor = red [ set speed 0 ] [ ifelse up-car? [ set-speed 0 -1 ] [ set-speed 1 0 ] ] end ;; set the speed variable of the turtle to an appropriate value (not exceeding the ;; speed limit) based on whether there are turtles on the patch in front of the turtle to set-speed [delta-x delta-y] ;; turtle procedure locals [ up-cars?-ahead turtles-ahead ] ;; get the turtles on the patch in front of the turtle ask patch-at delta-x delta-y [ set turtles-ahead turtles-here ] ;; if there are turtles in front of the turtle, slow down ;; otherwise, speed up ifelse any? turtles-ahead [ set up-cars?-ahead values-from turtles-ahead [up-car?] ifelse member? up-car? up-cars?-ahead and member? (not up-car?) up-cars?-ahead [ if not crash? [ set speed 0 ] ] [ set speed speed-of one-of turtles-ahead slow-down ] ] [ speed-up ] end ;; decrease the speed of the turtle to slow-down ;; turtle procedure ifelse speed <= 0 ;;if speed < 0 [ set speed 0 ] [ set speed speed - acceleration ] end ;; increase the speed of the turtle to speed-up ;; turtle procedure ifelse speed > speed-limit [ set speed speed-limit ] [ set speed speed + acceleration ] end ;; set the color of the turtle to a different color based on how fast the turtle is moving to set-car-color ;; turtle procedure ifelse speed < (speed-limit / 2) [ set color blue ] [ set color cyan - 2 ] end ;; keep track of the number of stopped turtles and the amount of time a turtle has been stopped ;; if its speed is 0 to record-data ;; turtle procedure ifelse speed = 0 [ set num-cars-stopped num-cars-stopped + 1 set wait-time wait-time + 1 ] [ set wait-time 0 ] end ;; crash any turtles at the same intersection going in different directions to crash-cars ask intersections with [any? turtles-here with [up-car?] and any? turtles-here with [not up-car?]] [ set accident? true set pcolor orange ] end ;; add the new information from this pass thru the go procedure to the HubNet lists to update-list-info set wait-data lput (mean values-from turtles [wait-time]) wait-data set stopped-data lput num-cars-stopped stopped-data set speed-data lput (mean values-from turtles [speed]) speed-data set time-data lput clock time-data end ;; plot the data from this pass thru the go procedure to do-plotting ifelse display-which-metric = old-display-which-metric [ ;; don't plot if no plots should be plotted if display-which-metric != 0 [ ;; we only need to plot 1 value since the current plot is the same as the plot we are supposed to plot to now ifelse display-which-metric = 1 [ plot-new-value "Stopped Cars" num-cars-stopped ] [ ifelse display-which-metric = 2 [ plot-new-value "Average Speed of Cars" mean values-from turtles [speed] ] [ ifelse display-which-metric = 3 [ plot-new-value "Average Wait Time of Cars" mean values-from turtles [wait-time] ] [ ;; therefore display-which-metric = 4 plot-new-value "Stopped Cars" num-cars-stopped plot-new-value "Average Wait Time of Cars" mean values-from turtles [wait-time] plot-new-value "Average Speed of Cars" mean values-from turtles [speed] ] ] ] ] ] [ ;; otherwise, we need to plot at least 1 list since the plot we are supposed to plot to is different from the plot we last plotted in ifelse display-which-metric = 0 [ clear-all-plots ] [ ifelse display-which-metric = 1 [ clear-plots-and-plot-in-new-plot "Stopped Cars" stopped-data ] [ ifelse display-which-metric = 2 [ clear-plots-and-plot-in-new-plot "Average Speed of Cars" speed-data ] [ ifelse display-which-metric = 3 [ clear-plots-and-plot-in-new-plot "Average Wait Time of Cars" wait-data ] [ ;; therefore display-which-metric = 4 ifelse old-display-which-metric = 1 [ plot-value-and-lists "Stopped Cars" num-cars-stopped "Average Speed of Cars" speed-data "Average Wait Time of Cars" wait-data ] [ ifelse old-display-which-metric = 2 [ plot-value-and-lists "Average Speed of Cars" (mean values-from turtles [speed]) "Stopped Cars" stopped-data "Average Wait Time of Cars" wait-data ] [ ifelse old-display-which-metric = 3 [ plot-value-and-lists "Average Wait Time of Cars" (mean values-from turtles [wait-time]) "Stopped Cars" stopped-data "Average Speed of Cars" speed-data ] [ ;; therefore old-display-which-metric = 0 plot-new-list "Stopped Cars" stopped-data plot-new-list "Average Speed of Cars" speed-data plot-new-list "Average Wait Time of Cars" wait-data ] ] ] ] ] ] ] set old-display-which-metric display-which-metric ] end to plot-new-value [name-of-plot value] set-current-plot name-of-plot plot value end to clear-plots-and-plot-in-new-plot [name-of-plot list-to-plot] clear-all-plots plot-new-list name-of-plot list-to-plot end to plot-new-list [name-of-plot list-to-plot] locals [index] set index 0 set-current-plot name-of-plot clear-plot repeat length list-to-plot [ plot item index list-to-plot set index index + 1 ] end to plot-value-and-lists [value-plot value list-plot1 list-to-plot1 list-plot2 list-to-plot2] plot-new-value value-plot value plot-new-list list-plot1 list-to-plot1 plot-new-list list-plot2 list-to-plot2 end ;; increases the clock by 1 and cycles phase to the next appropriate value to clock-tick set clock clock + 1 ;; The phase cycles from 0 to ticks-per-cycle, then starts over. set phase phase + 1 if phase mod ticks-per-cycle = 0 [ set phase 0 ] end ;; update the plots to show the current value of display-which-metric ;; done only by the Refresh Plots button to show-current-metric-in-plots if display-which-metric != old-display-which-metric [ ;; we need to plot at least 1 list since the plot we are supposed to plot to is different from the plot we last plotted in ifelse display-which-metric = 0 [ clear-all-plots ] [ ifelse display-which-metric = 1 [ clear-plots-and-plot-in-new-plot "Stopped Cars" stopped-data ] [ ifelse display-which-metric = 2 [ clear-plots-and-plot-in-new-plot "Average Speed of Cars" speed-data ] [ ifelse display-which-metric = 3 [ clear-plots-and-plot-in-new-plot "Average Wait Time of Cars" wait-data ] [ ;; therefore display-which-metric = 4 ifelse old-display-which-metric = 1 [ plot-new-list "Average Speed of Cars" speed-data plot-new-list "Average Wait Time of Cars" wait-data ] [ ifelse old-display-which-metric = 2 [ plot-new-list "Stopped Cars" stopped-data plot-new-list "Average Wait Time of Cars" wait-data ] [ ifelse old-display-which-metric = 3 [ plot-new-list "Stopped Cars" stopped-data plot-new-list "Average Speed of Cars" speed-data ] [ ;; therefore old-display-which-metric = 0 plot-new-list "Stopped Cars" stopped-data plot-new-list "Average Speed of Cars" speed-data plot-new-list "Average Wait Time of Cars" wait-data ] ] ] ] ] ] ] set old-display-which-metric display-which-metric ] end ;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Quick Start functions ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; instructions to quickly setup the model, and clients to run this activity to setup-quick-start set qs-item 0 set qs-items [ "Teacher: Follow these directions to setup the HubNet activity." "Optional: Zoom In (see Tools in the Menu Bar)" "Change the traffic grid (using the sliders GRID-SIZE-X and..." "GRID-SIZE-Y) to make enough lights for everyone." "Change any other of the settings that you would like to change." "For example, if you plan on running Gridlock in..." "the MANUAL mode, be sure to have AUTO? set to OFF." "Press the NetLogo SETUP button." "Press the INITIAL LOGIN button." "Everyone: Open the HubNet Client on your machine and..." "input the IP Address of this computer, type..." "your user name in the user name box and press ENTER" "Teacher: Once everyone is logged in and has a light..." "stop the INITIAL LOGIN button by pressing it again." "Everyone: Whichever mode AUTO? is set for in NetLogo,..." "you will control your intersection in a different way." "If you have chosen MANUAL,..." "you can change the state of your light by pressing..." "the CHANGE LIGHT button." "If you have chosen AUTO,..." "you can change the phase of your light by moving..." "the PHASE slider to a different position." "Teacher: Once everyone is ready,..." "start the simulation by pressing the GO button." "Teacher: You may want to view some of the plots." "Do this by changing the DISPLAY-WHICH-METRIC slider,..." "which changes the plot displayed for everyone." "Choose 0 to turn off all the plots..." "Choose 1 to see the STOPPED CARS plot..." "Choose 2 for the AVERAGE SPEED plot..." "Choose 3 for the AVERAGE WAIT plot..." "or Choose 4 for all the plots..." "Teacher: To rerun the activity with the same group,..." "stop the model by pressing the NetLogo GO button, if it is on." "Change any of the settings that you would like." "Press the NetLogo RE-RUN button." "Teacher: Once everyone is ready,..." "restart the simulation by pressing the GO button." "Teacher: To start the simulation over with a new group,..." "stop the model by pressing the NetLogo GO button, if it is on..." "and follow these instructions again from the beginning." ] set quick-start (item qs-item qs-items) end ;; view the next item in the quickstart monitor to view-next set qs-item qs-item + 1 if qs-item >= length qs-items [ set qs-item length qs-items - 1 ] set quick-start (item qs-item qs-items) end ;; view the previous item in the quickstart monitor to view-prev set qs-item qs-item - 1 if qs-item < 0 [ set qs-item 0 ] set quick-start (item qs-item qs-items) end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Code for interacting with the clients ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; when a command is sent, find out which client sent it and then execute the command to listen-clients ;; use without-interruption to eliminate the possibility that if both the GO and ;; INITIAL-LOGIN buttons are pressed that they both try processing the same message without-interruption [ while [hubnet-message-waiting?] [ hubnet-fetch-message ifelse hubnet-enter-message? [ give-intersection-coords wait 1 ;; we want to give some time for other clients to log in on this round ] [ ifelse hubnet-exit-message? [ abandon-intersection ] [ ifelse hubnet-message-tag = "Change Light" [ manual hubnet-message-source ] [ if hubnet-message-tag = "Phase" [ auto hubnet-message-source ] ] ] ] ] ] end ;; when a new client logs in, if there are free intersections, ;; assign one of them to that client ;; if this current-id already has an intersection, give the client that intersection. to give-intersection-coords locals [current-id] set current-id hubnet-message-source ifelse not any? intersections with [user-id = current-id] [ ;; the case where they tried logging in previously but there was no room for them ;; or they haven't logged in before get-free-intersection current-id ] [ ;; otherwise, we already have an intersection for the current-id. ;; all we need to do is send where the light is located at ask intersections with [user-id = current-id] [ hubnet-send current-id "Located At:" ("(" + my-column + "," + my-row + ")") ] ] end ;; when a client disconnects, free up its intersection to abandon-intersection ask intersections with [user-id = hubnet-message-source] [ set user-id -1 set my-phase 0 set plabel-of patch-at -1 1 no-label ] end ;; if there are any free intersections, pick one of them at random and give it to the current-id. ;; if there are not any free intersections, toss an error and put error values into the list to get-free-intersection [current-id] ifelse any? intersections with [user-id = -1] [ ;; pick a random intersection that hasn't been taken yet ask random-one-of intersections with [user-id = -1] [ set user-id current-id ask patch-at -1 1 [ set plabel-color black set plabel current-id ] hubnet-send current-id "Located At:" ("(" + my-column + "," + my-row + ")") ] ] [ hubnet-send current-id "Located At:" "Not enough lights" user-message "Not enough lights for student with id: " + current-id ] end ;; switch the traffic lights at the intersection for the client with user-id to manual [current-id] if not auto? [ ask intersections with [user-id = current-id] [ set green-light-up? (not green-light-up?) set-signal-colors ] ] end ;; change the value of the phase for the intersection at (xc,yc) to ;; the value passed by the client to auto [current-id] ask intersections with [user-id = current-id] [ set my-phase hubnet-message ] end ; *** NetLogo Model Copyright Notice *** ; ; This activity and associated models and materials was created as part of the projects: ; PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and ; INTEGRATED SIMULATION AND MODELING ENVIRONMENT. ; These projects gratefully acknowledge the support of the ; National Science Foundation (REPP & ROLE programs) -- grant numbers ; REC #9814682 and REC-0126227. ; ; Copyright 2002 by Uri Wilensky & Walter Stroup. Updated 2002. 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 the copyright holders. ; Contact the copyright holders for appropriate licenses for redistribution ; for profit. ; ; To refer to this model in academic publications, please use: ; Wilensky, U. & Stroup, W. (2002). NetLogo HubNet Gridlock model. ; http://ccl.northwestern.edu/netlogo/models/HubNetGridlock. ; Center for Connected Learning and Computer-Based Modeling, ; Northwestern University, Evanston, IL. ; ; In other publications, please use: ; Copyright 1998 by Uri Wilensky and Walter Stroup. All rights reserved. See ; http://ccl.northwestern.edu/netlogo/models/HubNetGridlock ; for terms of use. ; ; *** End of NetLogo Model Copyright Notice *** @#$#@#$#@ GRAPHICS-WINDOW 283 96 663 497 18 18 10.0 1 10 0 0 0 CC-WINDOW 665 332 844 497 Command Center TEXTBOX 4 361 278 457 This slider determines which plot is drawn.\n0=no plots\n1=stopped cars\n2=average speed\n3=average wait\n4=all three plots SLIDER 1 464 166 497 display-which-metric display-which-metric 0 4 0 1 1 NIL BUTTON 102 243 197 276 Initial Login listen-clients T 1 T OBSERVER T PLOT 565 500 844 689 Average Wait Time of Cars Time Average Wait 0.0 100.0 0.0 5.0 true false PENS "default" 1.0 0 -65536 true PLOT 283 500 562 689 Average Speed of Cars Time Average Speed 0.0 100.0 0.0 1.0 true false PENS "default" 1.0 0 -65536 true BUTTON 288 60 406 93 Reset Instructions setup-quick-start NIL 1 T OBSERVER T BUTTON 574 60 658 93 NEXT >>> view-next NIL 1 T OBSERVER T BUTTON 497 60 575 93 <<< PREV view-prev NIL 1 T OBSERVER T MONITOR 288 10 658 59 Quick Start Instructions- More in Info Window quick-start 0 1 SLIDER 97 41 194 74 grid-size-y grid-size-y 1 9 5 1 1 NIL SLIDER 1 41 95 74 grid-size-x grid-size-x 1 9 5 1 1 NIL SWITCH 98 113 188 146 auto? auto? 1 1 -1000 SWITCH 190 113 280 146 crash? crash? 1 1 -1000 SWITCH 1 113 96 146 power? power? 0 1 -1000 SLIDER 1 77 280 110 number number 0 400 200 1 1 cars PLOT 1 500 280 689 Stopped Cars Time Stopped Cars 0.0 100.0 0.0 100.0 true false PENS "default" 1.0 0 -65536 true BUTTON 216 243 280 276 Go go T 1 T OBSERVER T SLIDER 1 149 153 182 simulation-speed simulation-speed 0 10.0 7.5 0.1 1 NIL BUTTON 196 41 280 74 Setup setup-prompt NIL 1 T OBSERVER T SLIDER 155 149 280 182 speed-limit speed-limit 0.0 1.0 1.0 0.1 1 NIL BUTTON 1 243 82 276 Re-Run setup false NIL 1 T OBSERVER T MONITOR 175 185 280 234 Current Phase phase 3 1 SLIDER 1 201 173 234 ticks-per-cycle ticks-per-cycle 1 100 20 1 1 NIL BUTTON 168 464 280 497 Refresh Plots show-current-metric-in-plots NIL 1 T OBSERVER T @#$#@#$#@ WHAT IS IT? ----------- Students control traffic lights in a real-time traffic simulation. The teacher controls overall variables, such as the speed limit and the number of cars. This allows students to explore traffic dynamics, which can lead into many areas of study, from calculus to social studies. Challenge the students to develop strategies to improve traffic and discuss the different ways to measure the quality of traffic. The coordinates for the traffic lights are based on the first quadrant of the Cartesian plane. Therefore, the traffic light with the coordinates (0,0) is in the lowest row and the left-most column. The traffic light above it has coordinates (0,1) and the traffic light to the right of it has (1,0). This activity uses Gridlock client.nlogo for the HubNet Client interface. For further documentation, see the Participatory Simulations Guide found at http://ccl.northwestern.edu/ps/ HOW TO USE IT ------------- QUICKSTART INSTRUCTIONS: ------------------------ Contains instructions as to how to quickly setup the model, and clients to run this activity. The instructions can be found below and can be seen progressively in the Quick Start instructions monitor in the Interface: Teacher: Follow these directions to setup the HubNet activity. Optional: Zoom In (see Tools in the Menu Bar) Change the traffic grid (using the sliders GRID-SIZE-X and GRID-SIZE-Y) to make enough lights for everyone. Change any other of the settings that you would like to change. For example, if you plan on running Gridlock in the MANUAL mode, be sure to have AUTO? set to OFF. Press the NetLogo SETUP button. Press the INITIAL LOGIN button. Everyone: Open up a HubNet Client on your machine and input the IP Address of this computer, type your user name in the user name box and press ENTER. Teacher: Once everyone is logged in and has a light stop the INITIAL LOGIN button by pressing it again. Everyone: Whichever mode AUTO? is set for in NetLogo, you will control your intersection in a different way: If you have chosen MANUAL, you can change the state of your light by pressing the CHANGE LIGHT button. If you have chosen AUTO, you can change the phase of your light by moving the PHASE slider to a different position. Teacher: Once everyone is ready, start the simulation by pressing the GO button. Teacher: You may want to view some of the plots. Do this by changing the DISPLAY-WHICH-METRIC slider, which changes the plot displayed for everyone. - Choose 0 to turn off all the plots. - Choose 1 to see the STOPPED CARS plot. - Choose 2 for the AVERAGE SPEED OF CARS plot. - Choose 3 for the AVERAGE WAIT TIME OF CARS plot. - Choose 4 for all the plots. Teacher: To rerun the activity with the same group, stop the model by pressing the NetLogo GO button, if it is on. Change the values of the sliders and switches to the values you want for the new run. Press the NetLogo RE-RUN button. Once everyone is ready, restart the simulation by pressing the GO button. Teacher: To start the simulation over with a new group, stop the model by pressing the NetLogo GO button, if it is on and follow these instructions again from the beginning. BUTTONS: -------- SETUP - generates a new traffic grid based on the current GRID-SIZE-X and GRID-SIZE-Y and NUM-CARS number of cars. This also clears all the plots. This should only be pressed when starting out with a new group of users since all users associated with a traffic light will be disassociated from that traffic light. RE-RUN - allows you to keep the current traffic light/calculator associations, but clears the plots and after deleting all the currently existing cars, creates NUM-CARS number of cars. This does not change the grid size. This should be used to setup the model again for collecting more data or running the model again with the same users connected. GO - runs the simulation indefinitely INITIAL LOGIN - allows users to log into the activity without running the model or collecting data REFRESH PLOTS - redraws the plots based on the current value of DISPLAY-WHICH-METRIC. Useful for looking at different plots when GO is off. NEXT>>> - shows the next quick start instruction <<