Trafic BDI Scenario Simulation

Trafic BDI Scenario Simulation preview image

1 collaborator

Default-person AAMAS 2017 (Author)

Tags

bdi, recommender, trafic 

Tagged by AAMAS 2017 over 8 years ago

Visible to everyone | Changeable by the author
Model was written in NetLogo 5.3.1 • Viewed 351 times • Downloaded 27 times • Run 0 times
Download the 'Trafic BDI Scenario Simulation' 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

;;; Include files for communication and BDI agents
__includes ["communication.nls" "bdi.nls" "coordinates.nls" "UserAgent.nls"]

globals [passengers-left passengers-on-taxis passengers-arrived crashed current-light num-cars-stopped roads intersections
   list-distance
  list-path-waypoint
  list-distance-path
  list-dist-path
  list-links
  list-all-path
  list-total-distance
  waypoint-count
  number-waypoint
  list-waypoints
  strating-point
  path
  previous-waypoint
  total-distance
  final-distance
  fp]
breed [houses house]
breed [ works work]
breed [people-arrived person-arrived]

patches-own [distance-work road street-name is-intersection? ]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Setting up the Experiment
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to setup

  clear-all
  set current-light nobody
  set num-cars-stopped 0
  set number cars-number + 2
  set count-down 10
  ;set n 2
  set crashed 0
  ask patches [
        set road 0
        set distance-work -1]
  setup-streets
  setup-cars
  setup-work
  label-patches
  reset-ticks
end 

to setup-streets
  let px min-pxcor
  while [px <= max-pxcor]
    [
    ask patches with [pxcor = px or pxcor = px + 1 or pxcor = px + 2] [set pcolor grey set road road + 1]
    ask patches with [pycor = px or pycor = px + 1 or pycor = px + 2] [set pcolor grey set road road + 1]
    ask patches with [road = 2] [set pcolor 4 set is-intersection? true set intersections intersections + 1]
    set px px + 8
    ]
end 

to setup-work
  create-works 1 [
  set shape "building store"
  set Label "Work"
  set size 4
  set heading 0
  set color Blue
  setxy  15  7
  ask patches with [distance myself = 0] [set pcolor green
                                          set distance-work 0
                                          ]
  ]
    create-works 1 [
  set shape "house"
  set Label "Home"
  set size 4
  set heading 0
  set color Blue
  setxy  -19  -17
    ]
end 

to label-patches
  while [any? patches with [distance-work < 0 and road > 0] ]
        [setup-distances-work]
end 

to setup-distances-work
   let labeled-patches patches with [distance-work >= 0]
   ask labeled-patches [
             let dis distance-work
             ask neighbors4 with [distance-work < 0 and road > 0] [set distance-work dis + 1]
             ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Running the Experiment
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to go
  ask cars [car-behaviour]
  tick
end 



;;; Place the turtle somewhere where there is noboby else and there is a road.

to rand-xy-co-on-road
  let x 0
  let y 0

  loop [
    set x random-pxcor
    set y random-pycor
    if not any? turtles-on patch-at x y and [road > 0] of patch-at x y [setxy x y stop]
  ]
end 

There is only one version of this model, created over 8 years ago by AAMAS 2017.

Attached files

File Type Description Last updated
Trafic BDI Scenario Simulation.png preview Preview for 'Trafic BDI Scenario Simulation' over 8 years ago, by AAMAS 2017 Download

This model does not have any ancestors.

This model does not have any descendants.