# BML simple

Model was written in NetLogo 5.0.4
•
Viewed 270 times
•
Downloaded 25 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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; BML Traffic Model ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; V. 0.1 ;; There are two cars species: northbounds and eastbounds. globals[ phase ] breed[northbounds northbound] breed [eastbounds eastboud] ;; These two species populate a two dimmensional square lattice, with boundary conditions. ;; Each lattice site can have three states i) empty ii) has a northbound car iii) has an east bound car. patches-own[ is-empty? has-north? has-east?] ;;Speed Turtles turtles-own[ speed] ;; Shapes of agents. to setshapes set-default-shape northbounds "car" set-default-shape eastbounds "car" end to setup ;; (for this model to work with NetLogo's new plotting features, ;; __clear-all-and-reset-ticks should be replaced with clear-all at ;; the beginning of your setup procedure and reset-ticks at the end ;; of the procedure.) __clear-all-and-reset-ticks ask patches [ set pcolor green set is-empty? TRUE ] setshapes let total-patches count patches ;;let spatial-density .1 ask n-of (spatial-density * total-patches) patches [ sprout-northbounds 1 [ set color brown ] ;; set state to has north set has-north? TRUE set is-empty? FALSE ] ask n-of (spatial-density * total-patches) patches with [ is-empty? = TRUE] [ sprout-eastbounds 1 [ set color black ] ;; set state to has nort set has-east? TRUE set is-empty? FALSE ] end ;; Simulation. to go ifelse (ticks mod 2) = 0 ;; even steps [ ask eastbounds [ ifelse ( [is-empty?] of patch-at 1 0 = TRUE ) [ ask patch-here [ set is-empty? TRUE ] move-to patch-at 1 0 set speed 1 ask patch-here [ set is-empty? FALSE ] ] ;; head east] [ set speed 0 ask patch-here [ set is-empty? FALSE ] ] ] ] [ ask northbounds [ ifelse ( [is-empty?] of patch-at 0 1 = TRUE ) [ ask patch-here [ set is-empty? TRUE ] move-to patch-at 0 1 set speed 1 ask patch-here [ set is-empty? FALSE ] ] ;; head north [ set speed 0 ask patch-here [ set is-empty? FALSE ] ] ] ] tick update-plot1-tipos end ;; Reports to update-plot1-tipos set-current-plot "Velocidad Promedio" set-current-plot-pen "todos" let target1num mean [speed] of turtles ;; with [ parked? = false] plot target1num end ;; El tiempo

There is only one version of this model, created over 9 years ago by Victor Aguiar.

## Attached files

File | Type | Description | Last updated | |
---|---|---|---|---|

BML simple.png | preview | Preview for 'BML simple' | over 9 years ago, by Victor Aguiar | Download |

This model does not have any ancestors.

This model does not have any descendants.