Crowding Out

Crowding Out preview image

This model is seeking new collaborators — would you please help?

1 collaborator

Default-person Jorge Martínez (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.2 • Viewed 461 times • Downloaded 20 times • Run 0 times
Download the 'Crowding Out' 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

undirected-link-breed [partners partner]
undirected-link-breed [assocs assoc]
undirected-link-breed [friendships friendship]
undirected-link-breed [participations participation]

turtles-own [
  n-t-activity
]

breed [activities activity]
activities-own [
  max-d-activity
  d-activity
  time-alive
  ticks-to-die
  culture
  shared-culture
  n-capacity
]

breed [associations association]
associations-own [
  culture
  shared-culture
  n-capacity
]

breed [agentes agente]
agentes-own [
  gender
  time
  culture
  shared-culture
  max-friends
]

;;;;;;;;;;
;;SETUP
;;;;;;;;;;

to setup
  clear-all
  setup-world
  setup-people-quotes
  setup-activities
  reset-ticks
END

to setup-world
  ask patches [set pcolor white]
END

to setup-people-quotes
  ;;prob-female is the percentage of initial-people female
  let quote (prob-female / 100 * initial-people)
  create-agentes initial-people [
    while [any? other turtles-here ] [
      setxy random-xcor random-ycor ]
    set gender "male" set color black
  ]
  ask n-of quote agentes [
    set gender "female" set color blue
  ]
  ask agentes [
    ;;max limit of friends
    set max-friends random-in-range 0 12
    set culture n-values 11 [random 2]
    set shared-culture (filter [ i -> i = 0 ] culture)
    set time random-in-range 2 6
  ]
END

to setup-activities
  create-activities num-activity [
    while [any? other turtles-here] [
      setxy random-xcor random-ycor]
    set shape "box"
    set size 2
    set n-capacity random-in-range 10 25
    set max-d-activity random-in-range 200 500
    set d-activity 0
    set time-alive 0
    set ticks-to-die random-in-range 500 1000
    ask activities [
      set culture n-values 11 [random 2]
      set shared-culture (filter [i -> i = 0] culture)
    ]
  ]
END

;;;;;;;;;;
;;GO
;;;;;;;;;;

to go
  give-color
  move-agentes
  make-friends
  share-culture
  participate-activities
  reproduce-associations
  associate
  decay-activities
  resize-activities
  finish-activities
  tick
;  export-view (word ticks ".png")
end 

to give-color
  ask turtles [
    assign-n-t-activity
  ]
end 

to move-agentes
  ask agentes [
    if time >= 2 [
      rt random 40
      lt random 40
      fd distance-to-walk
    ]
    ;;when they have friends "flock" to them?
  ]
end 

to make-friends
  ;;configure the agentset (number) of friends an agent CAN have (besides the max-friends)
  ;;configure the agents that CAN be friends
  ;;the chosen agents to be friends will be the min number of this list of the possible-friends agentset?
  ;;the friendship will be created with those chosen
  ask agentes [
    let new-friends max-friends - count my-friendships
    let possible-friends other agentes with [color = [color] of myself] in-radius sight-radius ;;during x ticks?
    if new-friends > 0 [
      let chosen n-of min (list new-friends count other possible-friends) other possible-friends
      create-friendships-with chosen in-radius sight-radius [hide-link]
    ]
  ]
end 

to share-culture
  ask agentes [
    if sharing-culture = true [
      if any? friendship-neighbors [
        let friend one-of other friendship-neighbors
        let i random length culture
        let my-tag item i culture
        let friend-tag [ item i culture ] of friend
        if my-tag != friend-tag [
          set culture replace-item i culture friend-tag
          set shared-culture (filter [v -> v = 0] culture)
        ]
      ]
    ]
  ]
end 

to participate-activities
  ;;if the activities have less links than capacity to hold agents
  ;;the candidates to participate will be agents with
  ;;the same culture of myself in my radius and not being already a participant
  ;;those to link will be the minimum of those who aren't linked?
  ask activities [
    if count my-links < n-capacity [
      let candidates agentes with [
        color = [color] of myself and not participation-neighbor? myself ] in-radius sight-radius
      let n-to-link min (list (n-capacity - count my-links) (count candidates ) ) ;;aquellos que pueden enlazar son el número de candidatos de la resta de la capacidad máxima y el número de enlaces
      ask n-of n-to-link candidates [
        if (time >= 2) [
          create-participation-with myself  ;[hide-link]
          set color [color] of myself
          set time time - count my-participations
        ]
      ]
    ]
  ]
end 

to reproduce-associations ;;tie?
  ;;if hatching-activities is true
  ;;there aren't assocs around
  ;;and they have more friends than the neccesary friends to associate
  ;;and they have more than x time
  ;;create association with x specs
  ask agentes [
    if (hatching-assocs = true) and
    (not any? associations in-radius sight-radius) and
    (not any? assoc-neighbors) and
    (not any? partner-neighbors) and
    (count my-friendships >= n-friends-to-association) and
    (time >= 4) [
      hatch-associations 1 [create-partner-with myself [ tie ] ]
      set time time - 3
      ask associations [
        set shape "flag"
        set size 3
        set n-capacity random-in-range 10 30
        set label count assoc-neighbors
        set label-color black
      ]
    ]
  ]
end 

to associate
  ask associations [
    if count assoc-neighbors <= n-capacity [
      let candidates agentes with [
        color = [color] of myself and not assoc-neighbor? myself ] in-radius sight-radius
      let n-to-link min (list (n-capacity - count my-assocs) (count candidates))
      ask n-of n-to-link candidates [
        if time > 2 [
          create-assoc-with myself ;[hide-link]
          set time time - count my-assocs
          ]
        ]
      ]
    ]
;  ]
end 

to decay-activities
  ;; each tick sums 1 to d-activity (duration of activity)
  ;;if decaying-activities is true
  ;;and d-activity is equal or bigger than its max-d-activity (random)
  ;;and they have 1/4 of its capacity to  make participations
  ;;the activities die
  ask activities [
    set d-activity (d-activity + 1)
    if (decaying-activities = true) and
    (d-activity >= max-d-activity) and
    (count participation-neighbors <= n-capacity / 4) [
      ask participation-neighbors [
        set time time + 1
      ]
      die
    ]
  ]
end 

to resize-activities  ;;this signals the ones that are "active"
  ask activities [
    if (decaying-activities = true) and
    (d-activity >= max-d-activity) and
    (count participation-neighbors >= n-capacity / 4) [
      set size 3
      set label count participation-neighbors
      set label-color black
    ]
  ]
end 

to finish-activities
  ;;if there are active activities
  ;;make them die after x ticks
  ;;and give time to their participants
  ask activities [
    if (activities-die = true) and
    size = 3 [
      set time-alive (time-alive + 1)
      if time-alive > ticks-to-die [
        ask participation-neighbors [
          set time time + 1]
        die
      ]
    ]
  ]
end 

;;;;;;;;;;
;;UTILITIES
;;;;;;;;;;

to dissapear
  dissapear-activities
end 

to dissapear-associations
  dissapear-assocs
end 

to dissapear-assocs
  ask associations [
    ask partner-neighbors [
      set time time + 3
    ]
    ask assoc-neighbors [
      set time time + 1
    ]
    die]
end 

to dissapear-activities
  ask activities [
    die]
end 

to assign-n-t-activity
    if length shared-culture <= 4 [
      set n-t-activity ["red"]
      set color red
    ]
    if length shared-culture = 5 [
      set n-t-activity ["green"]
      set color green
    ]
    if length shared-culture = 6 [
      set n-t-activity ["green"]
      set color green
    ]
    if length shared-culture >= 7 [
      set n-t-activity ["black"]
      set color black
    ]
END

to-report random-in-range [low high]
  report low + random (high - low + 1)
END

There is only one version of this model, created over 6 years ago by Jorge Martínez.

Attached files

File Type Description Last updated
Crowding Out.png preview Preview for 'Crowding Out' over 6 years ago, by Jorge Martínez Download

This model does not have any ancestors.

This model does not have any descendants.