Spanish3

Spanish3 preview image

1 collaborator

Default-person David K (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.4.0 • Viewed 4 times • Downloaded 0 times • Run 0 times
Download the 'Spanish3' 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 [people person]
breed [labels label-turtle]
breed [buses bus]

turtles-own [
  destination
]

patches-own [
  building-type
  is-road?
]

to setup
  clear-all
  resize-world -30 30 -30 30
  set-patch-size 10
  setup-roads
  setup-buildings
  setup-labels
  setup-beach
  setup-people
  setup-bus
  reset-ticks
end 

to setup-roads
  ask patches [
    set pcolor green
    set is-road? false
  ]

  ;; Horizontal roads (every 8 rows)
  ask patches with [pycor mod 8 = 0] [
    set pcolor gray
    set is-road? true
  ]

  ;; Vertical roads (every 8 columns)
  ask patches with [pxcor mod 8 = 0] [
    set pcolor gray
    set is-road? true
  ]
end 

to setup-buildings
  ;; North West Quadrant (x < 0, y > 0)
  draw-building -22 24 "Supermercado" "box"
  draw-building -30 24 "" "house"
  draw-building -30 16 "" "house"
  draw-building -30 8 "" "house"
  draw-building -30 0 "" "house"
  draw-building -22 0 "" "house"
  draw-building -16 0 "" "house"
  draw-building -24 16 "Garaje" "box"
  draw-building -16 24 "Banco" "bank"
  draw-building -8 14 "Calle de Jupiter" "flag"
  draw-building -16 8 "Parque" "tree"
  draw-building -8 8 "" "house"
  draw-building -14 10 "" "tree"
  draw-building -16 16 "Fruitería" "strawberry"
  draw-building -6 24 "Ayuntamiento" "government"
  draw-building -6 18 "" "house"
  draw-building -24 8 "Viviendas" "bungalo"
  draw-building -21 10 "" "bungalo"
  draw-building -7 0 "Estación de fuego" "fire"

  ;; North East Quadrant (x >= 0, y > 0)
draw-building 10 24 "Centro comercial" "building"
  draw-building 2 8 "Universidad" "building"
  draw-building 8 16 "Autobus" "bus"
  draw-building 16 8 "Jardín" "flower"
  draw-building 24 8 "" "house"
  draw-building 8 8 "" "house"
  draw-building 17 0 "" "house"
  draw-building 25 0 "" "house"
  draw-building 19 16 "Cancha de Baloncesto" "basketball"
  draw-building 24 16 "" "house"
  draw-building 8 0 "Pizzería" "pizza"
  draw-building 0 16 "Escuela" "school"
  draw-building 2 24 "" "house"
  draw-building 16 24 "" "house"
  draw-building 24 24 "" "house"
  draw-building 2 0 "Tienda de carros" "car"


  ;; South East Quadrant (x >= 0, y <= 0)
  draw-building 10 -8 "Garaje de mecánico" "box"
  draw-building 1 -24 "Hospital" "person doctor"
  draw-building 16 -24 "El apartamentos" "house"
  draw-building 24 -24 "" "house"
  draw-building 24 -16 "" "house"
  draw-building 24 -8 "" "house"
  draw-building 8 -24 "" "house"
  draw-building 0 -8 "" "house"
  draw-building 1 -16 "Estación de fuego" "fire"
  draw-building 8 -16 "Templo" "temple"
  draw-building 16 -16 "" "house"
  draw-building 16 -8 "" "house"

  ;; South West Quadrant (x < 0, y <= 0)
  draw-building -16 -8 "Banco" "bank"
  draw-building -24 -6 "" "house"
  draw-building -30 -8 "" "house"
  draw-building -30 -16 "" "house"
  draw-building -30 -24 "" "house"
  draw-building -22 -24 "" "house"
  draw-building -8 -16 "Restaurante" "restaurant"
  draw-building -6 -24 "Taco Bell" "restaurant"
  draw-building -14 -24 "La estación de policía" "police"
  draw-building -24 -16 "Escuela" "school"
  draw-building -24 -10 "Calle de Mercury" "flag"  ;; Placeholder road
  draw-building -16 -16 "Mansiones" "mansions"
  draw-building -6 -8 "El apartamentos" "house"
end 

to draw-building [x y name building-shape]
  ask patches with [pxcor >= x and pxcor < x + 5 and pycor >= y and pycor < y + 5 and not is-road?] [
    set pcolor green
    set building-type name
  ]

  create-labels 1 [
    setxy x + 3 y + 3
    set shape building-shape
    set label name
    set size 3
    set color black
    set label-color white
  ]
end 

to setup-labels
  ask labels [
    set hidden? false
  ]
end 

to setup-beach
  let beach-row min-pycor
  ask patches with [pycor = beach-row] [
    set pcolor blue
  ]
  ask patches with [pycor = beach-row + 1] [
    set pcolor blue
  ]
  ask patches with [pycor = beach-row + 2] [
    set pcolor yellow
  ]
    ask patches with [pycor = beach-row + 3] [
    set pcolor yellow
  ]
    ask patches with [pycor = beach-row + 4] [
    set pcolor yellow
  ]
    ask patches with [pycor = beach-row + 5] [
    set pcolor yellow
  ]
end 

to setup-people
  create-people 20 [
    let beach-patch one-of patches with [pcolor = yellow]
    if beach-patch != nobody [
      setxy [pxcor] of beach-patch [pycor] of beach-patch
    ]
    set color white
    set shape "person"
    set size 2
    set destination nobody
  ]
end 

to setup-bus
  create-buses 2 [  ;; Create two buses
    let start-patch patch -24 -24
    if start-patch != nobody [
      setxy [pxcor] of start-patch [pycor] of start-patch
      set color red
      set shape "bus"
      set size 3
      set heading 90
    ]
  ]
end 

to move-bus
  ask buses [
    let next-patch patch-ahead 0.5
    if next-patch != nobody and [is-road?] of next-patch [
      fd 0.1
    ]
    if next-patch = nobody or not [is-road?] of next-patch [
      rt 90
    ]
  ]
end 

to go
  ask people [
    if destination = nobody or distance destination < 1 [
      let options patches with [building-type != "" and distance myself > 2]
      if any? options [
        set destination one-of options
      ]
    ]

    if destination != nobody [
      let target-x [pxcor] of destination
      let target-y [pycor] of destination

      let nearest-road min-one-of patches with [is-road?] [distancexy target-x target-y]

      if nearest-road != nobody [
        face nearest-road
        rt random 10 - 5  ;; slight wobble
        let next-step patch-ahead 0.5
        if next-step != nobody and [is-road?] of next-step [
          fd 0.5
        ]
      ]
    ]
  ]
  move-bus
  tick
end 

There is only one version of this model, created 21 days ago by David K.

Attached files

File Type Description Last updated
Spanish3.png preview Preview for 'Spanish3' 21 days ago, by David K Download

This model does not have any ancestors.

This model does not have any descendants.