Child of Traffic Basic

No preview image

1 collaborator

Default-person micka borscha (Author)

Tags

traffic 

Tagged by Drew Einhorn over 3 years ago

Child of model Traffic Basic
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.1.0 • Viewed 294 times • Downloaded 20 times • Run 0 times
Download the 'Child of Traffic Basic' 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

globals [max-speed traffic-density road-patches]

turtles-own [ speed ]

to setup
  clear-all
  set-patch-size 20
  setup-globals
  setup-patches
  setup-cars
end 

to setup-globals
  set max-speed 1
  set traffic-density 0.3
  set road-patches patches with [pycor = 0]
end 

to setup-patches
  ask road-patches [set pcolor white]
end 

to setup-cars
  let num-cars round (traffic-density * count road-patches)
  ask n-of num-cars road-patches [sprout 1]
  ask turtles [
    set color yellow
    set heading 90
    set speed random-float 1
    ]

  ask one-of turtles [
    set size 2
    set color red ]
end 

to go
  ask turtles [
  change-speed
  forward speed ]
  wait 0.1
end 

to change-speed
  let hindrance one-of turtles-on patch-ahead 1
    ifelse (hindrance != nobody)
    [ set speed 0.80 * [speed] of hindrance ]
    [ set speed (1.1 * speed) ]
    if speed > max-speed [
    set speed max-speed ]
end 

There is only one version of this model, created over 5 years ago by micka borscha.

Attached files

No files

Parent: Traffic Basic

This model does not have any descendants.

Graph of models related to 'Child of Traffic Basic'