Koul_Dhruv_FinalProject

No preview image

1 collaborator

Default-person Dhruv Koul (Author)

Tags

(This model has yet to be categorized with any tags)
Model group MAM-2013 | Visible to everyone | Changeable by the author
Model was written in NetLogo 5.0.4 • Viewed 679 times • Downloaded 176 times • Run 0 times
Download the 'Koul_Dhruv_FinalProject' 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 program models how different attributes of tornadoes affect the damage caused to cities depending on city size, layout, and building densities. It also shows how cars are generally destroyed during these storms, either directly due to the tornadoes' impact or due to accidents caused by cars crashing into trees, houses, buildings, or other cars.

The user sets attributes for the tornado; the options given in a range taken from empirical data of average tornadoes for their lifetime, their strength, movement speeds, and the fact that they move around randomly. The user can also allow for tornado families to occur - and if so they occur at a very small probability given that tornado families are extremely rare. The user can also choose a number of cars that attempt to escape the tornado along with car speeds. Based on a mathematical model, the tornado damages houses and buildings, and throws any trees or cars that it finds in its path. The damage done to houses and buildings versus overall city damage are plotted, and the percentage of cars destroyed due to tornadoes vs due to accidents are also kept track of. Other monitors also show the initial/final values of the city and the total damage done (in dollars), as well as the total percentage of cars destroyed during the storm.

HOW IT WORKS

The city layouts of houses, buildings, and trees are predefined. There are three possible city layouts, a large city, a medium city, and a small city. The large cities have larger buildings with a dense layout, a small amount of trees and no houses in the area. Medium cities have an average "downtown" area and also a suburban area with trees. The small cities have a tiny shopping center with a lot of houses spread around with a lot of trees in the surrounding area as well.

For the rest of the setup, the user chooses attributes for the tornado, the number of cars and the cars' speeds before choosing the size of city setup. The tornado attributes include:

1) Tornado lifetime - between 1 and 12 minutes (normalized to a certain number of ticks) 2) Tornado strength - between 1 and 5 (depicted by size) 3) Movement speed - between 30 and 70 mph (normalized to be screen appropriate) 4) Movement probability - tornadoes move randomly - the user can set the probability 5) Reproduction - if the user allows it, then a 0.1% chance exists that a tornado will reproduce into a tornado family (these are very rare - hence the small probability)

Finally, the user can choose a number of cars between 1 and 50 and give them all a speed between 0 and 85 mph (upper limit of 'safe' driving).

Upon hitting go, the tornado will move around the world, and depending on its strength, will throw trees and cars that it encounters in its path. If those thrown objects hit a house or building, they will cause damage. If the tornado encounters a house or building, then depending on the strength and the amount of time the tornado has spent there it will inflict a certain amount of damage. Cars try and escape the tornado if it approaches them, but depending on its speed and direction the car will either get thrown by the tornado, will crash into a house, building, tree, or another car, or it will escape the tornado's path.

The overall damage, in dollars, is counted during the life of the program run, and the percentage damage to the city is also displayed in a monitor, as is the initial and final "aggregate values" of the cities. The damage done to houses vs. the total damage is plotted, as is the damage done to buildings vs. the total damage. The percentage of total cars destroyed is shown in a monitor, with a breakdown as to the percentage of destroyed cars attributed to the tornado directly versus car accidents caused by cars crashing into trees, houses, buildings, and each other.

HOW TO USE IT

To setup the model, choose values for the attributes for the tornado, as well as the number of cars and cars' speeds. Then choose a city size by pressing on the approprate setup button, which also incorporates the settings chosen. Then press go. Here is a breakdown of each of the widgets:

tornado-lifetime slider: user chooses a 'lifetime' for tornadoes - it is normalized into a certain number of ticks.

tornado-strength slider: user chooses a strength for tornadoes - depicted by size.

movement-speed slider: user chooses a path movement speed for tornadoes - it is normalized for appropriate depiction on screen.

movement-probability slider: user chooses the probability with which tornadoes will move - they move randomly in real life as well.

number-of-cars slider: user chooses a number of cars to escape tornadoes in the world.

car-speed slider: user chooses a speed for cars - it is normalized for appropriate depiction on screen in the same way as movement-speed is.

allow-reproduction? switch: user decided whether or not tornadoes can reproduce into families - if allowed, then tornadoes reproduce with a 0.1% probability.

setup-large-city button: sets up large city layout as predefined, along with previous attributes chosen by user.

setup-medium-city button: sets up medium city layout as predefined, along with previous attributes chosen by user.

setup-small-city button: sets up small city layout as predefined, along with previous attributes chosen by user.

go button: starts the model run.

show-initial-city-value-in-dollars monitor: sums values of all buildings and houses in the world and displays it.

show-total-damage-during-run monitor: displays total damage done to city's buildings and houses during model run.

show-final-city-value-in-dollars monitor: sums values of all buildings and houses in the world after damage has been done and displays it.

percentage-damage-to-city-at-end: computes percentage of damage done to city by calculating (total damage / inital value) * 100.

Building Damage vs. Total plot: plots damage done to only buildings compared to total damage done to city.

House Damage vs. Total plot: plots damage done to only houses compared to total damage done to city.

percentage-cars-destroyed-by-tornadoes: shows percentage of cars destroyed directly by tornadoes in relation to total cars destroyed.

percentage-cars-destroyed-by-accidents: shows percentage of cars destroyed as a result of crashing into houses, buildings, trees, or other cars when trying to escape tornadoes in relation to total cars destroyed.

percentage-cars-destroyed-total: shows total percentage of cars destroyed in relation to initial number of cars in the world.

THINGS TO NOTICE

There are a few things to notice in the model. First, see how when a strong enough tornado runs into a house, the house changes into a blackened circle, indicating that it has been completely destroyed. Buildings, after a certain amount of damage, will turn a light brown, then a dark brown after more damage, and finally a black color after it has been completely destroyed.

When a tornado approaches a tree, it throws the tree a certain distance depending on their movement speed and their strength. If a tree is thrown into a house or building, it does a certain amount of damage. If a tree is thrown into a car, that car gets destroyed.

Also notice that cars start to drive off when a tornado approaches in their vicinity. However, if a tornado catches up to them (and subsequently throws them) or if a car runs into a building, house, tree, or another car, the cars involved also turn black, indicating that they have been destroyed as well.

If a tornado family forms, notice that each tornado that is born has a lifetime of its own, and even if the parent tornado dissipates, the tornado children will last until their lifetime has elapsed (same lifetime as set by the user at setup).

Finally, also notice that trees and cars (even after being destroyed) can be thrown multiple times, whereas houses and buildings are not thrown around.

THINGS TO TRY

1) Make the view bigger and see how a more spread out world affects the overall damage done to the city, given that the tornado needs to cover more ground.

2) Make the tornadoes faster than the cars - do the tornadoes necessarily catch up to all of the cars? Now make the cars faster than the tornadoes - do the cars necessarily safely outrun the tornadoes?

3) Adjust the number of cars - do more cars lead to more accidents/car casualties?

4) Adjust the probability of the tornado moving - how does the probability affect the overall damage done to the city?

5) Allow for tornado reproduction - does the probability required for tornado reproduction always get realized? How does it affect the damage done to the city? How much chaos does it cause with the cars? Do the tornadoes move together or independently?

6) Adjust the tornado lifetimes and the probability of moving together - see how it affects the damage done.

EXTENDING THE MODEL

1) Make for an infinite world by allowing the tornadoes or cars to move off screen and come back if they have the chance - how does it affect damage and car movement?

2) Implement pathways that cars must travel in order to escape tornadoes rather than letting them move all over the place - how does that affect car success rate in escaping tornadoes? How about avoiding accidents with buildings/houses/other cars?

3) Instead of having cars moving away only when a tornado approaches them and stop after the tornado leaves them alone, have cars continue to drive after the first time they've been disturbed. How does that affect the casualty count of cars?

4) Instead of creating the tornadoes at setup, have them appear after pressing go at some point, either in a random location or allowing the user to choose where to set it each time by picking coordinates. How does the "element of surprise" affect the cars?

5) Include pedestrians walking in the cities that have safe-zones within the city - such as in larger buildings, and allow for them to scramble for safety upon seeing the tornado. Maybe include a crowd limit at each safe-zone so if too many people crowd one area, the newcomers have to fight for a spot or move to another location and perhaps are too late getting to safety.

6) Though the tornadoes move randomly and probabilistically, have the tornado move in a general path from Southwest to Northeast. How does this affect damage and car movement? This is the average movement path of tornadoes in Tornado Alley as tracked, though movements within the overall path have been known to be jumpy as this model already shows.

7) Try and model real tornado air flows and rotating columns of air. See how, depending on the rotation of the wind column, objects picked up by the tornado would actually be thrown. Tornado air flows are extremely complex, so this would be very challenging.

NETLOGO FEATURES

1) Made use of world boundary coordinates (max-pxcor, max-pycor, min-pxcor, min-pycor) along with patch-ahead in order to bounce the tornadoes and cars off the walls and keep them in view.

2) Made use of breeds that helped distinguish between different types of turtles - buildings, houses, trees, cars, and tornadoes.

3) Made use of set-default-shape in order to simplify setup by just needing to specify shapes at creation once.

4) Made use of in-radius and breeds-here in order to do spatial checks of turtle interaction.

5) Used the math library (exponentials, etc) in order to come up with mathematical models for tornadoes throwing objects, as well as the actual damage model.

RELATED MODELS

Bounce - for checking world boundaries to keep tornadoes and cars in view.

Wolf Sheep Predation - for spatial turtle interaction.

Fire - for how density affects damage.

CREDITS AND REFERENCES

Code, syntax, and ideas on how to proceed with model:

Bounce example - code for checking world boundaries to keep tornadoes and cars in view.

Wilensky, Uri. "NetLogo Dictionary." NetLogo 5.0.4 User Manual:. N.p., n.d. Web. 10 June 2013. http://ccl.northwestern.edu/netlogo/docs/dictionary.html.

David Weintrop (TA) - for ideas with car casualty implemention, world-view implementation, and visual capturing of model's emergent behavior.

Facts used for reference pattern(s) - both damage and tornado attributes:

"Tornado (meteorology) : Duration." Encyclopedia Britannica Online. Encyclopedia Britannica, n.d. Web. 10 June 2013. http://www.britannica.com/EBchecked/topic/599941/tornado/218376/Speed-and-direction-of-movement.

"Tornado FAQs." FAQs about Tornadoes. N.p., n.d. Web. 10 June 2013. http://www.stormsheltersinc.com/faqs.htm.

"Tornado Facts & History." Storm Aware. N.p., n.d. Web. 10 June 2013. http://stormaware.mo.gov/tornado-facts-history/.

"What You Need to Know about Tornadoes." CNN. Cable News Network, 04 Jun. 2013. Web. 10 June 2013. http://www.cnn.com/2013/05/20/us/tornadoes-fast-facts/.

"Good Reasons Not To Be in a Car When a Tornado Strikes." Good Reasons Not To Be in a Car When a Tornado Strikes. N.p., n.d. Web. 10 June 2013. http://www.tornadoproject.com/safety/cars.htm.

"Are Cars Really a Safe Option in Tornadoes?" Flame. N.p., 11 Jan. 2003. Web. 10 June 2013. http://www.flame.org/~cdoswell/tors&cars/cars_and_tornadoes.html.

"Tornado Statistics." Statistic Brain RSS. N.p., n.d. Web. 10 June 2013. http://www.statisticbrain.com/tornado-statistics/.

"Tornadoes: Total Cost of Damage Statistics - States Compared - Statemaster." RSS Stats. N.p., n.d. Web. 10 June 2013. http://www.statemaster.com/graph/geo_tor_tot_cos_of_dam-geography-tornadoes-total-cost-damage.

"Tornado - Data and Statistics." Disaster Statistics. N.p., n.d. Web. 10 June 2013. http://www.preventionweb.net/english/hazards/statistics/?hid=70.

"1999 Oklahoma Tornado Outbreak." Wikipedia. Wikimedia Foundation, n.d. Web. 10 June 2013. http://en.wikipedia.org/wiki/1999_Oklahoma_tornado_outbreak.

"Trulia." Trulia. N.p., n.d. Web. 10 June 2013. http://www.trulia.com. Helped with average home prices and property values used in model.

"Oklahoma Meteorologist Criticized for 'irresponsible' Tornado Warning That Put Lives in Danger." NY Daily News. Reuters, 6 June 2013. Web. 10 June 2013. http://www.nydailynews.com/news/national/oklahoma-meteorologist-criticized-tornado-warning-article-1.1364792.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

;; Dhruv Koul
;; EECS 372 - Spring 2013
;; Final Project

;; breeds used in model
breed [tornadoes tornado]
breed [trees tree]
breed [houses house]              ;; for small and medium cities
breed [buildings building]        ;; for medium and large cities (and a few in small cities)
breed [cars car]


globals [total-life initial-city-value initial-buildings-value initial-houses-value
  final-city-value final-buildings-value final-houses-value total-damage
  initial-car-count car-casualty-tornado car-casualty-accident final-car-casualty-count]
tornadoes-own [lifetime t-speed]
buildings-own [initial-bvalue b-damage b-time-with-tornado]    ;; value is average value for buildings in specified city size
houses-own [initial-hvalue h-damage  h-time-with-tornado]        ;; value is average value for homes in specified city size
cars-own [speed]


;; setting default shapes aids in simplifying the setup process

to set-default-shapes
  set-default-shape trees "tree"
  set-default-shape tornadoes "target"
  set-default-shape houses "house"
  set-default-shape buildings "box"
  set-default-shape cars "car"
end 


;; tornado procedure
;; sets lifetime of each tornado (taken from average tornado lifetimes and adjusts it for time (explained in report)

to set-total-life
  set total-life (tornado-lifetime / 10 * 60 * 50)
end 


;; initialize global variables and call this in the setup functions

to set-initial-values
  set initial-buildings-value (sum [initial-bvalue] of buildings)
  set initial-houses-value (sum [initial-hvalue] of houses)
  set initial-city-value (initial-buildings-value + initial-houses-value)
  set total-damage 0
  set car-casualty-tornado 0
  set car-casualty-accident 0
end 


;; tornado procedure
;; creates tornadoes (function since tornadoes are same across cities - reusable code)

to make-tornadoes-appear
  create-tornadoes 1 [
    set color gray                                            ;; will focus less on the actual physics of the tornado as that will be difficult to
    set lifetime 0
    set size (tornado-strength / 2 + 1)                       ;; model accurately - instead will focus on the movement of tornadoes, the probability
    set t-speed (movement-speed / 100)
    move-to one-of patches with [count turtles-here = 0]      ;; of them jumping from place to place, and the actual damage they cause based on a reference
  ]                                                           ;; pattern from previous tornadoes in similar-sized areas
end 


;; cars procedure
;; creates cars (cars same across cities and # defined by user - reusable code)

to make-cars-appear
  create-cars number-of-cars [
    set initial-car-count number-of-cars
    set color red
    set speed (car-speed / 100)                              ;; car speed is normalized to move at a "see-able" pace (just like tornado mph)
    move-to one-of patches with [count turtles-here = 0]
  ]
end 


;; SETUP OF CITIES - three types of cities are being set up - large cities, medium-sized cities
;; and small town/rural areas. These setups are going to be pre-defined and captured in three different
;; setup buttons. The user can choose which type of city they want to use and pair with a certain
;; strength of tornado to assess damage done. The rationale for the setups will be scattered in comments
;; throughout the code as well as detailed in the report's final analysis. The values given to the buildings and
;; houses in each of the type of cities is the average property value for such types in examples of cities that are
;; the same size as the ones I've chosen for this model (explained in the report).

to setup-large-city
  clear-all
  
  set-default-shapes
  set-total-life
  
  ask patches [
    set pcolor green - 2.5     ;; chose green to be the "landscape" of the cities - same for medium and small cities
  ]
  
  create-trees 50 [                   
    set color green                   
    move-to one-of patches with [
      count turtles-here = 0 and
      pxcor > 24
    ]
  ]
  
  ;; downtown setting
  create-buildings 40 [
    set size 3 + random 3             ;; for large city - at least a size of 3
    set color blue
    set initial-bvalue 500000000
    set b-time-with-tornado 0
    set b-damage 0
    move-to one-of patches with [
      count turtles-here = 0 and
      not any? turtles in-radius 2 and
      pxcor < 11 and pycor > 0
    ]  
  ]
  
  ;; less densely-populated, non-downtown area
  create-buildings 15 [
    set size 1.5 + random 2             ;; for large city - at least a size of 3
    set color gray + 1
    set initial-bvalue 250000000      ;; in lesser downtown - property is slightly cheaper
    set b-time-with-tornado 0
    set b-damage 0
    move-to one-of patches with [
      count turtles-here = 0 and
      not any? turtles in-radius 2 and
      pxcor < 11 and pycor < -5
    ]  
  ]
  
  make-tornadoes-appear
  make-cars-appear
  
  set-initial-values
  setup-damage-plot
  
  reset-ticks
end 

to setup-medium-city
  clear-all
  
  set-default-shapes
  set-total-life
  
  ask patches [
    set pcolor green - 2.5
  ]
  
  create-trees 40 [     
    set color green
    move-to one-of patches with [
      count turtles-here = 0 and
      pxcor > 1
    ]
  ]
  
  ;; on one side of the trees will exist houses
  ;; the other side of the trees will be the "downtown" area
  create-houses 40 [
    set size 1.25
    set color yellow
    set initial-hvalue 200000
    set h-time-with-tornado 0
    set h-damage 0
    move-to one-of patches with [
      count turtles-here = 0 and
      not any? turtles in-radius 2 and
      pxcor > 3
    ]
  ]
  
  ;; medium city downtown area
  create-buildings 25 [
    set size 1 + random 3
    set color gray + 1
    set initial-bvalue 100000000
    set b-time-with-tornado 0
    set b-damage 0
    move-to one-of patches with [
      count turtles-here = 0 and
      not any? turtles in-radius 2 and
      pxcor < 1 and pycor > 0
    ]
  ]
  
  ;; smaller buildings in non-downtown area
  create-buildings 10 [
    set size 1 + random 2
    set color gray + 1
    set initial-bvalue 50000000         ;; worth a little less than the downtown buildings
    set b-time-with-tornado 0
    set b-damage 0
    move-to one-of patches with [
      count turtles-here = 0 and
      not any? turtles in-radius 2 and
      pxcor < 1 and pycor < -8
    ]
  ]
  
  make-tornadoes-appear
  make-cars-appear
  
  set-initial-values
  setup-damage-plot
  
  reset-ticks
end 


;; SMALL CITY

to setup-small-city
  clear-all
  
  set-default-shapes
  set-total-life
  
  ask patches [
    set pcolor green - 2.5
  ]
  
  create-trees 80 [
    set color green
    move-to one-of patches with [
      count houses = 0 and
      count buildings = 0
    ]
  ]
  
  ;; houses around the city except near shopping district
  create-houses 50 [
    set size 1.25
    set color yellow
    set initial-hvalue 125000
    set h-time-with-tornado 0
    set h-damage 0
    move-to one-of patches with [
      count turtles-here = 0 and
      pxcor < 4 or (pxcor > 4 and pycor < 0)
    ]
  ]
  
  ;; tight little "shopping district"
  create-buildings 10 [
    set size 1.5
    set color gray + 1
    set initial-bvalue 20000000
    set b-time-with-tornado 0
    set b-damage 0
    move-to one-of patches with [
      count turtles-here = 0 and
      pxcor > 6 and pycor > 6
    ]
  ]
  
  make-tornadoes-appear
  make-cars-appear
  
  set-initial-values
  setup-damage-plot
  
  reset-ticks
end 


;; GO CODE

to go
  if not any? tornadoes [
    calculate-total-damage
    set-final-values
    stop
  ]
  move-tornadoes
  move-cars
  throw-cars
  throw-trees
  tornado-damage-to-buildings
  tornado-damage-to-houses
  increment-tornado-life
  check-tornado-death  
  tick
end 


;; tornadoes procedure
;; tornadoes will move based on a probability which user assigns - a probabilistic movement
;; is consistent with the average tornado. Though tendecies for tornadoes are to move from SW - NE,
;; I've decided to allow the user to assign a probability to make the model exhibit "emergent" behavior
;; I'm also bouncing off world boundaries to avoid the tornado getting caught - just for action purposes

to move-tornadoes
  ask tornadoes [
    if patch-ahead 0.1 != nobody and abs [pxcor] of patch-ahead 0.1 = max-pxcor [
      set heading (- heading)
    ]
    
    if patch-ahead 0.1 != nobody and abs [pycor] of patch-ahead 0.1 = max-pycor [
      set heading (180 - heading)
    ]                                                             ;; according to probability - this is just so it
  ]     
  ;; doesn't get stuck (I've unchecked wrapping)
  if random 100 < movement-probability [
    ask tornadoes [
      wiggle
      fd t-speed
      check-reproduction
    ]
  ]
end 


;; cars procedure
;; cars will try and move away from tornadoes and buildings and houses (avoid massive collisions
;; also checking that the cars try and bounce away from the ends of the world to avoid getting fully stuck there

to move-cars
  ask cars [
    if patch-ahead 0.1 != nobody and abs [pxcor] of patch-ahead 0.1 = max-pxcor [
      set heading (- heading)
    ]
    
    if patch-ahead 0.1 != nobody and abs [pycor] of patch-ahead 0.1 = max-pycor [
      set heading (180 - heading)
    ]
    
    avoid-tornadoes              ;; only move when a tornado is approaching
    check-for-car-accidents      ;; after moving, check for car accidents
  ]
end 


;; cars procedure
;; checks for tornadoes and tries to escape them

to avoid-tornadoes
  if any? tornadoes in-radius 4 [
    face one-of tornadoes in-radius 4
    rt 180
    wiggle
    fd speed
  ]
end 


;; cars procedure
;; checks for nearby cars and trees to avoid collisions

to avoid-cars-and-trees
  if any? trees in-radius 1 or any? cars in-radius 1 [
    wiggle
    fd speed
    avoid-cars-and-trees             ;; when avoiding tornadoes, it's also important to watch out for other
    avoid-houses-and-buildings       ;; obstacles, like other cars, houses, trees and buildings
  ]
end 


;; cars procedure
;; checks for nearby buildings and houses to avoid collisions

to avoid-houses-and-buildings
  if any? houses in-radius 1 or any? buildings in-radius 1 [
    wiggle
    fd speed
  ]
end 


;; cars procedure
;; check for collisions with houses, buildings, trees, or other cars
;; account for those collisions in casualty-by-accident count

to check-for-car-accidents
  ask cars with [color != black] [
    if any? buildings-here or any? houses-here or any? trees-here or any? other cars-here [
      set speed 0
      set color black
      set car-casualty-accident car-casualty-accident + 1
    ]
  ]
end 


;; turtles procedure
;; allow users to choose the speed at which the tornado actually travels
;; research shows that speed is generally between 30 - 70 mph (hence the limits)

to wiggle
  rt random 30
  lt 15
end 


;; tornado procedure
;; if the user allows tornado reproduction, then there is a .1% chance that a tornado will
;; reproduce - tornado "families" are rare, so that's why the percentage chance is so low

to check-reproduction
  if allow-reproduction? and random 1000 = 0 [
    ask one-of tornadoes [
      hatch 1 [set lifetime 0]
    ]
  ]
end 


;; tornado procedure
;; if the tornado encounters a car, it treats the car just like a tree (throwing it) - with the
;; car becoming damaged and added to the car casualty percentage

to throw-cars
  ask tornadoes [
    if any? cars in-radius (tornado-strength / 2) [
      ask cars in-radius (tornado-strength / 2) [
        move-to one-of patches in-radius (sqrt ((tornado-strength ^ 2) + ((0.05 * (movement-speed)) ^ 2)))
        ask cars in-radius (tornado-strength / 2) with [color != black] [
          set speed 0
          set color black
          set car-casualty-tornado car-casualty-tornado + 1
        ]
        check-if-hit-something
      ]
    ]
  ]
end 


;; tornado procedure
;; if it encounters a tree in its path, throw it to another patch based on tornado strength and movement speed
;; this is a little arbitrary but it's a sort of vector math, using movement-speed as a vector
;; proceed to check if the thrown tree has hit a building or a home

to throw-trees
  ask tornadoes [
    if any? trees in-radius (tornado-strength / 2) [
      ask trees in-radius (tornado-strength / 2) [
        move-to one-of patches in-radius (sqrt ((tornado-strength ^ 2) + ((0.05 * (movement-speed)) ^ 2)))
        check-if-hit-something
      ]
    ]
  ]
end 


;; turtles procedure
;; if the tree was thrown to a spot where there are any buildings or houses here
;; then inflict damage to them (assuming houses are hurt more than buildings)

to check-if-hit-something
  ask buildings-here [
    set b-damage b-damage + 3000
  ]
  ask houses-here [
    set h-damage h-damage + 10000
  ]
end 


;; tornado procedure
;; calculate damage done by tornadoes - the targets are going to be in a certain
;; radius size depending on strength of tornado because the tornado can cause damage
;; with its winds in similar settings

to tornado-damage-to-houses
  ask tornadoes [
    if any? houses in-radius (tornado-strength / 2) [
      ask houses in-radius (tornado-strength / 2) [
        set h-time-with-tornado h-time-with-tornado + 1
        calculate-house-damage
        show-house-damage-visually
      ]
    ]
  ]
end 


;; tornado procedure
;; calculate damage done by tornadoes - the targets are going to be in a certain
;; radius size depending on strength of tornado because the tornado can cause damage
;; with its winds in similar settings

to tornado-damage-to-buildings
  ask tornadoes [
    if any? buildings in-radius (tornado-strength / 2) [
      ask buildings in-radius (tornado-strength / 2) [
        set b-time-with-tornado b-time-with-tornado + 1
        calculate-building-damage
        show-building-damage-visually
      ]
    ]
  ]
end 


;; otherwise set damage according to this model (mathematical model I've chosen that
;; works out to reflect some average reference pattern statistics - and it takes into
;; account some relevant factors of the tornado)

to calculate-house-damage
  ifelse (h-damage >= initial-hvalue)
    [set h-damage initial-hvalue]
    [set h-damage ((tornado-strength ^ 3) * (e ^ (h-time-with-tornado / 50)) * 100000)]
end 

to calculate-building-damage
  ifelse (b-damage >= initial-bvalue)
    [set b-damage initial-bvalue]
    [set b-damage ((tornado-strength ^ 3) * (e ^ (b-time-with-tornado / 50)) * 100000)]
end 


;; buildings procedure
;; changes the color/shape of a building depending on amount of damage done to it percentage-wise

to show-building-damage-visually
  if (b-damage / initial-bvalue) >= 0.333 [
    set color brown
  ]
  if (b-damage / initial-bvalue) >= 0.667 [
    set color brown - 2
  ]
  if (b-damage / initial-bvalue) >= 1 [
    set color black
    set shape "circle"                       ;; indicates a sort of 2D "heap" of building material
  ] 
end 


;; houses procedure
;; changes the color/shape of a house depending on amount of damage done to it percentage-wise

to show-house-damage-visually
  if (h-damage / initial-hvalue) >= 0.333 [
    set color brown
  ]
  if (h-damage / initial-hvalue) >= 0.667 [
    set color brown - 2
  ]
  if (h-damage / initial-hvalue) >= 1 [
    set color black
    set shape "circle"                       ;; indicates a sort of 2D "heap" of building material
  ] 
end 


;; tornadoes procedure
;; make the tornado creep closer to dissipation

to increment-tornado-life
  ask tornadoes [
    set lifetime lifetime + 1
  ]
end 


;; tornadoes procedure
;; if the tornado has outlived its allotted lifetime, it dies

to check-tornado-death
  ask tornadoes with [lifetime >= total-life] [die]
end 


;; total damage to the entire city (sum of individual damages of houses and buildings)

to calculate-total-damage
  set total-damage ((sum [h-damage] of houses) + (sum [b-damage] of buildings))
end 


;; calculate final values - again all global variables and called in go function

to set-final-values
  set final-buildings-value (initial-buildings-value - (sum [b-damage] of buildings))
  set final-houses-value (initial-houses-value - (sum [h-damage] of houses))
  set final-city-value (final-buildings-value + final-houses-value)
  set final-car-casualty-count (count cars with [color = black])
end 


;; set up the initial values for the plots (setup in each setup function)

to setup-damage-plot
  set-current-plot "Building Damage vs. Total"
  set-plot-x-range 0 100
  set-plot-y-range 0 1000000
  
  set-current-plot "House Damage vs. Total"
  set-plot-x-range 0 100
  set-plot-y-range 0 1000000
end 

There are 18 versions of this model.

Uploaded by When Description Download
Dhruv Koul about 12 years ago Final Upload - Project finished Download this version
Dhruv Koul about 12 years ago everything done minus behaviorspace - looking to see if anything can be added (not necessary though) Download this version
Dhruv Koul about 12 years ago tweaked tree hit damage; added an extension possibility Download this version
Dhruv Koul about 12 years ago all changes should be done Download this version
Dhruv Koul about 12 years ago fixed plotting and value calculation; adjusted interface tab and commenting; Download this version
Dhruv Koul about 12 years ago I think interface tab, info tab, and code tab are done Download this version
Dhruv Koul about 12 years ago info tab first cut done; code tab done; re-check info tab next Download this version
Dhruv Koul about 12 years ago model should be done; halfway done with info tab; need to go through code cleanup Download this version
Dhruv Koul about 12 years ago larger view, cars moving around, destruction due to tornadoes vs. due to accidents implemented; next - testing, code refinement, info tab, etc etc Download this version
Dhruv Koul over 12 years ago denser downtown created, setup tweaked, damage showing visually, graphs added, world unwrapped; add escaping cars perhaps? Download this version
Dhruv Koul over 12 years ago Damage model working decently, changed some setup; need to add damage color scheme, keep testing damage model with some minor tweaks? Download this version
Dhruv Koul over 12 years ago trees are being thrown, city values are calculated, damage model is left Download this version
Dhruv Koul over 12 years ago Tornadoes moving and dissipating, damage model and costs are next Download this version
Dhruv Koul over 12 years ago Cities setup code should be good to go Download this version
Dhruv Koul over 12 years ago setup code is mostly done (small city is slightly buggy) Download this version
Dhruv Koul over 12 years ago Initial Commit Download this version
Dhruv Koul over 12 years ago Blank model - original file upload Download this version
Dhruv Koul over 12 years ago Initial upload Download this version

Attached files

File Type Description Last updated
DhruvKoul_June3.pdf pdf Progress report - June 3 over 12 years ago, by Dhruv Koul Download
DhruvKoul_May13.pdf pdf Progress report - May 13 over 12 years ago, by Dhruv Koul Download
DhruvKoul_May20.pdf pdf Progress report - May 20 over 12 years ago, by Dhruv Koul Download
DhruvKoul_May27.pdf pdf Progress report - May 27 over 12 years ago, by Dhruv Koul Download
Koul_Dhruv_Final Report.pdf pdf Final Project Report about 12 years ago, by Dhruv Koul Download
Koul_Dhruv_Poster Presentation.pdf pdf Poster Presentation "Digital Version" about 12 years ago, by Dhruv Koul Download
Koul_Dhruv_Project Proposal.pdf pdf Original Project Proposal about 12 years ago, by Dhruv Koul Download
Koul_Dhruv_Slam.ppt powerpoint Poster "Slam" Slides about 12 years ago, by Dhruv Koul Download

This model does not have any ancestors.

This model does not have any descendants.