BML simple

BML simple preview image

1 collaborator

Default-person Victor Aguiar (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0.4 • Viewed 422 times • Downloaded 30 times • Run 0 times
Download the 'BML simple' 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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;          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 about 12 years ago by Victor Aguiar.

Attached files

File Type Description Last updated
BML simple.png preview Preview for 'BML simple' about 12 years ago, by Victor Aguiar Download

This model does not have any ancestors.

This model does not have any descendants.