alg-Aldea Lúdica

alg-Aldea Lúdica preview image

2 collaborators

Man_Hauser (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.5 • Viewed 341 times • Downloaded 29 times • Run 0 times
Download the 'alg-Aldea Lúdica' 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

globals [
  test
  xx
  yy
  x1
  y1
  x2
  y2  
  x3
  y3
  x4
  y4
  x5
  y5
  innovacion1
  innovacion2
  innovacion3
  innovacion4
  innovacion5
  innovacion-1
  innovacion-2
  innovacion-3
  innovacion-4
  innovacion-5
]
;NODOS
breed [nodos nodo]
breed [halos halo]
;TERRITORIO
patches-own [agro vivienda taller laboratorio escenico cultural agro? vivienda? taller? laboratorio? escenico? cultural? nodeable]
;AGENTES
breed [ciudadanos-i ciudadano-i]
breed [locales local]
breed [expertos experto]
breed [visitantes visitante]
;RECURSOS
breed [economicos economico]
breed [hardwares hardware]
breed [aplicaciones aplicacion]
breed [objetosculturales objetocultural]
breed [materiales material]

;PROPIEDADES INTERNAS
nodos-own [nciudadano-i nlocal nexperto nvisitante neconomico nhardware naplicacion nobjetocultural nmaterial territorio agentes recursos]
turtles-own [tipo meses]

;LINKS
undirected-link-breed [relacionesinternas relacioninterna]
directed-link-breed [relacionesexternas relacionexterna]
relacionesinternas-own [nodolink? vidarelacioninterna]
relacionesexternas-own [vidarelacionexterna]

to apuntar
    if mouse-down? [
      set xx round mouse-xcor
      set yy round mouse-ycor
    ]
    if nodo? = "alga"[
    set x1 xx
    set y1 yy
    ]
    if nodo? = "colorida"[
    set x2 xx
    set y2 yy
  ]
    if nodo? = "axouxere"[
    set x3 xx
    set y3 yy
  ]
    if nodo? = "ucv"[
    set x4 xx
    set y4 yy
  ]
    if nodo? = "sede"[
    set x5 xx
    set y5 yy
  ]
end 

to pintarprueba
  ca
  ask one-of patches [set pcolor blue]
  ask one-of patches [set pcolor red]
  ask one-of patches [set pcolor yellow]
  ask one-of patches [set pcolor pink]
  ask one-of patches [set pcolor brown]
end 

to posicion
  ask patches with [pcolor = blue] [
    set x1 pxcor 
    set y1 pycor]
  ask patches with [pcolor = red] [
    set x2 pxcor 
    set y2 pycor]
  ask patches with [pcolor = yellow] [
    set x3 pxcor 
    set y3 pycor]
  ask patches with [pcolor = pink] [
    set x4 pxcor 
    set y4 pycor]
  ask patches with [pcolor = brown] [
    set x5 pxcor 
    set y5 pycor]
end 

to setup
;  ask patches [set pcolor white]
  set innovacion1 0
  set innovacion2 0
  set innovacion3 0
  set innovacion4 0
  set innovacion5 0
  set innovacion-1 0
  set innovacion-2 0
  set innovacion-3 0
  set innovacion-4 0
  set innovacion-5 0
  set test[
    [2 3 2 3 3 2 1 4 2 2 3 4 3 2 2]
    [3 4 1 1 2 4 2 2 1 3 1 1 1 3 2]
    [0 3 0 0 2 5 2 1 1 2 2 1 1 5 0]
    [0 1 0 0 4 4 1 3 2 2 1 1 0 4 0]
    [3 3 1 0 2 3 2 2 0 5 1 1 0 3 0]
  ]
  let colors [green blue red yellow orange violet] 
  crt 1 [
    set breed nodos
    setxy x1 y1
    set shape "nodo"
    set tipo 0
    set size 5
    set color color1
    set meses 0
    hatch 1 [
    set breed halos
    set shape "halo"
    set size 25
    ask patches in-radius (13) [set nodeable 1]
    ]
    set agro item 0 item tipo test
    set vivienda item 1 item tipo test
    set taller item 2 item tipo test
    set laboratorio item 3 item tipo test
    set escenico item 4 item tipo test
    set cultural item 5 item tipo test
    set nciudadano-i item 6 item tipo test
    set nlocal item 7 item tipo test
    set nexperto item 8 item tipo test
    set nvisitante item 9 item tipo test
    set neconomico item 10 item tipo test
    set nhardware item 11 item tipo test
    set naplicacion item 12 item tipo test
    set nobjetocultural item 13 item tipo test
    set nmaterial item 14 item tipo test
    ask n-of agro patches in-radius (2 + 1)[
      set pcolor green
      set agro? 1]
    ask n-of vivienda patches in-radius (2 + 3) [
      set pcolor blue
      set vivienda? 1]
    ask n-of taller patches in-radius (2 + 5) [
      set pcolor red
      set taller? 1]
    ask n-of laboratorio patches in-radius (2 + 7) [
      set pcolor yellow
      set laboratorio? 1]
    ask n-of escenico patches in-radius (2 + 9) [
      set pcolor orange
      set escenico? 1]
    ask n-of cultural patches in-radius (2 + 11) [
      set pcolor violet
      set cultural? 1]
    hatch nciudadano-i [
      set breed ciudadanos-i
      setxy (x1 + random-float 3) (y1 + random-float 2)
      set shape "ciudadano-i"
      set size 2
      rt random 360
    ]
    hatch nlocal [
      set breed locales
      setxy (x1 + ((random-float  2) + 1)) (y1 + ((random-float  2) + 1))
      set shape "local"
      set size 2
      rt random 360
    ]
    hatch nexperto [
      set breed expertos
      setxy (x1 + ((random-float -2) + 2)) (y1 + ((random-float -2) + 2))
      set shape "experto"
      set size 2
      rt random 360
    ]
    hatch nvisitante [
      set breed visitantes
      setxy (x1 + ((random-float -2) + 2)) (y1 + ((random-float 2) + 2))
      set shape "visitante"
      set size 2
      rt random 360
    ]
    hatch neconomico [
      set breed economicos
      setxy (x1 + ((random-float -2) + 2)) (y1 + ((random-float -2) + 2))
      set shape "economico"
      set size 2
      rt random 360
    ]
    hatch nhardware [
      set breed hardwares
      setxy (x1 + ((random-float -2) + 2)) (y1 + ((random-float -2) + 2))
      set shape "hardware"
      set size 2
      rt random 360
    ]
    hatch naplicacion [
      set breed aplicaciones
      setxy (x1 + ((random-float -2) + 2)) (y1 + ((random-float -2) + 2))
      set shape "aplicacion"
      set size 2
      rt random 360
    ]
    hatch nobjetocultural [
      set breed objetosculturales
      setxy (x1 + ((random-float -2) + 2)) (y1 + ((random-float -2) + 2))
      set shape "objetocultural"
      set size 2
      rt random 360
    ]
    hatch nmaterial [
      set breed materiales
      setxy (x1 + ((random-float -2) + 2)) (y1 + ((random-float -2) + 2))
      set shape "material"
      set size 2
      rt random 360
    ]
  ]
  crt 1 [
    set breed nodos
    setxy x2 y2
    set shape "nodo"
    set tipo 1
    set size 5
    set color color2
    set meses 0
    hatch 1 [
    set breed halos
    set shape "halo"
    set size 25
    ask patches in-radius (13) [set nodeable 1]
    ]
    set agro item 0 item tipo test
    set vivienda item 1 item tipo test
    set taller item 2 item tipo test
    set laboratorio item 3 item tipo test
    set escenico item 4 item tipo test
    set cultural item 5 item tipo test
    set nciudadano-i item 6 item tipo test
    set nlocal item 7 item tipo test
    set nexperto item 8 item tipo test
    set nvisitante item 9 item tipo test
    set neconomico item 10 item tipo test
    set nhardware item 11 item tipo test
    set naplicacion item 12 item tipo test
    set nobjetocultural item 13 item tipo test
    ask n-of agro patches in-radius (2 + 1)[
      set pcolor green
      set agro? 2]
    ask n-of vivienda patches in-radius (2 + 3) [
      set pcolor blue
      set vivienda? 2]
    ask n-of taller patches in-radius (2 + 5) [
      set pcolor red
      set taller? 2]
    ask n-of laboratorio patches in-radius (2 + 7) [
      set pcolor yellow
      set laboratorio? 2]
    ask n-of escenico patches in-radius (2 + 9) [
      set pcolor orange
      set escenico? 2]
    ask n-of cultural patches in-radius (2 + 11) [
      set pcolor violet
      set cultural? 2]
    hatch nciudadano-i [
      set breed ciudadanos-i
      setxy (x2 + random-float 3) (y2 + random-float 2)
      set shape "ciudadano-i"
      set size 2
      rt random 360
    ]
    hatch nlocal [
      set breed locales
      setxy (x2 + ((random-float  2) + 1)) (y2 + ((random-float  2) + 1))
      set shape "local"
      set size 2
      rt random 360
    ]
    hatch nexperto [
      set breed expertos
      setxy (x2 + ((random-float -2) + 2)) (y2 + ((random-float -2) + 2))
      set shape "experto"
      set size 2
      rt random 360
    ]
    hatch nvisitante [
      set breed visitantes
      setxy (x2 + ((random-float -2) + 2)) (y2 + ((random-float 2) + 2))
      set shape "visitante"
      set size 2
      rt random 360
    ]
    hatch neconomico [
      set breed economicos
      setxy (x2 + ((random-float -2) + 2)) (y2 + ((random-float -2) + 2))
      set shape "economico"
      set size 2
      rt random 360
    ]
    hatch nhardware [
      set breed hardwares
      setxy (x2 + ((random-float -2) + 2)) (y2 + ((random-float -2) + 2))
      set shape "hardware"
      set size 2
      rt random 360
    ]
    hatch naplicacion [
      set breed aplicaciones
      setxy (x2 + ((random-float -2) + 2)) (y2 + ((random-float -2) + 2))
      set shape "aplicacion"
      set size 2
      rt random 360
    ]
    hatch nobjetocultural [
      set breed objetosculturales
      setxy (x2 + ((random-float -2) + 2)) (y2 + ((random-float -2) + 2))
      set shape "objetocultural"
      set size 2
      rt random 360
    ]
    hatch nmaterial [
      set breed materiales
      setxy (x2 + ((random-float -2) + 2)) (y2 + ((random-float -2) + 2))
      set shape "material"
      set size 2
      rt random 360
    ]
  ]
    crt 1 [
    set breed nodos
    setxy x3 y3
    set shape "nodo"
    set tipo 2
    set size 5
    set color color3
    set meses 0
    hatch 1 [
    set breed halos
    set shape "halo"
    set size 25
    ask patches in-radius (13) [set nodeable 1]
    ]
    set agro item 0 item tipo test
    set vivienda item 1 item tipo test
    set taller item 2 item tipo test
    set laboratorio item 3 item tipo test
    set escenico item 4 item tipo test
    set cultural item 5 item tipo test
    set nciudadano-i item 6 item tipo test
    set nlocal item 7 item tipo test
    set nexperto item 8 item tipo test
    set nvisitante item 9 item tipo test
    set neconomico item 10 item tipo test
    set nhardware item 11 item tipo test
    set naplicacion item 12 item tipo test
    set nobjetocultural item 13 item tipo test
    ask n-of agro patches in-radius (2 + 1)[
      set pcolor green
      set agro? 3]
    ask n-of vivienda patches in-radius (2 + 3) [
      set pcolor blue
      set vivienda? 3]
    ask n-of taller patches in-radius (2 + 5) [
      set pcolor red
      set taller? 3]
    ask n-of laboratorio patches in-radius (2 + 7) [
      set pcolor yellow
      set laboratorio? 3]
    ask n-of escenico patches in-radius (2 + 9) [
      set pcolor orange
      set escenico? 3]
    ask n-of cultural patches in-radius (2 + 11) [
      set pcolor violet
      set cultural? 3]
    hatch nciudadano-i [
      set breed ciudadanos-i
      setxy (x3 + random-float 3) (y3 + random-float 2)
      set shape "ciudadano-i"
      set size 2
      rt random 360
    ]
    hatch nlocal [
      set breed locales
      setxy (x3 + ((random-float  2) + 1)) (y3 + ((random-float  2) + 1))
      set shape "local"
      set size 2
      rt random 360
    ]
    hatch nexperto [
      set breed expertos
      setxy (x3 + ((random-float -2) + 2)) (y3 + ((random-float -2) + 2))
      set shape "experto"
      set size 2
      rt random 360
    ]
    hatch nvisitante [
      set breed visitantes
      setxy (x3 + ((random-float -2) + 2)) (y3 + ((random-float 2) + 2))
      set shape "visitante"
      set size 2
      rt random 360
    ]
    hatch neconomico [
      set breed economicos
      setxy (x3 + ((random-float -2) + 2)) (y3 + ((random-float -2) + 2))
      set shape "economico"
      set size 2
      rt random 360
    ]
    hatch nhardware [
      set breed hardwares
      setxy (x3 + ((random-float -2) + 2)) (y3 + ((random-float -2) + 2))
      set shape "hardware"
      set size 2
    ]
    hatch naplicacion [
      set breed aplicaciones
      setxy (x3 + ((random-float -2) + 2)) (y3 + ((random-float -2) + 2))
      set shape "aplicacion"
      set size 2
      rt random 360
    ]
    hatch nobjetocultural [
      set breed objetosculturales
      setxy (x3 + ((random-float -2) + 2)) (y3 + ((random-float -2) + 2))
      set shape "objetocultural"
      set size 2
      rt random 360
    ]
    hatch nmaterial [
      set breed materiales
      setxy (x3 + ((random-float -2) + 2)) (y3 + ((random-float -2) + 2))
      set shape "material"
      set size 2
      rt random 360
    ]
  ]
    crt 1 [
    set breed nodos
    setxy x4 y4
    set shape "nodo"
    set tipo 3
    set size 5
    set color color4
    set meses 0
    hatch 1 [
    set breed halos
    set shape "halo"
    set size 25
    ask patches in-radius (13) [set nodeable 1]
    ]
    set agro item 0 item tipo test
    set vivienda item 1 item tipo test
    set taller item 2 item tipo test
    set laboratorio item 3 item tipo test
    set escenico item 4 item tipo test
    set cultural item 5 item tipo test
    set nciudadano-i item 6 item tipo test
    set nlocal item 7 item tipo test
    set nexperto item 8 item tipo test
    set nvisitante item 9 item tipo test
    set neconomico item 10 item tipo test
    set nhardware item 11 item tipo test
    set naplicacion item 12 item tipo test
    set nobjetocultural item 13 item tipo test
    ask n-of agro patches in-radius (2 + 1)[
      set pcolor green
      set agro? 4]
    ask n-of vivienda patches in-radius (2 + 3) [
      set pcolor blue
      set vivienda? 4]
    ask n-of taller patches in-radius (2 + 5) [
      set pcolor red
      set taller? 4]
    ask n-of laboratorio patches in-radius (2 + 7) [
      set pcolor yellow
      set laboratorio? 4]
    ask n-of escenico patches in-radius (2 + 9) [
      set pcolor orange
      set escenico? 4]
    ask n-of cultural patches in-radius (2 + 11) [
      set pcolor violet
      set cultural? 4]
    hatch nciudadano-i [
      set breed ciudadanos-i
      setxy (x4 + random-float 3) (y4 + random-float 2)
      set shape "ciudadano-i"
      set size 2
      rt random 360
    ]
    hatch nlocal [
      set breed locales
      setxy (x4 + ((random-float  2) + 1)) (y4 + ((random-float  2) + 1))
      set shape "local"
      set size 2
      rt random 360
    ]
    hatch nexperto [
      set breed expertos
      setxy (x4 + ((random-float -2) + 2)) (y4 + ((random-float -2) + 2))
      set shape "experto"
      set size 2
      rt random 360
    ]
    hatch nvisitante [
      set breed visitantes
      setxy (x4 + ((random-float -2) + 2)) (y4 + ((random-float 2) + 2))
      set shape "visitante"
      set size 2
      rt random 360
    ]
    hatch neconomico [
      set breed economicos
      setxy (x4 + ((random-float -2) + 2)) (y4 + ((random-float -2) + 2))
      set shape "economico"
      set size 2
      rt random 360
    ]
    hatch nhardware [
      set breed hardwares
      setxy (x4 + ((random-float -2) + 2)) (y4 + ((random-float -2) + 2))
      set shape "hardware"
      set size 2
      rt random 360
    ]
    hatch naplicacion [
      set breed aplicaciones
      setxy (x4 + ((random-float -2) + 2)) (y4 + ((random-float -2) + 2))
      set shape "aplicacion"
      set size 2
      rt random 360
    ]
    hatch nobjetocultural [
      set breed objetosculturales
      setxy (x4 + ((random-float -2) + 2)) (y4 + ((random-float -2) + 2))
      set shape "objetocultural"
      set size 2
      rt random 360
    ]
    hatch nmaterial [
      set breed materiales
      setxy (x4 + ((random-float -2) + 2)) (y4 + ((random-float -2) + 2))
      set shape "material"
      set size 2
      rt random 360
    ]
  ]
    crt 1 [
    set breed nodos
    setxy x5 y5
    set shape "nodo"
    set tipo 4
    set size 5
    set color color5
    set meses 0
    hatch 1 [
    set breed halos
    set shape "halo"
    set size 25
    ask patches in-radius (13) [set nodeable 1]
    ]
    set agro item 0 item tipo test
    set vivienda item 1 item tipo test
    set taller item 2 item tipo test
    set laboratorio item 3 item tipo test
    set escenico item 4 item tipo test
    set cultural item 5 item tipo test
    set nciudadano-i item 6 item tipo test
    set nlocal item 7 item tipo test
    set nexperto item 8 item tipo test
    set nvisitante item 9 item tipo test
    set neconomico item 10 item tipo test
    set nhardware item 11 item tipo test
    set naplicacion item 12 item tipo test
    set nobjetocultural item 13 item tipo test
    ask n-of agro patches in-radius (2 + 1)[
      set pcolor green
      set agro? 5]
    ask n-of vivienda patches in-radius (2 + 3) [
      set pcolor blue
      set vivienda? 5]
    ask n-of taller patches in-radius (2 + 5) [
      set pcolor red
      set taller? 5]
    ask n-of laboratorio patches in-radius (2 + 7) [
      set pcolor yellow
      set laboratorio? 5]
    ask n-of escenico patches in-radius (2 + 9) [
      set pcolor orange
      set escenico? 5]
    ask n-of cultural patches in-radius (2 + 11) [
      set pcolor violet
      set cultural? 5]
    hatch nciudadano-i [
      set breed ciudadanos-i
      setxy (x5 + random-float 3) (y5 + random-float 2)
      set shape "ciudadano-i"
      set size 2
      rt random 360
    ]
    hatch nlocal [
      set breed locales
      setxy (x5 + ((random-float  2) + 1)) (y5 + ((random-float  2) + 1))
      set shape "local"
      set size 2
      rt random 360
    ]
    hatch nexperto [
      set breed expertos
      setxy (x5 + ((random-float -2) + 2)) (y5 + ((random-float -2) + 2))
      set shape "experto"
      set size 2
      rt random 360
    ]
    hatch nvisitante [
      set breed visitantes
      setxy (x5 + ((random-float -2) + 2)) (y5 + ((random-float 2) + 2))
      set shape "visitante"
      set size 2
      rt random 360
    ]
    hatch neconomico [
      set breed economicos
      setxy (x5 + ((random-float -2) + 2)) (y5 + ((random-float -2) + 2))
      set shape "economico"
      set size 2
      rt random 360
    ]
    hatch nhardware [
      set breed hardwares
      setxy (x5 + ((random-float -2) + 2)) (y5 + ((random-float -2) + 2))
      set shape "hardware"
      set size 2
    ]
    hatch naplicacion [
      set breed aplicaciones
      setxy (x5 + ((random-float -2) + 2)) (y5 + ((random-float -2) + 2))
      set shape "aplicacion"
      set size 2
      rt random 360
    ]
    hatch nobjetocultural [
      set breed objetosculturales
      setxy (x5 + ((random-float -2) + 2)) (y5 + ((random-float -2) + 2))
      set shape "objetocultural"
      set size 2
      rt random 360
    ]
    hatch nmaterial [
      set breed materiales
      setxy (x5 + ((random-float -2) + 2)) (y5 + ((random-float -2) + 2))
      set shape "material"
      set size 2
      rt random 360
    ]
  ]
  reset-ticks
end 

to make-movie

  ;; prompt user for movie location
  user-message "Primero, ponle un nombre a tu película (elige uno terminado en .mov)"
  let path user-new-file
  if not is-string? path [ stop ]  ;; stop if user canceled

  ;; run the model
  ;setup
  movie-start path
  movie-grab-view
  while [continuarpelicula?] 
    [ go
      if (ayudar?)[ayudar]
      movie-grab-view ]

  ;; export the movie
  movie-close
  user-message (word "Exported movie to " path)
end 

to visualizar
  ask nodos with [tipo = 0] [
    set label "alg-a"
  ]
  ask nodos with [tipo = 1] [
    set label "colorida"
  ]
  ask nodos with [tipo = 2] [
    set label "axouxere"
  ]
  ask nodos with [tipo = 3] [
    set label "ucv"
  ]
  ask nodos with [tipo = 4] [
    set label "sede"
  ]
end 

to ayudar
  crt ayuda-externa-cantidad[
    if (nodo? = "alga") [
      setxy x1 y1
      set size 2 
      set tipo 0
      set innovacion-1 (innovacion-1 - ayuda-externa-cantidad)]
    if (nodo? = "colorida") [
      setxy x2 y2
      set size 2 
      set tipo 1
      set innovacion-2 (innovacion-2 - ayuda-externa-cantidad)]
    if (nodo? = "axouxere") [
      setxy x3 y3
      set size 2 
      set tipo 2
      set innovacion-3 (innovacion-3 - ayuda-externa-cantidad)]
    if (nodo? = "ucv") [
      setxy x4 y4
      set size 2 
      set tipo 3
      set innovacion-4 (innovacion-4 - ayuda-externa-cantidad)]
    if (nodo? = "sede") [
      setxy x5 y5
      set size 2 
      set tipo 4
      set innovacion-5 (innovacion-5 - ayuda-externa-cantidad)]
    if (ayuda-externa = "ciudadano-i") [
    set breed ciudadanos-i
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "experto") [
    set breed expertos
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "local") [
    set breed locales
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "visitante") [
    set breed visitantes
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "economico") [
    set breed economicos
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "hardware") [
    set breed hardwares
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "aplicacion") [
    set breed aplicaciones
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "objetocultural") [
    set breed objetosculturales
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "material") [
    set breed materiales
    set size 2
    set shape ayuda-externa]
  ]
end 

to comprar
  if (nodo? = "alga") [
  ask one-of economicos with [tipo = 0][
      set innovacion-1 (innovacion-1 - 1)
    if (ayuda-externa = "ciudadano-i") [
    set breed ciudadanos-i
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "experto") [
    set breed expertos
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "local") [
    set breed locales
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "visitante") [
    set breed visitantes
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "economico") [
    set breed economicos
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "hardware") [
    set breed hardwares
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "aplicacion") [
    set breed aplicaciones
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "objetocultural") [
    set breed objetosculturales
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "material") [
    set breed materiales
    set size 2
    set shape ayuda-externa]
  ]
  ]
    if (nodo? = "colorida") [
      ask one-of economicos with [tipo = 1][
      set innovacion-2 (innovacion-2 - 1)
    if (ayuda-externa = "ciudadano-i") [
    set breed ciudadanos-i
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "experto") [
    set breed expertos
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "local") [
    set breed locales
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "visitante") [
    set breed visitantes
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "economico") [
    set breed economicos
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "hardware") [
    set breed hardwares
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "aplicacion") [
    set breed aplicaciones
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "objetocultural") [
    set breed objetosculturales
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "material") [
    set breed materiales
    set size 2
    set shape ayuda-externa]
  ]
    ]
         
    if (nodo? = "axouxere") [
      ask one-of economicos with [tipo = 2][
      set innovacion-3 (innovacion-3 - 1)
    if (ayuda-externa = "ciudadano-i") [
    set breed ciudadanos-i
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "experto") [
    set breed expertos
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "local") [
    set breed locales
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "visitante") [
    set breed visitantes
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "economico") [
    set breed economicos
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "hardware") [
    set breed hardwares
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "aplicacion") [
    set breed aplicaciones
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "objetocultural") [
    set breed objetosculturales
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "material") [
    set breed materiales
    set size 2
    set shape ayuda-externa]
  ]
    ] 
    if (nodo? = "ucv") [
      ask one-of economicos with [tipo = 3][
      set innovacion-4 (innovacion-4 - 1)
    if (ayuda-externa = "ciudadano-i") [
    set breed ciudadanos-i
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "experto") [
    set breed expertos
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "local") [
    set breed locales
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "visitante") [
    set breed visitantes
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "economico") [
    set breed economicos
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "hardware") [
    set breed hardwares
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "aplicacion") [
    set breed aplicaciones
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "objetocultural") [
    set breed objetosculturales
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "material") [
    set breed materiales
    set size 2
    set shape ayuda-externa]
  ]
    ]
    if (nodo? = "sede") [
      ask one-of economicos with [tipo = 4][
      set innovacion-5 (innovacion-5 - 1)
    if (ayuda-externa = "ciudadano-i") [
    set breed ciudadanos-i
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "experto") [
    set breed expertos
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "local") [
    set breed locales
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "visitante") [
    set breed visitantes
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "economico") [
    set breed economicos
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "hardware") [
    set breed hardwares
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "aplicacion") [
    set breed aplicaciones
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "objetocultural") [
    set breed objetosculturales
    set size 2
    set shape ayuda-externa]
    if (ayuda-externa = "material") [
    set breed materiales
    set size 2
    set shape ayuda-externa]
  ]
    ]
end 

to go
  if (color1 >= 55 and color2 >= 55 and color3 >= 55 and color4 >= 55 and color5 >= 55) [ stop ] 
  ask turtles  [
  movimientosinternos
  ]
  ask turtles [
    set meses meses + 1]
  ask nodos [relaciones]
  ask relacionesinternas [
    if vidarelacioninterna > 2 [
      die]
  ]
    ask relacionesexternas [
    if vidarelacionexterna > 2 [
      die]
  ]
  if rede? [conectarredes]
  tick
  update-plots
  if  (ticks != 0) and (ticks mod fase = 0) [
      comprobarfase
      set innovacion1 0
      set innovacion2 0
      set innovacion3 0
      set innovacion4 0
      set innovacion5 0
      set innovacion-1 0
      set innovacion-2 0
      set innovacion-3 0
      set innovacion-4 0
      set innovacion-5 0
  ]
  ask relacionesinternas [set vidarelacioninterna (vidarelacioninterna + 1)]
  ask relacionesexternas [set vidarelacionexterna (vidarelacionexterna + 1)]
  if evolucion? [evolucion]
  if perdidas? [perdidas]
end 

to relaciones
  relacion1
  relacion2
  relacion3
  relacion4
  relacion5
  relacion6
  relacion7
end 

to conectarredes
  rede1
  rede2
  rede3
  rede4
  rede5
  rede6
  rede7
end 

to marronar
  set color1 35
  set color2 35
  set color3 35
  set color4 35
  set color5 35
end 

to comprobarfase
    ask nodos[
      if color1 < 56 [set color1 (color1 + round (innovacion1 / 4) + round ((innovacion-1) / 2))]
      if color2 < 56 [set color2 (color2 + round (innovacion2 / 4) + round ((innovacion-2) / 2))]
      if color3 < 56 [set color3 (color3 + round (innovacion3 / 4) + round ((innovacion-3) / 2))]
      if color4 < 56 [set color4 (color4 + round (innovacion4 / 4) + round ((innovacion-4) / 2))]
      if color5 < 56 [set color5 (color5 + round (innovacion5 / 4) + round ((innovacion-5) / 2))]
      ]
    ask nodos with [tipo = 0] [
      set color color1
      set territorio ((count patches in-radius 11 with [pcolor = red]) + (count patches in-radius 11 with [pcolor = yellow]) + (count patches in-radius 11 with [pcolor = green]) + (count patches in-radius 11 with [pcolor = orange]) + (count patches in-radius 11 with [pcolor = blue]))
      set agentes ((count locales with [ tipo = 0]) + (count expertos with [ tipo = 0]) + (count ciudadanos-i with [ tipo = 0]) + (count visitantes with [ tipo = 0]))
      set recursos ((count materiales with [ tipo = 0]) + (count hardwares with [ tipo = 0]) + (count economicos with [ tipo = 0]) + (count aplicaciones with [ tipo = 0])+ (count objetosculturales with [ tipo = 0]))
    ]
    ask nodos with [tipo = 1] [
      set color color2
      set territorio ((count patches in-radius 11 with [pcolor = red]) + (count patches in-radius 11 with [pcolor = yellow]) + (count patches in-radius 11 with [pcolor = green]) + (count patches in-radius 11 with [pcolor = orange]) + (count patches in-radius 11 with [pcolor = blue]))
      set agentes ((count locales with [ tipo = 1]) + (count expertos with [ tipo = 1]) + (count ciudadanos-i with [ tipo = 1]) + (count visitantes with [ tipo = 1]))
      set recursos ((count materiales with [ tipo = 1]) + (count hardwares with [ tipo = 1]) + (count economicos with [ tipo = 1]) + (count aplicaciones with [ tipo = 1])+ (count objetosculturales with [ tipo = 1]))
    ]
    ask nodos with [tipo = 2] [
      set color color3
      set territorio ((count patches in-radius 11 with [pcolor = red]) + (count patches in-radius 11 with [pcolor = yellow]) + (count patches in-radius 11 with [pcolor = green]) + (count patches in-radius 11 with [pcolor = orange]) + (count patches in-radius 11 with [pcolor = blue]))
      set agentes ((count locales with [ tipo = 2]) + (count expertos with [ tipo = 2]) + (count ciudadanos-i with [ tipo = 2]) + (count visitantes with [ tipo = 2]))
      set recursos ((count materiales with [ tipo = 2]) + (count hardwares with [ tipo = 2]) + (count economicos with [ tipo = 2]) + (count aplicaciones with [ tipo = 2])+ (count objetosculturales with [ tipo = 2]))
    ]
    ask nodos with [tipo = 3] [
      set color color4
      set territorio ((count patches in-radius 11 with [pcolor = red]) + (count patches in-radius 11 with [pcolor = yellow]) + (count patches in-radius 11 with [pcolor = green]) + (count patches in-radius 11 with [pcolor = orange]) + (count patches in-radius 11 with [pcolor = blue]))
      set agentes ((count locales with [ tipo = 3]) + (count expertos with [ tipo = 3]) + (count ciudadanos-i with [ tipo = 3]) + (count visitantes with [ tipo = 3]))
      set recursos ((count materiales with [ tipo = 3]) + (count hardwares with [ tipo = 3]) + (count economicos with [ tipo = 3]) + (count aplicaciones with [ tipo = 3])+ (count objetosculturales with [ tipo = 3]))
    ]
    ask nodos with [tipo = 4] [
      set color color5
      set territorio ((count patches in-radius 11 with [pcolor = red]) + (count patches in-radius 11 with [pcolor = yellow]) + (count patches in-radius 11 with [pcolor = green]) + (count patches in-radius 11 with [pcolor = orange]) + (count patches in-radius 11 with [pcolor = blue]))
      set agentes ((count locales with [ tipo = 4]) + (count expertos with [ tipo = 4]) + (count ciudadanos-i with [ tipo = 4]) + (count visitantes with [ tipo = 4]))
      set recursos ((count materiales with [ tipo = 4]) + (count hardwares with [ tipo = 4]) + (count economicos with [ tipo = 4]) + (count aplicaciones with [ tipo = 4])+ (count objetosculturales with [ tipo = 4]))
    ]
    ask halos with [tipo = 0][
      set color color1
      ]
    ask halos with [tipo = 1][
      set color color2
    ]
    ask halos with [tipo = 2][
      set color color3
      ]
    ask halos with [tipo = 3][
      set color color4
    ]
    ask halos with [tipo = 4][
      set color color5
      ]
end 

to movimientosinternos
  ask turtles with [(breed != nodos) and (breed != halos)][
  ifelse (nodeable = 1) [
  fd  1
  ]
  [
  rt ((random 30) + 180)
  fd 1
  ]
;  create-links-with other turtles in-radius 5 with [(breed != nodos) and (breed != halos)] [
;    set color yellow]
  
  ]
end 

to recolorear
;    if (pcolor < 10) [set pcolor white]
    if ((pcolor > 12  and pcolor <= 19)  or (pcolor >= 22 and pcolor <= 29) or (pcolor >= 122 and pcolor <= 129) or (pcolor >= 132 and pcolor <= 139)) [set pcolor grey set nodeable 1]
;    if (pcolor >= 20 and pcolor < 40) [set pcolor orange]
;    if (pcolor >= 40 and pcolor < 50) [set pcolor yellow]
;    if (pcolor >= 50 and pcolor < 90) [set pcolor green]
    if ((pcolor >= 72 and pcolor <= 79) or (pcolor >= 82 and pcolor <= 89) or (pcolor >= 92 and pcolor <= 99) or (pcolor >= 112 and pcolor <= 119) or (pcolor >= 102 and pcolor <= 109)) [set pcolor blue]
end 



;-----------------------------------------------------------EVOLUCION Y PERDIDAS-------------------------------------------------------------------------

to evolucion
  if (ticks != 0) and (ticks mod fase = 0)[
  ask ciudadanos-i with [meses >= fase][
    ifelse (random 1 = 1) [
      set breed expertos
      set shape "experto"
      set meses 0]
    [if (random 2 = 2) [die]
      ]
  ]
  ask expertos with [meses >= fase][
    ifelse (random 1 = 1) [
      set breed ciudadanos-i
      set shape "ciudadano-i"
      set meses 0]
    [die]
  ]
  ask visitantes with [meses >= fase][
    ifelse (random 2 = 2) [
      set breed expertos
      set shape "experto"
      set meses 0]
    [if random 2 = 2 [die]
      ]
  ]
  ]
end 

to perdidas
  if (ticks != 0) and (ticks mod fase = 0)[
    ask locales with [meses > fase][
    if random 7 = 7 [
    hatch 1 [
      set meses 0]
      ]
  ]
  ]
end 




;-------------------------------------------------RELACIONES EXTERNAS PORMENORIZADAS--------------------------------------------------------------

to rede1 ;intercambio ciudadanos-i
  
  let aleatorio1para0 (random 4)
  if any? economicos with [tipo = 0][
  if ((count ciudadanos-i with [tipo = 0]) > ((count ciudadanos-i with [tipo = aleatorio1para0 ])))[
    ask one-of nodos with [tipo = 0] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio1para0][
        set color yellow
        set innovacion1 (innovacion1 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of ciudadanos-i with [tipo = 0][
        face (one-of nodos with [tipo = aleatorio1para0])
        fd distance (one-of nodos with [tipo = aleatorio1para0])
        set tipo aleatorio1para0
        ]
      ]
      ]
  ]
  ask one-of economicos with [tipo = 0][
    die]
    ]
  let aleatorio1para1 (random 4)
  if any? economicos with [tipo = 1][
  if ((count ciudadanos-i with [tipo = 1]) > ((count ciudadanos-i with [tipo = aleatorio1para1 ])))[
    ask one-of nodos with [tipo = 1] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio1para1][
        set color yellow
        set innovacion2 (innovacion2 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of ciudadanos-i with [tipo = 1][
        face (one-of nodos with [tipo = aleatorio1para1])
        fd distance (one-of nodos with [tipo = aleatorio1para1])
        set tipo aleatorio1para1
        ]
      ]
      ]
    ]
  ask one-of economicos with [tipo = 1][
    die]
  ]
  let aleatorio1para2 (random 4)
  if any? economicos with [tipo = 2][
  if ((count ciudadanos-i with [tipo = 2]) > ((count ciudadanos-i with [tipo = aleatorio1para2 ])))[
    ask one-of nodos with [tipo = 2] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio1para2][
        set color yellow
        set innovacion3 (innovacion3 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of ciudadanos-i with [tipo = 2][
        face (one-of nodos with [tipo = aleatorio1para2])
        fd distance (one-of nodos with [tipo = aleatorio1para2])
        set tipo aleatorio1para2
        ]
      ]
      ]
    ]
  ask one-of economicos with [tipo = 2][
    die]
  ]
  let aleatorio1para3 (random 4)
  if any? economicos with [tipo = 3][
  if ((count ciudadanos-i with [tipo = 3]) > ((count ciudadanos-i with [tipo = aleatorio1para3 ])))[
    ask one-of nodos with [tipo = 3] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio1para3][
        set color yellow
        set innovacion4 (innovacion4 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of ciudadanos-i with [tipo = 3][
        face (one-of nodos with [tipo = aleatorio1para3])
        fd distance (one-of nodos with [tipo = aleatorio1para3])
        set tipo aleatorio1para3
        ]
      ]
      ]
    ]
  ask one-of economicos with [tipo = 3][
    die]
  ]
  let aleatorio1para4 (random 4)
  if any? economicos with [tipo = 4][
  if ((count ciudadanos-i with [tipo = 4]) > ((count ciudadanos-i with [tipo = aleatorio1para4 ])))[
    ask one-of nodos with [tipo = 4] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio1para4][
        set color yellow
        set innovacion5 (innovacion5 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of ciudadanos-i with [tipo = 4][
        face (one-of nodos with [tipo = aleatorio1para4])
        fd distance (one-of nodos with [tipo = aleatorio1para4])
        set tipo aleatorio1para4
        ]
      ]
      ]
    ]
  ask one-of economicos with [tipo = 4][
    die]
  ]
end 

to rede2 ;intercambio expertos
  
  let aleatorio2para0 (random 4)
  if any? economicos with [tipo = 0][
  if ((count expertos with [tipo = 0]) > ((count expertos with [tipo = aleatorio2para0 ])))[
    ask one-of nodos with [tipo = 0] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio2para0][
        set color pink
        set innovacion1 (innovacion1 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of expertos with [tipo = 0][
        face (one-of nodos with [tipo = aleatorio2para0])
        fd distance (one-of nodos with [tipo = aleatorio2para0])
        set tipo aleatorio2para0
        ]
      ]
      ]
  ]
  ask one-of economicos with [tipo = 0][
    die]
    ]
  let aleatorio2para1 (random 4)
  if any? economicos with [tipo = 1][
  if ((count expertos with [tipo = 1]) > ((count expertos with [tipo = aleatorio2para1 ])))[
    ask one-of nodos with [tipo = 1] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio2para1][
        set color pink
        set innovacion2 (innovacion2 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of expertos with [tipo = 1][
        face (one-of nodos with [tipo = aleatorio2para1])
        fd distance (one-of nodos with [tipo = aleatorio2para1])
        set tipo aleatorio2para1
        ]
      ]
      ]
    ]
  ask one-of economicos with [tipo = 1][
    die]
  ]
  let aleatorio2para2 (random 4)
  if any? economicos with [tipo = 2][
  if ((count expertos with [tipo = 2]) > ((count expertos with [tipo = aleatorio2para2 ])))[
    ask one-of nodos with [tipo = 2] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio2para2][
        set color pink
        set innovacion3 (innovacion3 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of expertos with [tipo = 2][
        face (one-of nodos with [tipo = aleatorio2para2])
        fd distance (one-of nodos with [tipo = aleatorio2para2])
        set tipo aleatorio2para2
        ]
      ]
      ]
    ]
  ask one-of economicos with [tipo = 2][
    die]
  ]
  let aleatorio2para3 (random 4)
  if any? economicos with [tipo = 3][
  if ((count expertos with [tipo = 3]) > ((count expertos with [tipo = aleatorio2para3 ])))[
    ask one-of nodos with [tipo = 3] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio2para3][
        set color pink
        set innovacion4 (innovacion4 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of expertos with [tipo = 3][
        face (one-of nodos with [tipo = aleatorio2para3])
        fd distance (one-of nodos with [tipo = aleatorio2para3])
        set tipo aleatorio2para3
        ]
      ]
      ]
    ]
  ask one-of economicos with [tipo = 3][
    die]
  ]
  let aleatorio2para4 (random 4)
  if any? economicos with [tipo = 4][
  if ((count expertos with [tipo = 4]) > ((count expertos with [tipo = aleatorio2para4 ])))[
    ask one-of nodos with [tipo = 4] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio2para4][
        set color pink
        set innovacion5 (innovacion5 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of expertos with [tipo = 4][
        face (one-of nodos with [tipo = aleatorio2para4])
        fd distance (one-of nodos with [tipo = aleatorio2para4])
        set tipo aleatorio2para4
        ]
      ]
      ]
    ]
  ask one-of economicos with [tipo = 4][
    die]
  ]
end 

to rede3    ;intercambio economicos
  
  let aleatorio3para0 (random 4)
  if ((count economicos with [tipo = 0]) > ((count economicos with [tipo = aleatorio3para0 ])))[
    ask one-of nodos with [tipo = 0] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio3para0][
        set color orange
        set innovacion1 (innovacion1 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of economicos with [tipo = 0][
        face (one-of nodos with [tipo = aleatorio3para0])
        fd distance (one-of nodos with [tipo = aleatorio3para0])
        set tipo aleatorio3para0
        ]
        ]
      ]
    ]
  let aleatorio3para1 (random 4)
  if ((count economicos with [tipo = 1]) > ((count economicos with [tipo = aleatorio3para1 ])))[
    ask one-of nodos with [tipo = 1] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio3para1][
        set color orange
        set innovacion2 (innovacion2 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of economicos with [tipo = 1][
        face (one-of nodos with [tipo = aleatorio3para1])
        fd distance (one-of nodos with [tipo = aleatorio3para1])
        set tipo aleatorio3para1
        ]
      ]
      ]
    ]
  let aleatorio3para2 (random 4)
  if ((count economicos with [tipo = 2]) > ((count economicos with [tipo = aleatorio3para2 ])))[
    ask one-of nodos with [tipo = 2] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio3para2][
        set color orange
        set innovacion3 (innovacion3 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of economicos with [tipo = 2][
        face (one-of nodos with [tipo = aleatorio3para1])
        fd distance (one-of nodos with [tipo = aleatorio3para1])
        set tipo aleatorio3para2
        ]
      ]
      ]
    ]
  let aleatorio3para3 (random 4)
  if ((count economicos with [tipo = 3]) > ((count economicos with [tipo = aleatorio3para3 ])))[
    ask one-of nodos with [tipo = 3] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio3para3][
        set color orange
        set innovacion4 (innovacion4 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of economicos with [tipo = 3][
        face (one-of nodos with [tipo = aleatorio3para3])
        fd distance (one-of nodos with [tipo = aleatorio3para3])
        set tipo aleatorio3para3
        ]
      ]
      ]
    ]
  
  let aleatorio3para4 (random 4)
  if ((count economicos with [tipo = 4]) > ((count economicos with [tipo = aleatorio3para4 ])))[
    ask one-of nodos with [tipo = 4] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio3para4][
        set color orange
        set innovacion5 (innovacion5 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of economicos with [tipo = 4][
        face (one-of nodos with [tipo = aleatorio3para4])
        fd distance (one-of nodos with [tipo = aleatorio3para4])
        set tipo aleatorio3para4
        ]
      ]
      ]
    ]
end 

to rede4    ;intercambio aplicaciones
  
  let aleatorio4para0 (random 4)
  if ((count aplicaciones with [tipo = 0]) > ((count aplicaciones with [tipo = aleatorio4para0 ])))[
    ask one-of nodos with [tipo = 0] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio4para0][
        set color magenta
        set innovacion1 (innovacion1 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of aplicaciones with [tipo = 0][
        face (one-of nodos with [tipo = aleatorio4para0])
        fd distance (one-of nodos with [tipo = aleatorio4para0])
        set tipo aleatorio4para0
        ]
        ]
      ]
    ]
  let aleatorio4para1 (random 4)
  if ((count aplicaciones with [tipo = 1]) > ((count aplicaciones with [tipo = aleatorio4para1 ])))[
    ask one-of nodos with [tipo = 1] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio4para1][
        set color magenta
        set innovacion2 (innovacion2 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of aplicaciones with [tipo = 1][
        face (one-of nodos with [tipo = aleatorio4para1])
        fd distance (one-of nodos with [tipo = aleatorio4para1])
        set tipo aleatorio4para1
        ]
      ]
      ]
    ]
  let aleatorio4para2 (random 4)
  if ((count aplicaciones with [tipo = 2]) > ((count aplicaciones with [tipo = aleatorio4para2 ])))[
    ask one-of nodos with [tipo = 2] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio4para2][
        set color magenta
        set innovacion3 (innovacion3 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of aplicaciones with [tipo = 2][
        face (one-of nodos with [tipo = aleatorio4para2])
        fd distance (one-of nodos with [tipo = aleatorio4para2])
        set tipo aleatorio4para2
        ]
      ]
      ]
    ]
  let aleatorio4para3 (random 4)
  if ((count aplicaciones with [tipo = 3]) > ((count aplicaciones with [tipo = aleatorio4para3 ])))[
    ask one-of nodos with [tipo = 3] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio4para3][
        set color magenta
        set innovacion4 (innovacion4 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of aplicaciones with [tipo = 3][
        face (one-of nodos with [tipo = aleatorio4para3])
        fd distance (one-of nodos with [tipo = aleatorio4para3])
        set tipo aleatorio4para3
        ]
      ]
      ]
    ]
  
  let aleatorio4para4 (random 4)
  if ((count aplicaciones with [tipo = 4]) > ((count aplicaciones with [tipo = aleatorio4para4 ])))[
    ask one-of nodos with [tipo = 4] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio4para4][
        set color magenta
        set innovacion5 (innovacion5 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of aplicaciones with [tipo = 4][
        face (one-of nodos with [tipo = aleatorio4para4])
        fd distance (one-of nodos with [tipo = aleatorio4para4])
        set tipo aleatorio4para4
        ]
      ]
      ]
    ]
end 

to rede5    ;intercambio objetos culturales
  
  let aleatorio5para0 (random 4)
  if ((count objetosculturales with [tipo = 0]) > ((count objetosculturales with [tipo = aleatorio5para0 ])))[
    ask one-of nodos with [tipo = 0] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio5para0][
        set color blue
        set innovacion1 (innovacion1 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of objetosculturales with [tipo = 0][
        face (one-of nodos with [tipo = aleatorio5para0])
        fd distance (one-of nodos with [tipo = aleatorio5para0])
        set tipo aleatorio5para0
        ]
        ]
      ]
    ]
  let aleatorio5para1 (random 4)
  if ((count objetosculturales with [tipo = 1]) > ((count objetosculturales with [tipo = aleatorio5para1 ])))[
    ask one-of nodos with [tipo = 1] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio5para1][
        set color blue
        set innovacion2 (innovacion2 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of objetosculturales with [tipo = 1][
        face (one-of nodos with [tipo = aleatorio5para1])
        fd distance (one-of nodos with [tipo = aleatorio5para1])
        set tipo aleatorio5para1
        ]
      ]
      ]
    ]
  let aleatorio5para2 (random 4)
  if ((count objetosculturales with [tipo = 2]) > ((count objetosculturales with [tipo = aleatorio5para2 ])))[
    ask one-of nodos with [tipo = 2] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio5para2][
        set color blue
        set innovacion3 (innovacion3 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of objetosculturales with [tipo = 2][
        face (one-of nodos with [tipo = aleatorio5para2])
        fd distance (one-of nodos with [tipo = aleatorio5para2])
        set tipo aleatorio5para2
        ]
      ]
      ]
    ]
  let aleatorio5para3 (random 4)
  if ((count objetosculturales with [tipo = 3]) > ((count objetosculturales with [tipo = aleatorio5para3 ])))[
    ask one-of nodos with [tipo = 3] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio5para3][
        set color blue
        set innovacion4 (innovacion4 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of objetosculturales with [tipo = 3][
        face (one-of nodos with [tipo = aleatorio5para3])
        fd distance (one-of nodos with [tipo = aleatorio5para3])
        set tipo aleatorio5para3
        ]
      ]
      ]
    ]
  
  let aleatorio5para4 (random 4)
  if ((count objetosculturales with [tipo = 4]) > ((count objetosculturales with [tipo = aleatorio5para4 ])))[
    ask one-of nodos with [tipo = 4] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio5para4][
        set color blue
        set innovacion5 (innovacion5 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of objetosculturales with [tipo = 4][
        face (one-of nodos with [tipo = aleatorio5para4])
        fd distance (one-of nodos with [tipo = aleatorio5para4])
        set tipo aleatorio5para4
        ]
      ]
      ]
    ]
end 

to rede6 ;intercambio hardwares
  
  let aleatorio6para0 (random 4)
  if any? economicos with [tipo = 0][
  if ((count hardwares with [tipo = 0]) > ((count hardwares with [tipo = aleatorio6para0 ])))[
    ask one-of nodos with [tipo = 0] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio6para0][
        set color brown
        set innovacion1 (innovacion1 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of hardwares with [tipo = 0][
        face (one-of nodos with [tipo = aleatorio6para0])
        fd distance (one-of nodos with [tipo = aleatorio6para0])
        set tipo aleatorio6para0
        ]
      ]
      ]
  ]
  ask one-of economicos with [tipo = 0][
    die]
    ]
  let aleatorio6para1 (random 4)
  if any? economicos with [tipo = 1][
  if ((count hardwares with [tipo = 1]) > ((count hardwares with [tipo = aleatorio6para1 ])))[
    ask one-of nodos with [tipo = 1] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio6para1][
        set color brown
        set innovacion2 (innovacion2 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of hardwares with [tipo = 1][
        face (one-of nodos with [tipo = aleatorio6para1])
        fd distance (one-of nodos with [tipo = aleatorio6para1])
        set tipo aleatorio6para1
        ]
      ]
      ]
    ]
  ask one-of economicos with [tipo = 1][
    die]
  ]
  let aleatorio6para2 (random 4)
  if any? economicos with [tipo = 2][
  if ((count hardwares with [tipo = 2]) > ((count hardwares with [tipo = aleatorio6para2 ])))[
    ask one-of nodos with [tipo = 2] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio6para2][
        set color brown
        set innovacion3 (innovacion3 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of hardwares with [tipo = 2][
        face (one-of nodos with [tipo = aleatorio6para2])
        fd distance (one-of nodos with [tipo = aleatorio6para2])
        set tipo aleatorio6para2
        ]
      ]
      ]
    ]
  ask one-of economicos with [tipo = 2][
    die]
  ]
  let aleatorio6para3 (random 4)
  if any? economicos with [tipo = 3][
  if ((count hardwares with [tipo = 3]) > ((count hardwares with [tipo = aleatorio6para3 ])))[
    ask one-of nodos with [tipo = 3] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio6para3][
        set color brown
        set innovacion4 (innovacion4 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of hardwares with [tipo = 3][
        face (one-of nodos with [tipo = aleatorio6para3])
        fd distance (one-of nodos with [tipo = aleatorio6para3])
        set tipo aleatorio6para3
        ]
      ]
      ]
    ]
  ask one-of economicos with [tipo = 3][
    die]
  ]
  let aleatorio6para4 (random 4)
  if any? economicos with [tipo = 4][
  if ((count hardwares with [tipo = 4]) > ((count hardwares with [tipo = aleatorio6para4 ])))[
    ask one-of nodos with [tipo = 4] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio6para4][
        set color brown
        set innovacion5 (innovacion5 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of hardwares with [tipo = 4][
        face (one-of nodos with [tipo = aleatorio6para4])
        fd distance (one-of nodos with [tipo = aleatorio6para4])
        set tipo aleatorio6para4
        ]
      ]
      ]
    ]
  ask one-of economicos with [tipo = 4][
    die]
  ]
end 

to rede7 ;intercambio materiales
  
  let aleatorio7para0 (random 4)
  if any? economicos with [tipo = 0][
  if ((count materiales with [tipo = 0]) > ((count materiales with [tipo = aleatorio7para0 ])))[
    ask one-of nodos with [tipo = 0] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio7para0][
        set color violet
        set innovacion1 (innovacion1 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of materiales with [tipo = 0][
        face (one-of nodos with [tipo = aleatorio7para0])
        fd distance (one-of nodos with [tipo = aleatorio7para0])
        set tipo aleatorio7para0
        ]
      ]
      ]
  ]
  ask one-of economicos with [tipo = 0][
    die]
    ]
  let aleatorio7para1 (random 4)
  if any? economicos with [tipo = 1][
  if ((count materiales with [tipo = 1]) > ((count materiales with [tipo = aleatorio7para1 ])))[
    ask one-of nodos with [tipo = 1] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio7para1][
        set color violet
        set innovacion2 (innovacion2 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of materiales with [tipo = 1][
        face (one-of nodos with [tipo = aleatorio7para1])
        fd distance (one-of nodos with [tipo = aleatorio7para1])
        set tipo aleatorio7para1
        ]
      ]
      ]
    ]
  ask one-of economicos with [tipo = 1][
    die]
  ]
  let aleatorio7para2 (random 4)
  if any? economicos with [tipo = 2][
  if ((count materiales with [tipo = 2]) > ((count materiales with [tipo = aleatorio7para2 ])))[
    ask one-of nodos with [tipo = 2] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio7para2][
        set color violet
        set innovacion3 (innovacion3 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of materiales with [tipo = 2][
        face (one-of nodos with [tipo = aleatorio7para2])
        fd distance (one-of nodos with [tipo = aleatorio7para2])
        set tipo aleatorio7para2
        ]
      ]
      ]
    ]
  ask one-of economicos with [tipo = 2][
    die]
  ]
  let aleatorio7para3 (random 4)
  if any? economicos with [tipo = 3][
  if ((count materiales with [tipo = 3]) > ((count materiales with [tipo = aleatorio7para3 ])))[
    ask one-of nodos with [tipo = 3] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio7para3][
        set color violet
        set innovacion4 (innovacion4 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of materiales with [tipo = 3][
        face (one-of nodos with [tipo = aleatorio7para3])
        fd distance (one-of nodos with [tipo = aleatorio7para3])
        set tipo aleatorio7para3
        ]
      ]
      ]
    ]
  ask one-of economicos with [tipo = 3][
    die]
  ]
  let aleatorio7para4 (random 4)
  if any? economicos with [tipo = 4][
  if ((count materiales with [tipo = 4]) > ((count materiales with [tipo = aleatorio7para4 ])))[
    ask one-of nodos with [tipo = 4] [
      create-relacionexterna-to one-of nodos with [tipo = aleatorio7para4][
        set color violet
        set innovacion5 (innovacion5 + 2)
        set shape "discontinuas"
        set vidarelacionexterna 0
        ask one-of materiales with [tipo = 4][
        face (one-of nodos with [tipo = aleatorio7para4])
        fd distance (one-of nodos with [tipo = aleatorio7para4])
        set tipo aleatorio7para4
        ]
      ]
      ]
    ]
  ask one-of economicos with [tipo = 4][
    die]
  ]
end 




;--------------------------------------------------RELACIONES INTERNAS PORMENORIZADAS----------------------------------------------------------------

to relacion1 ;La que describe un cultivo en colaboración local: Local + ciudadano-i + tierra = economico
  
    if any? patches with [agro? = 1][
    ask patches with [agro? = 1][
    if any? ciudadanos-i with [tipo = 0] in-radius 5[
    ask one-of ciudadanos-i  with [tipo = 0] in-radius 5 [
    if any? locales  with [tipo = 0] in-radius 5[
    create-relacioninterna-with one-of locales  with [tipo = 0] in-radius 5 
    [ set color green
      set nodolink? "nodo1"
      set innovacion1 (innovacion1 + 1)
      set vidarelacioninterna 0
      ]
     hatch ((random 1) + 1) [
        set meses 0
        set tipo 0
        set breed economicos
        set shape "economico"
        ]
     ]
    ]
    ]
    ]
]
  if any? patches with [agro? = 2][
  ask patches with [agro? = 2][
    if any? ciudadanos-i  with [tipo = 1] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 1] in-radius 5 [
    if any? locales with [tipo = 1] in-radius 5[
    create-relacioninterna-with one-of locales with [tipo = 1] in-radius 5 
    [ set color green
      set nodolink? "nodo2"
      set innovacion2 (innovacion2 + 1)
      set vidarelacioninterna 0
      ]
     hatch ((random 1) + 1) [
        set meses 0
        set tipo 1
        set breed economicos
        set shape "economico"
        ]
     ]
    ]
    ]
    ]
]
  if any? patches with [agro? = 3][
    ask one-of patches with [agro? = 3][
    if any? ciudadanos-i with [tipo = 2] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 2] in-radius 5 [
    if any? locales with [tipo = 2] in-radius 5[
    create-relacioninterna-with one-of locales with [tipo = 2] in-radius 5 
    [ set color green
      set nodolink? "nodo3"
      set innovacion3 (innovacion3 + 1)
      set vidarelacioninterna 0
      ]
     hatch ((random 1) + 1) [
        set meses 0
        set tipo 2
        set breed economicos
        set shape "economico"
        ]
     ]
    ]
    ]
    ]
]
    if any? patches with [agro? = 4][
      ask one-of patches with [agro? = 4][
    if any? ciudadanos-i with [tipo = 3] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 3] in-radius 5 [
    if any? locales with [tipo = 3] in-radius 5[
    create-relacioninterna-with one-of locales with [tipo = 3] in-radius 5 
    [ set color green
      set nodolink? "nodo4"
      set innovacion4 (innovacion4 + 1)
      set vidarelacioninterna 0
      ]
     hatch ((random 1) + 1) [
        set meses 0
        set tipo 3
        set breed economicos
        set shape "economico"
        ]
     ]
    ]
    ]
      ]
]
    if any? patches with [agro? = 5][
        ask one-of patches with [agro? = 5][
    if any? ciudadanos-i with [tipo = 4] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 4] in-radius 5 [
    if any? locales with [tipo = 4] in-radius 5[
    create-relacioninterna-with one-of locales with [tipo = 4] in-radius 5 
    [ set color green
      set nodolink? "nodo5"
      set innovacion5 (innovacion5 + 1)
      set vidarelacioninterna 0
      ]
     hatch ((random 1) + 1) [
        set meses 0
        set tipo 4
        set breed economicos
        set shape "economico"
        ]
     ]
    ]
    ]
    ]
]
end 

to relacion2 ; La que describe un cultivo que autoproduce el ciudadano
    if any? patches with [agro? = 1][
    ask patches with [agro? = 1][
    if any? ciudadanos-i with [tipo = 0]  in-radius 5[
    ask one-of ciudadanos-i with [tipo = 0]  in-radius 5 [
    if any? other ciudadanos-i with [tipo = 0]  in-radius 5[
    create-relacioninterna-with one-of other ciudadanos-i with [tipo = 0]  in-radius 5 
    [ set color pink
      set nodolink? "nodo1"
      set innovacion1 (innovacion1 + 1)
      set vidarelacioninterna 0
      ]
     hatch ((random 1) + 1) [
        set meses 0
        set tipo 0
        set breed economicos
        set shape "economico"
        ]
     ]
    ]
    ]
    ]
    ]
    if any? patches with [agro? = 2][
    ask patches with [agro? = 2][
    if any? ciudadanos-i with [tipo = 1] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 1] in-radius 5 [
    if any? other ciudadanos-i with [tipo = 1] in-radius 5[
    create-relacioninterna-with one-of other ciudadanos-i with [tipo = 1] in-radius 5 
    [ set color pink
      set nodolink? "nodo2"
      set innovacion2 (innovacion2 + 1)
      set vidarelacioninterna 0
      ]
     hatch ((random 1) + 1) [
        set meses 0
        set tipo 1
        set breed economicos
        set shape "economico"
        ]
     ]
    ]
    ]
    ]
    ]
    if any? patches with [agro? = 3][
    ask patches with [agro? = 3][
    if any? ciudadanos-i with [tipo = 2] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 2] in-radius 5 [
    if any? other ciudadanos-i with [tipo = 2] in-radius 5[
    create-relacioninterna-with one-of other ciudadanos-i with [tipo = 2] in-radius 5 
    [ set color pink
      set nodolink? "nodo3"
      set innovacion3 (innovacion3 + 1)
      set vidarelacioninterna 0
      ]
     hatch ((random 1) + 1) [
        set meses 0
        set tipo 2
        set breed economicos
        set shape "economico"
        ]
     ]
    ]
    ]
    ]
    ]
    if any? patches with [agro? = 4][
    ask patches with [agro? = 4][
    if any? ciudadanos-i with [tipo = 3] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 3] in-radius 5 [
    if any? other ciudadanos-i with [tipo = 3] in-radius 5[
    create-relacioninterna-with one-of other ciudadanos-i with [tipo = 3] in-radius 5 
    [ set color pink
      set nodolink? "nodo4"
      set innovacion4 (innovacion4 + 1)
      set vidarelacioninterna 0
      ]
     hatch ((random 1) + 1) [
        set meses 0
        set tipo 3
        set breed economicos
        set shape "economico"
        ]
     ]
    ]
    ]
    ]
    ]
    if any? patches with [agro? = 5][
    ask patches with [agro? = 5][
    if any? ciudadanos-i with [tipo = 4] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 4] in-radius 5 [
    if any? other ciudadanos-i with [tipo = 4] in-radius 5[
    create-relacioninterna-with one-of other ciudadanos-i with [tipo = 4] in-radius 5 
    [ set color pink
      set nodolink? "nodo5"
      set innovacion5 (innovacion5 + 1)
      set vidarelacioninterna 0
      ]
     hatch ((random 1) + 1) [
        set meses 0
        set tipo 4
        set breed economicos
        set shape "economico"
        ]
     ]
    ]
    ]
    ]
    ]
end 

to relacion3
    if any? materiales with [tipo = 0][
    if any? patches with [taller? = 1][
    ask patches with [taller? = 1][
    if any? ciudadanos-i with [tipo = 0] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 0] in-radius 5 [
    if any? locales with [tipo = 0] in-radius 5[
    create-relacioninterna-with one-of locales with [tipo = 0] in-radius 5 
    [ set color brown
      set nodolink? "nodo1"
      set innovacion1 (innovacion1 + 1)
      set vidarelacioninterna 0
      ask one-of materiales with [tipo = 0][
      die]
      ]
    ask patch-here [set pcolor blue set vivienda? 1]
     ]
    ]
    ]
    ]
    ]
    ]
    
    if any? materiales with [tipo = 1][
    if any? patches with [taller? = 2][
    ask patches with [taller? = 2][
    if any? ciudadanos-i with [tipo = 1] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 1] in-radius 5 [
    if any? locales with [tipo = 1] in-radius 5[
    create-relacioninterna-with one-of locales with [tipo = 1] in-radius 5 
    [ set color brown
      set nodolink? "nodo2"
      set innovacion2 (innovacion2 + 1)
      set vidarelacioninterna 0
      ask one-of materiales with [tipo = 1][
      die]
      ]
    ask patch-here [set pcolor blue set vivienda? 2]
     ]
    ]
    ]
    ]
    ]
    ]

if any? materiales with [tipo = 2][
    if any? patches with [taller? = 3][
    ask patches with [taller? = 3][
    if any? ciudadanos-i with [tipo = 2] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 2] in-radius 5 [
    if any? locales with [tipo = 2] in-radius 5[
    create-relacioninterna-with one-of locales with [tipo = 2] in-radius 5 
    [ set color brown
      set nodolink? "nodo3"
      set innovacion3 (innovacion3 + 1)
      set vidarelacioninterna 0
      ask one-of materiales with [tipo = 2][
      die]
      ]
    ask patch-here [set pcolor blue set vivienda? 3]
     ]
    ]
    ]
    ]
    ]
    ]

if any? materiales with [tipo = 3][
    if any? patches with [taller? = 4][
    ask patches with [taller? = 4][
    if any? ciudadanos-i with [tipo = 3] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 3] in-radius 5 [
    if any? locales with [tipo = 3] in-radius 5[
    create-relacioninterna-with one-of locales with [tipo = 3] in-radius 5 
    [ set color brown
      set nodolink? "nodo4"
      set innovacion4 (innovacion4 + 1)
      set vidarelacioninterna 0
      ask one-of materiales with [tipo = 3][
      die]
      ]
    ask patch-here [set pcolor blue set vivienda? 4]
     ]
    ]
    ]
    ]
    ]
    ]

if any? materiales with [tipo = 4][
    if any? patches with [taller? = 5][
    ask patches with [taller? = 5][
    if any? ciudadanos-i with [tipo = 4] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 4]in-radius 5 [
    if any? locales with [tipo = 4] in-radius 5[
    create-relacioninterna-with one-of locales with [tipo = 4] in-radius 5 
    [ set color brown
      set nodolink? "nodo5"
      set innovacion5 (innovacion5 + 1)
      set vidarelacioninterna 0
      ask one-of materiales with [tipo = 4][
      die]
      ]
    ask patch-here [set pcolor blue set vivienda? 5]
     ]
    ]
    ]
    ]
    ]
    ]
end 

to relacion4
    if any? materiales with [tipo = 0][
    if any? patches with [taller? = 1][
    ask patches with [taller? = 1][
    if any? ciudadanos-i with [tipo = 0] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 0] in-radius 5 [
    if any? other ciudadanos-i with [tipo = 0] in-radius 5[
    create-relacioninterna-with one-of other ciudadanos-i with [tipo = 0] in-radius 5 
    [ set color blue
      set nodolink? "nodo1"
      set innovacion1 (innovacion1 + 1)
      set vidarelacioninterna 0
      ask one-of materiales with [tipo = 0][
      die]
      ]
    ask patch-here [set pcolor blue set vivienda? 1]
       ]
     ]
    ]
    ]
    ]
    ]
    
    if any? materiales with [tipo = 1][
    if any? patches with [taller? = 2][
    ask patches with [taller? = 2][
    if any? ciudadanos-i with [tipo = 1] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 1] in-radius 5 [
    if any? other ciudadanos-i with [tipo = 1] in-radius 5[
    create-relacioninterna-with one-of other ciudadanos-i with [tipo = 1] in-radius 5 
    [ set color blue
      set nodolink? "nodo2"
      set innovacion2 (innovacion2 + 1)
      set vidarelacioninterna 0
      ask one-of materiales with [tipo = 1][
      die]
      ]
    ask patch-here [set pcolor blue set vivienda? 2]
       ]
     ]
    ]
    ]
    ]
    ]
    
    if any? materiales with [tipo = 2][
    if any? patches with [taller? = 3][
    ask patches with [taller? = 3][
    if any? ciudadanos-i with [tipo = 2] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 2] in-radius 5 [
    if any? other ciudadanos-i with [tipo = 2] in-radius 5[
    create-relacioninterna-with one-of other ciudadanos-i with [tipo = 2] in-radius 5 
    [ set color blue
      set nodolink? "nodo3"
      set innovacion3 (innovacion3 + 1)
      set vidarelacioninterna 0
      ask one-of materiales with [tipo = 2][
      die]
      ]
    ask patch-here [set pcolor blue set vivienda? 3]
       ]
     ]
    ]
    ]
    ]
    ]
    
    if any? materiales with [tipo = 3][
    if any? patches with [taller? = 4][
    ask patches with [taller? = 4][
    if any? ciudadanos-i with [tipo = 3] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 3] in-radius 5 [
    if any? other ciudadanos-i with [tipo = 3] in-radius 5[
    create-relacioninterna-with one-of other ciudadanos-i with [tipo = 3] in-radius 5 
    [ set color blue
      set nodolink? "nodo4"
      set innovacion4 (innovacion4 + 1)
      set vidarelacioninterna 0
      ask one-of materiales with [tipo = 3][
      die]
      ]
    ask patch-here [set pcolor blue set vivienda? 4]
       ]
     ]
    ]
    ]
    ]
    ]
    
    if any? materiales with [tipo = 4][
    if any? patches with [taller? = 5][
    ask patches with [taller? = 5][
    if any? ciudadanos-i with [tipo = 4] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 4] in-radius 5 [
    if any? other ciudadanos-i with [tipo = 4] in-radius 5[
    create-relacioninterna-with one-of other ciudadanos-i with [tipo = 4] in-radius 5 
    [ set color blue
      set nodolink? "nodo5"
      set innovacion5 (innovacion5 + 1)
      set vidarelacioninterna 0
      ask one-of materiales with [tipo = 4][
      die]
      ]
    ask patch-here [set pcolor blue set vivienda? 5]
       ]
     ]
    ]
    ]
    ]
    ]
end 

to relacion5
    if any? economicos with [tipo = 0][
    if any? patches with [laboratorio? = 1][
    ask patches with [laboratorio? = 1][
    if any? ciudadanos-i with [tipo = 0] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 0] in-radius 5 [
    if any? expertos with [tipo = 0] in-radius 5[
    create-relacioninterna-with one-of expertos with [tipo = 0] in-radius 5 
    [ set color red
      set nodolink? "nodo1"
      set innovacion1 (innovacion1 + 1)
      set vidarelacioninterna 0
      ask one-of economicos with [tipo = 0][
    die]
      ]
     hatch 1 [
        set meses 0
        set tipo 0
        set breed aplicaciones
        set shape "aplicacion"
        ]
      hatch 1 [
        set meses 0
        set tipo 0
        set breed hardwares
        set shape "hardware"
        ]
      hatch random 3 [
        set meses 0
        set tipo 0
        set breed economicos
        set shape "economico"
        ]

     ]
    ]
    ]
    ]
    ]
    ]
    
    if any? economicos with [tipo = 1][
    if any? patches with [laboratorio? = 2][
    ask patches with [laboratorio? = 2][
    if any? ciudadanos-i with [tipo = 1]  in-radius 5[
    ask one-of ciudadanos-i with [tipo = 1] in-radius 5 [
    if any? expertos with [tipo = 1] in-radius 5[
    create-relacioninterna-with one-of expertos with [tipo = 1] in-radius 5 
    [ set color red
      set nodolink? "nodo2"
      set innovacion2 (innovacion2 + 1)
      set vidarelacioninterna 0
      ask one-of economicos with [tipo = 1][
    die]
      ]
     hatch 1 [
        set meses 0
        set tipo 1
        set breed aplicaciones
        set shape "aplicacion"
        ]
      hatch 1 [
        set meses 0
        set tipo 1
        set breed hardwares
        set shape "hardware"
        ]
      hatch random 3 [
        set meses 0
        set tipo 1
        set breed economicos
        set shape "economico"
        ]

     ]
    ]
    ]
    ]
    ]
    ]
    
    if any? economicos with [tipo = 2][
    if any? patches with [laboratorio? = 3][
    ask patches with [laboratorio? = 3][
    if any? ciudadanos-i with [tipo = 2] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 2] in-radius 5 [
    if any? expertos with [tipo = 2] in-radius 5[
    create-relacioninterna-with one-of expertos with [tipo = 2] in-radius 5 
    [ set color red
      set nodolink? "nodo3"
      set innovacion3 (innovacion3 + 1)
      set vidarelacioninterna 0
      ask one-of economicos with [tipo = 2][
    die]
      ]
     hatch 1 [
        set meses 0
        set tipo 2
        set breed aplicaciones
        set shape "aplicacion"
        ]
      hatch 1 [
        set meses 0
        set tipo 2
        set breed hardwares
        set shape "hardware"
        ]
      hatch random 3 [
        set meses 0
        set tipo 2
        set breed economicos
        set shape "economico"
        ]

     ]
    ]
    ]
    ]
    ]
    ]
    
    if any? economicos with [tipo = 3][
    if any? patches with [laboratorio? = 4][
    ask patches with [laboratorio? = 4][
    if any? ciudadanos-i with [tipo = 3] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 3] in-radius 5 [
    if any? expertos with [tipo = 3] in-radius 5[
    create-relacioninterna-with one-of expertos with [tipo = 3] in-radius 5 
    [ set color red
      set nodolink? "nodo4"
      set innovacion4 (innovacion4 + 1)
      set vidarelacioninterna 0
      ask one-of economicos with [tipo = 3][
    die]
      ]
     hatch 1 [
        set meses 0
        set tipo 3
        set breed aplicaciones
        set shape "aplicacion"
        ]
      hatch 1 [
        set meses 0
        set tipo 3
        set breed hardwares
        set shape "hardware"
        ]
      hatch random 3 [
        set meses 0
        set tipo 3
        set breed economicos
        set shape "economico"
        ]

     ]
    ]
    ]
    ]
    ]
    ]
    
    if any? economicos with [tipo = 4][
    if any? patches with [laboratorio? = 5][
    ask patches with [laboratorio? = 5][
    if any? ciudadanos-i with [tipo = 4] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 4] in-radius 5 [
    if any? expertos with [tipo = 4] in-radius 5[
    create-relacioninterna-with one-of expertos with [tipo = 4] in-radius 5 
    [ set color red
      set nodolink? "nodo5"
      set innovacion5 (innovacion5 + 1)
      set vidarelacioninterna 0
      ask one-of economicos with [tipo = 4][
    die]
      ]
     hatch 1 [
        set meses 0
        set tipo 4
        set breed aplicaciones
        set shape "aplicacion"
        ]
      hatch 1 [
        set meses 0
        set tipo 4
        set breed hardwares
        set shape "hardware"
        ]
      hatch random 3 [
        set meses 0
        set tipo 4
        set breed economicos
        set shape "economico"
        ]

     ]
    ]
    ]
    ]
    ]
    ]
end 

to relacion6
    if any? economicos with [tipo = 0][
    if any? patches with [escenico? = 1][
    ask patches with [escenico? = 1][
    if any? ciudadanos-i with [tipo = 0] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 0] in-radius 5 [
    if any? expertos with [tipo = 0] in-radius 5[
    create-relacioninterna-with one-of expertos with [tipo = 0] in-radius 5 
    [ set color turquoise
      set nodolink? "nodo1"
      set innovacion1 (innovacion1 + 1)
      set vidarelacioninterna 0
      ask one-of economicos with [tipo = 0][
    die]
      ]
     hatch random 2 [
        set meses 0
        set tipo 0
        set breed economicos
        set shape "economico"
        ]
     hatch 1 [
        set meses 0
        set tipo 0
        set breed visitantes
        set shape "visitante"
        ]
     ]
    ]
    ]
    ]
    ]
    ]
    
    if any? economicos with [tipo = 1][
    if any? patches with [escenico? = 2][
    ask patches with [escenico? = 2][
    if any? ciudadanos-i with [tipo = 1] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 1] in-radius 5 [
    if any? expertos with [tipo = 1] in-radius 5[
    create-relacioninterna-with one-of expertos with [tipo = 1] in-radius 5 
    [ set color turquoise
      set nodolink? "nodo2"
      set innovacion2 (innovacion2 + 1)
      set vidarelacioninterna 0
      ask one-of economicos with [tipo = 1][
    die]
      ]
     hatch random 2 [
        set meses 0
        set tipo 1
        set breed economicos
        set shape "economico"
        ]
     hatch 1 [
        set meses 0
        set tipo 1
        set breed visitantes
        set shape "visitante"
        ]
     ]
    ]
    ]
    ]
]
    ]
    
    if any? economicos with [tipo = 2][
    if any? patches with [escenico? = 3][
    ask patches with [escenico? = 3][
    if any? ciudadanos-i with [tipo = 2] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 2] in-radius 5 [
    if any? expertos with [tipo = 2] in-radius 5[
    create-relacioninterna-with one-of expertos with [tipo = 2] in-radius 5 
    [ set color turquoise
      set nodolink? "nodo3"
      set innovacion3 (innovacion3 + 1)
      set vidarelacioninterna 0
      ask one-of economicos with [tipo = 2][
    die]
      ]
     hatch random 2 [
        set meses 0
        set tipo 2
        set breed economicos
        set shape "economico"
        ]
     hatch 1 [
        set meses 0
        set tipo 2
        set breed visitantes
        set shape "visitante"
        ]
     ]
    ]
    ]
    ]
]
    ]
    
    if any? economicos with [tipo = 3][
    if any? patches with [escenico? = 4][
    ask patches with [escenico? = 4][
    if any? ciudadanos-i with [tipo = 3] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 3] in-radius 5 [
    if any? expertos with [tipo = 3] in-radius 5[
    create-relacioninterna-with one-of expertos with [tipo = 3] in-radius 5 
    [ set color turquoise
      set nodolink? "nodo4"
      set innovacion4 (innovacion4 + 1)
      set vidarelacioninterna 0
      ask one-of economicos with [tipo = 3][
    die]
      ]
     hatch random 2 [
        set meses 0
        set tipo 3
        set breed economicos
        set shape "economico"
        ]
     hatch 1 [
        set meses 0
        set tipo 3
        set breed visitantes
        set shape "visitante"
        ]
     ]
    ]
    ]
    ]
]
    ]
    
    if any? economicos with [tipo = 4][
    if any? patches with [escenico? = 5][
    ask patches with [escenico? = 5][
    if any? ciudadanos-i with [tipo = 4] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 4] in-radius 5 [
    if any? expertos with [tipo = 4] in-radius 5[
    create-relacioninterna-with one-of expertos with [tipo = 4] in-radius 5 
    [ set color turquoise
      set nodolink? "nodo5"
      set innovacion5 (innovacion5 + 1)
      set vidarelacioninterna 0
      ask one-of economicos with [tipo = 4][
    die]
      ]
     hatch random 2 [
        set meses 0
        set tipo 4
        set breed economicos
        set shape "economico"
        ]
     hatch 1 [
        set meses 0
        set tipo 4
        set breed visitantes
        set shape "visitante"
        ]
     ]
    ]
    ]
    ]
]
    ]
end 

to relacion7
    if any? economicos with [tipo = 0][
    if any? patches with [cultural? = 1][
    ask patches with [cultural? = 1][
    if any? ciudadanos-i with [tipo = 0] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 0] in-radius 5 [
    if any? expertos with [tipo = 0] in-radius 5[
    create-relacioninterna-with one-of expertos with [tipo = 0] in-radius 5 
    [ set color lime
      set nodolink? "nodo1"
      set innovacion1 (innovacion1 + 1)
      set vidarelacioninterna 0
      ask one-of economicos with [tipo = 0][
    die]
      ]
    hatch random 2 [
        set meses 0
        set tipo 0
        set breed economicos
        set shape "economico"
        ]
     hatch 1 [
        set meses 0
        set tipo 0
        set breed objetosculturales
        set shape "objetocultural"
        ]
     ]
    ]
    ]
    ]
    ]
    ]
    
    if any? economicos with [tipo = 1][
    if any? patches with [cultural? = 2][
    ask patches with [cultural? = 2][
    if any? ciudadanos-i with [tipo = 1] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 1] in-radius 5 [
    if any? expertos with [tipo = 1] in-radius 5[
    create-relacioninterna-with one-of expertos with [tipo = 1] in-radius 5 
    [ set color lime
      set nodolink? "nodo2"
      set innovacion2 (innovacion2 + 1)
      set vidarelacioninterna 0
      ask one-of economicos with [tipo = 1][
    die]
      ]
    hatch random 2 [
        set meses 0
        set tipo 1
        set breed economicos
        set shape "economico"
        ]
     hatch 1 [
        set meses 0
        set tipo 1
        set breed objetosculturales
        set shape "objetocultural"
        ]
     ]
    ]
    ]
    ]
    ]
    ]
    
    if any? economicos with [tipo = 2][
    if any? patches with [cultural? = 3][
    ask patches with [cultural? = 3][
    if any? ciudadanos-i with [tipo = 2] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 2] in-radius 5 [
    if any? expertos with [tipo = 2] in-radius 5[
    create-relacioninterna-with one-of expertos with [tipo = 2] in-radius 5 
    [ set color lime
      set nodolink? "nodo3"
      set innovacion3 (innovacion3 + 1)
      set vidarelacioninterna 0
      ask one-of economicos with [tipo = 2][
    die]
      ]
    hatch random 2 [
        set meses 0
        set tipo 2
        set breed economicos
        set shape "economico"
        ]
     hatch 1 [
        set meses 0
        set tipo 2
        set breed objetosculturales
        set shape "objetocultural"
        ]
     ]
    ]
    ]
    ]
    ]
    ]
    
    if any? economicos with [tipo = 3][
    if any? patches with [cultural? = 4][
    ask patches with [cultural? = 4][
    if any? ciudadanos-i with [tipo = 3] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 3] in-radius 5 [
    if any? expertos with [tipo = 3] in-radius 5[
    create-relacioninterna-with one-of expertos with [tipo = 3] in-radius 5 
    [ set color lime
      set nodolink? "nodo4"
      set innovacion4 (innovacion4 + 1)
      set vidarelacioninterna 0
      ask one-of economicos with [tipo = 3][
    die]
      ]
    hatch random 2 [
        set meses 0
        set tipo 3
        set breed economicos
        set shape "economico"
        ]
     hatch 1 [
        set meses 0
        set tipo 3
        set breed objetosculturales
        set shape "objetocultural"
        ]
     ]
    ]
    ]
    ]
    ]
    ]
    
    if any? economicos with [tipo = 4][
    if any? patches with [cultural? = 5][
    ask patches with [cultural? = 5][
    if any? ciudadanos-i with [tipo = 4] in-radius 5[
    ask one-of ciudadanos-i with [tipo = 4] in-radius 5 [
    if any? expertos with [tipo = 4] in-radius 5[
    create-relacioninterna-with one-of expertos with [tipo = 4] in-radius 5 
    [ set color lime
      set nodolink? "nodo5"
      set innovacion5 (innovacion5 + 1)
      set vidarelacioninterna 0
      ask one-of economicos with [tipo = 4][
    die]
      ]
    hatch random 2 [
        set meses 0
        set tipo 4
        set breed economicos
        set shape "economico"
        ]
     hatch 1 [
        set meses 0
        set tipo 4
        set breed objetosculturales
        set shape "objetocultural"
        ]
     ]
    ]
    ]
    ]
    ]
    ]
end 

There are 3 versions of this model.

Uploaded by When Description Download
Alberto de Austria Millán almost 9 years ago Última actualización Download this version
Alberto de Austria Millán almost 9 years ago Tablas actualizadas Download this version
Alberto de Austria Millán almost 9 years ago Initial upload Download this version

Attached files

File Type Description Last updated
alg-Aldea Lúdica.png preview Preview for 'alg-Aldea Lúdica' almost 9 years ago, by Alberto de Austria Millán Download
montaje2.jpg background Archivo para color patches almost 9 years ago, by Alberto de Austria Millán Download

This model does not have any ancestors.

This model does not have any descendants.