Parking with information
Model was written in NetLogo 5.2.0
•
Viewed 311 times
•
Downloaded 23 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
Globals [ticks1 z1 w1 t1 walk avgwalk] turtles-own [parktimer distparked diststart disttraveled parked] ;;parked is a boolean indicating whether a car is parked or not ;;parktimer is a counter that counts down to when a parked car departs ;;ticks2 is a counter that resets every time a new car is created ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ to setup clear-all setup-patches setup-turtles reset-ticks set w1 list "null" "Walking Distance" set t1 list "null" "Walking Distance" set z1 round(random-exponential arrival_headway) end ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ to setup-patches ask patch 0 1 [ set pcolor 75] ask patches with [ pycor = -1] [ set pcolor green if (pxcor mod 2 = 0) [ set pcolor green + 2 ] ] ask patches with [pycor = 0] [ set pcolor gray ] end ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ to setup-turtles ask n-of 1 patches with [pycor = -1] [ sprout 1 [set parktimer round((random-exponential depart_headway))] ] ;print max [count turtles-here] of patches ask turtles with [who > 0] [ set color blue set shape "car" set heading 90 set pcolor red ] Ask turtle 0 [ set color orange set shape "car" set heading 90 set xcor (- startposition) ;;This xcor indicates the spot where someone will start searching set ycor 0 ;;ycor of 0 indicates this car is on the road set diststart abs(xcor) set parked false ] end ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ to advance ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ifelse ticks = 0 [] [ ;;This is the arrival rate/creation of new cars searching for parking ifelse (ticks1 >= z1 and (not any? turtles-on patches with [(pycor = 0) and (pxcor = (- startposition))])) [ create-turtles 1 [ set color orange - 2 set shape "car" set heading 90 set xcor (- startposition) set diststart xcor set parked false set parktimer round(random-exponential depart_headway) ] set ticks1 0 set z1 round(random-exponential arrival_headway) ] [ set ticks1 ticks1 + 1 ] ] ask turtles with [ (color = orange) and (ycor = 0)] [ ifelse( any? turtles-on patch-at 0 -1) [ forward 1 ] [ right 90 forward 1 set pcolor red set distparked abs(xcor) set disttraveled (xcor + startposition) set w1 lput (abs(distparked)) w1 set t1 lput (disttraveled) t1 set parked true let walk1 but-first w1 set walk but-first walk1 set avgwalk (sum walk / length walk) ] ] ask turtles with [ (color = orange - 2) and (ycor = 0)] [ set color orange ] ask turtles with [color = yellow] [ forward 1 ] ask turtles with [ycor = -1] ;;Departure code-- Cars will depart when their parktimer is 0. Parktimer is set randomly (exponentially) upon creation. [ ifelse (parktimer <= 0 and (not any? turtles-on patch-at 0 1 )) [ depart ] [ set parktimer (parktimer - 1) ] ] ask turtles with [ (xcor = max-pxcor) and (color = yellow)] [ die ] tick end ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ to depart set pcolor blue set ycor 0 set heading 90 set color yellow end ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There is only one version of this model, created over 9 years ago by zhibin chen.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Parking with information.png | preview | Preview for 'Parking with information' | over 9 years ago, by zhibin chen | Download |
This model does not have any ancestors.
This model does not have any descendants.