RoundAbout

RoundAbout preview image

1 collaborator

Default-person Wahaj Naveed (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.4.0 • Viewed 17 times • Downloaded 0 times • Run 0 times
Download the 'RoundAbout' modelDownload this modelEmbed this model

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

to draw-road
  ask patches [
    set pcolor green - random-float 0.5
  ]
  let road-y (max-pycor / 2) - 7
  let road-width 6

  ask patches with [pycor >= road-y - road-width / 2 and pycor <= road-y + road-width / 2] [
    set pcolor grey - 2.5 + random-float 0.25
  ]
  setup-credits
  drawy-road
  round-about
  create-car
end 

to drawy-road

  let road-x (max-pxcor / 2) - 8
  let road-width 6

  ask patches with [pxcor >= road-x - road-width / 2 and pxcor <= road-x + road-width / 2] [
    set pcolor grey - 2.5 + random-float 0.25
  ]
end 

to round-about
  ask patches [
    let distance-to-center distancexy 0 0
    if distance-to-center <= 11 [
      set pcolor grey - 2.5 + random-float 0.25
    ]
  ]
  ask patches [
    let distance-to-center distancexy 0 0
    if distance-to-center <= 4.5 [
      set pcolor white - 2.5 + random-float 0.25
    ]
  ]
end 

to create-car
  create-turtles 5 [
    setxy min-pxcor ((max-pycor / 2) - 7)  ; Left to right
    set heading 90
    set shape "car"
    set color red
  ]

  create-turtles 5 [
    setxy max-pxcor ((max-pycor / 2) - 9)  ; Right to left
    set heading 270
    set shape "car"
    set color blue

  ]

  create-turtles 5 [
    setxy ((max-pxcor / 2) - 8) max-pycor  ; Top to bottom
    set heading 180
    set shape "car"
    set color orange
  ]

  create-turtles 5 [
    setxy ((max-pxcor / 2) - 6) min-pycor  ; Bottom to top
    set heading 0
    set shape "car"
    set color cyan
  ]
end 

to go
  go-from-left
  go-from-right
  go-from-top
  go-from-bottom
end 

to go-from-left
  ask turtles with [heading = 90] [
    if xcor < -5 or xcor > 5 [
      set ycor ((max-pycor / 2) - 7)
    ]

    if xcor >= -5 and xcor <= 5 [
      set ycor ((max-pycor / 2) - 3)
    ]

    fd 1


  ]
end 

to go-from-right
  ask turtles with [heading = 270] [
    if xcor < -5 or xcor > 5 [
      set ycor ((max-pycor / 2) - 9)
    ]

    if xcor >= -5 and xcor <= 5 [
      set ycor ((max-pycor / 2) - 11)
    ]
     if xcor >= -4 and xcor <= 4 [
      set ycor ((max-pycor / 2) - 12)
    ]
     if xcor >= -3 and xcor <= 3 [
      set ycor ((max-pycor / 2) - 13)
    ]

    fd 1


  ]
end 

to go-from-top
  ask turtles with [heading = 180] [
    if ycor < -5 or ycor > 5 [
      set xcor ((max-pxcor / 2) - 8)
    ]

    if ycor >= -5 and ycor <= 5 [
      set xcor ((max-pxcor / 2) - 4)
    ]
    if ycor >= -4 and ycor <= 4 [
      set xcor ((max-pxcor / 2) - 3)
    ]

    fd 1


  ]
end 

to go-from-bottom
  ask turtles with [heading = 0] [
    if ycor < -5 or ycor > 5 [
      set xcor ((max-pxcor / 2) - 6)
    ]

    if ycor >= -5 and ycor <= 5 [
      set xcor ((max-pxcor / 2) - 2)
    ]

    fd 1


  ]
end 

to setup-credits
  create-turtles 1 [
    setxy (max-pxcor ) (min-pycor )
    set label "Credits: Wahaj"
    set label-color white

  ]
end 

There is only one version of this model, created 5 days ago by Wahaj Naveed.

Attached files

File Type Description Last updated
RoundAbout.png preview Preview for 'RoundAbout' 5 days ago, by Wahaj Naveed Download

This model does not have any ancestors.

This model does not have any descendants.