Parking model on street

No preview image

1 collaborator

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 4.1.3 • Viewed 644 times • Downloaded 61 times • Run 0 times
Download the 'Parking model  on street' modelDownload this modelEmbed this model

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


WHAT IS IT?

This section could give a general understanding of what the model is trying to show or explain.

HOW IT WORKS

This section could explain what rules the agents use to create the overall behavior of the model.

HOW TO USE IT

This section could explain how to use the model, including a description of each of the items in the interface tab.

THINGS TO NOTICE

This section could give some ideas of things for the user to notice while running the model.

THINGS TO TRY

This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.

EXTENDING THE MODEL

This section could give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc.

NETLOGO FEATURES

This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.

RELATED MODELS

This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.

CREDITS AND REFERENCES

This section could contain a reference to the model's URL on the web if it has one, as well as any other necessary credits or references.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Parking model
;; The aim of the model is to simulate cars who park in a street
;; The cars may not park on parking space which are occupied
;; The cars prefer a parking space which isn't surrounded by another car

to setup ;; to create the world
ca ;; delete everything
crt num-turtles;; creates the number of turtles has is indicated by the slider
;; Some cars are one the road , the other cars are situated on the parking spaces
;; the turtles 1-4 are random situated on the road, they have a different color
;; there are no cars on the line (-10 0) (10 -0) so that the cars don't influence each other
;; the turtles 4 - 14 are random situated on the parking spaces beneath the road, they have a blue collor
;; the turtles 15 - 30 are random situated on the parking spaces above the road, they have a blue collor
;; the road are the patches between the coordinates (-10 1) and (10 -1); the patches (-10 0 ) (10 0) form a line which spit the road in 2 parts
;; the parking spaces above are the patches between (-10 2) and (10 2)
;; the parking spaces beneath are the patches between (-10 -2) and (10 -2) 
;; the even parking spaces have a dark gray collor
;; the odd parking spaces have light gray collor
;; the rest of the patches are green grass

ask turtles with [ who > 14]
               [set color blue ;; the collor of the turtle becomes blue 
               set shape "car" ;; the shape of the turtle becomes a car
               set heading 90  
               set xcor round random-xcor ;; the x-coordinate is random but a round number so that is parked on one parking space
               set ycor ( 2) ;; the cars are parked in the parkings above the road
                ]
ask turtles with [ who <= 14]
               [set color blue ;; ;; the collor of the turtle becomes blue 
               set shape "car";; the shape of the turtle becomes a car
               set heading 90
               set xcor round random-xcor;;;; the x-coordinate is random but a round number so that is parked on one parking space
               set ycor ( -2)  ;;the cars are parked in the parkings beneath the road
               ]              
ask turtle 1 [set color RED ;; the collor of the turtle becomes blue 
               set shape "car";; the shape of the turtle becomes a car
               set heading 90
               set xcor round random-xcor ;; the x-coordinate is random
               set ycor -1 ;; the car is put on lower part of the road
             ]
ask turtle 2  [set color 45
               set shape "car";; the shape of the turtle becomes a car
               set heading -90
               set xcor round random-xcor ;;;; the x-coordinate is random
               set ycor 1 ;; the car is put on higher part of the road
              ]
ask turtle 3  [set color 85
               set shape "car";; the shape of the turtle becomes a car
               set heading -90
               set xcor round random-xcor ;; the x-coordinate is random 
               set ycor 1 ;; the car is put on higher part of the road
              ]
ask turtle 4 [set color 125
               set shape "car";; the shape of the turtle becomes a car
               set heading 90
               set xcor round random-xcor ;; the x-coordinate is random
               set ycor -1 ;; the car is put on lower part of the road
              ]

ask patches [ifelse (pycor = 1) or (pycor = -1) ;; If a patch has an ycoordinate 1 or -1 or is a port of the road, the patch becomes black
                    [set pcolor black
                    ]
                    [ifelse (pycor = 0) ;; ;; If a patch has an y coordinate 0 or is a part of the separation lane, the patch becomes white
                       [ set pcolor white]
                           [ifelse (pycor = 2) or (pycor = -2)
                               [ifelse (pxcor = 2) or (pxcor = 4) or (pxcor = 6) or (pxcor = 8) or (pxcor = 10) or (pxcor = -2) or (pxcor = -4) or (pxcor = -6) or (pxcor = -8) or (pxcor = -10) or (pxcor = 0)
                                     [set pcolor 4 
                                     ] ;; If a patch has an y-coordinate 2 an an even x-coordinate  the patch becomes dark gray 
                                     [set pcolor 6 
                                     ] ;; If a patch has an y-coordinate 2 an an odd x-coordinate  the patch becomes light gray                                        ]   
                                ]      
                                [ set pcolor green 
                                ] ;; if a patch is no parking space, road part or a part of the white lane the patch becomes green         
                       ]
                    ]               
            ] 
end 

to go ;; The parking movement
;; The turtles on the road move the other stay on their place
;; If there is another car on a parkingspace, the car moves forward
;; if there non other turtle in the neighborhood the turtle will move to the  a parking path and parks their
  
  ask turtles with [ycor = 1 or ycor = -1] ;; the parking movement is only one by the cars on the road
                  [ifelse ( any? turtles-on neighbors )
                         [pd forward 1
                         ] ;; if there a turtle in the neighborhood the cars moves one
                         [pd right 90 forward 1
                          ] ;; if there is no turtle in the neighborhood the car turns right and moves 1 so that has parked
                    ]
end      




There is only one version of this model, created about 13 years ago by Relinde Nieuwborg.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.