Tel Aviv Under Fire

Tel Aviv Under Fire preview image

1 collaborator

Default-person Arthur Hjorth (Author)


(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0.3 • Viewed 172 times • Downloaded 9 times • Run 0 times
Download the 'Tel Aviv Under Fire' 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

breed [commuters commuter]
breed [explosions explosion]
breed [telavivs telaviv]

commuters-own [hit?]
explosions-own [duration]

globals [made-it hit rocket-timer attempts]

to setup
  create-telavivs 1 [set shape "circle" set size 6 set color blue]
  ask telavivs [stamp]
  ask telavivs [die]
  set made-it 0
  set hit 0
  set rocket-timer 0
  set attempts 0
  create-commuters 1 [set hit? false set xcor -4 set heading 90 set shape "car" set size .2]

to go
  ;; move commuters
  ;; hamas fires rockets
  ;; check if a rocket hits
  ;; advance 'age' of explosions and remove if they are over
  ;; check if commuter made it to work
  ;; if no commuters active, make a new one
  if count commuters < 1[
    ;; add to total number of attempts made at crossing tel aviv
    set attempts attempts + 1
  ;; stop after 100,000 attempts
  if attempts >= 100000 [stop]

to commuters-move
  ;; since one tick is a second, and one patch is one kilometer, we move 
  ;; .0003 patch per tick per km/h
  ask commuters [fd .0003 * travel-speed]

to check-impact
  ask explosions[
    ;; check if there are any commuters within explosion-radius distance
    if any? commuters with [distance myself < explosion-radius / 1000]
      ;; if there is, the commuter is hit
      let nearby-commuter one-of commuters with [distance myself < explosion-radius / 1000]
      ask nearby-commuter [
        ;; add to global paramter that counts how many were hit
        set hit hit + 1

to rockets-landing
  ;; add to rocket timer
  set rocket-timer rocket-timer + 1
  if rocket-timer >= seconds-between-rockets
    ;; center explosion (has random heading), then forward radius of tel aviv (3 patches)
    ;; good, turtle perspective on random distribution on a circle
    create-explosions 1 [
      ;; hide it or it gets ugly
      set shape "circle"
      ;; size accordingly
      set size explosion-radius / 1000 
      set color red 
      fd random-float 3 
      ;; set set duration of this explosion to global parameter value
      set duration explosion-duration
    ;; reset rocket timer if rocket fired
    set rocket-timer 0

to explosions-duration
  ask explosions[
    ;; count down and die
    set duration duration - 1
    if duration <= 0 [die]

to check-if-made-it
  ;; this checks if commuter made it across tel aviv
  ask commuters with [xcor > 4.2 ] [
    ;; add to global counter for people who made it
    set made-it made-it + 1 

to next-commuter
  ;; make a new commuter
    create-commuters 1 [set hit? false set xcor -4 set heading 90 set shape "car" set size .2]

There is only one version of this model, created over 6 years ago by Arthur Hjorth.

Attached files

File Type Description Last updated
Tel Aviv Under Fire.png preview Preview for 'Tel Aviv Under Fire' almost 6 years ago, by Arthur Hjorth Download

This model does not have any ancestors.

This model does not have any descendants.