Final_Project_Addiction

No preview image

1 collaborator

Tags

(This model has yet to be categorized with any tags)
Parent of 1 model: Metric_update
Model group MAM-2016 | Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0-M5 • Viewed 285 times • Downloaded 22 times • Run 0 times
Download the 'Final_Project_Addiction' 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

extensions [nw]

breed [people person]
breed [dealers dealer]

undirected-link-breed [ friendships friendship ]
undirected-link-breed [ customers customer ]

globals [answer drugs-done-total times-eaten-total work-done-total make-friends-total first-time]
people-own [money dopamine-level times-done times-eaten times-worked times-friend days-since-drug num-friends risk-behavior last-action]
links-own [weight]

;; called upon setup

to setup
  ca
  reset-ticks
  set drugs-done-total 0 ;; total amount of times the population decided to do drugs
  set times-eaten-total 0 ;; total amount of times the population decided to eat
  set work-done-total 0 ;; total amount of times the population decided to do work
  set make-friends-total 0 ;; total amount of times the population decided to make a new friend
  create-network ;; creates the social network
  set first-time true
end 

;;uses preferential attachment to create a social network amongst the turtles

to create-network
   nw:generate-preferential-attachment turtles friendships num-people [
     ifelse illegal-world? [
       ifelse random 100 > 5 [make-normal-person] [make-dealer]] ;; 5 dealers for every 100 people
     [make-normal-person] ;; no dealers in this world
     setxy random-xcor random-ycor
     set shape "person"
   ]
end 

;; function to create a dealer turtle

to make-dealer
  set breed dealers
  set color white
  let goahead true
  ask link-neighbors [
    if customer-neighbor? myself [set goahead false]]
  if goahead [ask my-links [ set color green set breed customers set thickness .3 ]]
end 

;; function to create a normal person

to make-normal-person
  set breed people
  set color sky
  set money random 100 ;; they all start with a random amount of money
  set dopamine-level random 100 ;; they all start with a random amount of happiness
  set times-done 0 ;; no one has tried drugs before
  set risk-behavior random 100 ;; the personality is all random, some people are more risk prone
  set days-since-drug 0
  set times-worked 0 ;; they all have never worked before
  set times-eaten 0 ;; they all have never eaten before
  set times-friend 0 ;; they all have never made a friend before
  set last-action nobody ;; they have never done any action before
  ask my-links [
    ifelse [breed] of other-end = dealers [set color green] ;; to differentiate between dealer links and friendship
      [set weight (random 5) + 1 ;; will be numbers 1 - 5, 1 being the lowest form of friendship, 5 being best friends
        set color 14.9 + weight ;; a visual representation of the friendships, the more red they are the less strong
      ]
    set thickness .3
  ]
end 

to go
  ask people [
    let action utility ;; function that picks the option that provides the most utility
    show action
    if action = "work" [work set work-done-total work-done-total + 1]
    if action = "drugs" [do-drugs set drugs-done-total drugs-done-total + 1]
    if action = "eat" [eat set times-eaten-total times-eaten-total + 1]
    if action = "make friend" [make-new-friend set make-friends-total make-friends-total + 1]
    if action != "make friend" [set last-action action]
    if first-time = false [friendships-link-change]
  ]
  if first-time = true [set first-time false]
  show "end of tick"
  tick
end 

;; function that calculates which action will give the person the most utility and returns the answer

to-report utility
  let t_work work-change
  let t_drug drug-change
  let t_eat eat-change
  let t_friend make-new-friend-change
  if t_work > t_drug and t_work > t_eat and t_work > t_friend [ set answer "work" ] ;; work gives the most utility
  if t_drug > t_work and t_drug > t_eat and t_drug > t_friend [ set answer "drugs" ] ;; drugs gives the most utility
  if t_eat > t_drug and t_eat > t_work and t_eat > t_friend [ set answer "eat" ] ;; eating gives the most utility
  if t_friend > t_drug and t_friend > t_eat and t_friend > t_work [set answer "make friend" ] ;; making a new friend gives the most utility
  report answer
end 

;; function that calculates how much utility a person will get from working

to-report work-change
  let temp-dopamine dopamine-level - energy-of-job ;; your job takes away a certain amount of energy/happiness
  let temp-money money + energy-of-job ;; you get money depending on how much energy your job takes
  report temp-dopamine + temp-money ;; return the decreased dopamine and the increased money added together
end 

;; function to actually cause the person to work and gain/lose the benefits

to work
  set dopamine-level dopamine-level - energy-of-job
  set money money + energy-of-job
  set days-since-drug days-since-drug + 1
  set times-worked times-worked + 1
end 

;; function that calculates how much utility a person will get from eating

to-report eat-change
  let temp-dopamine dopamine-level + energy-from-food ;; eating gives you energy
  let temp-money money - cost-of-food ;; eating takes away money
  ;; if eating does not put you into debt, report the change, if it does return 0
  ifelse temp-money > 0 [report temp-dopamine + temp-money] [report 0]
end 

;; function to actually cause the person to eat and gain/lose the benefits

to eat
  set dopamine-level dopamine-level + energy-from-food
  set money money - cost-of-food
  set days-since-drug days-since-drug + 1
  set times-eaten times-eaten + 1
end 

;; function that calculates how much utility a person will get from doing drugs

to-report drug-change
  let ease ease-of-finding
  if ease = 0 [report 0] ;; if the person is not close enough to drugs, he/she will not do it
  let temp-times-done 0
  ;; rehab mechanism, if a person abstains enough then his/her tolerance will decrease
  ifelse days-since-drug > 20 [set temp-times-done 1][set temp-times-done times-done + 1]
  let temp-dopamine dopamine-level + drug-potency ;; the more potent the drug, the more it will increase happiness
  let tolerance 1
  let amount 100 - drug-potency
  ;; the more potent the drug the quicker your tolerance builds, the less potent the more time it takes to build
  if temp-times-done > amount [set tolerance tolerance + 1]
  if temp-times-done > amount * 2 [set tolerance tolerance + 2]
  if temp-times-done > amount * 4 [set tolerance tolerance + 3]
  let temp-money money - (cost-of-drug * tolerance) ;; the drug will get more expensive the more you do it because you build a tolerance
  let total temp-dopamine + temp-money + ease-of-finding
  ifelse random 100 < risk-behavior [ ;; uses probability to calculate whether a person will do the drug
    ifelse temp-money > 0 [report total] ; could afford to do the drug
    [ifelse temp-times-done > amount [report total] ;; the person can't afford it but will do it anyway
      [report 0 ]]] ;; can't afford it and aren't addicted enough to do it anyway
  [report 0]
end 

;; function to show how easy it is currently to find drugs
;; different for if it they are legal or illegal

to-report ease-of-finding
  let ease 0
  ifelse illegal-world? [
    ;; a turtle will calculate if they have a connection with a dealer either through
    ;; a direct connection or a friend
    if any? (nw:turtles-in-radius 1) with [breed = dealers and who != [who] of myself ] [set ease 30] ;; the person is connected to the dealer
    if any? (nw:turtles-in-radius 2) with [breed = dealers and who != [who] of myself] [set ease 20] ;; the person is two links away from the dealer
    if any? (nw:turtles-in-radius 3) with [breed = dealers and who != [who] of myself] [set ease 10] ;; the person is three links away from the dealer
  ]
  [
    ;; a turtle will calculate if it has any friends that it could do a drug with
    let amount 100 - drug-potency
    ifelse times-done <= amount [ ;; they are not addicted yet and still need friends to purchase the drug
      if my-links != nobody [
        ask my-links [
          let friend other-end
          ;; find friends and see if they will purchase a drug with you
          ask friend [
            if money > cost-of-drug [ ;; the friend can afford it
              if random 100 < risk-behavior [set ease 20]]]]]] ;; the friend is adventureous enough
    [ set ease 30 ]
  ]
  report ease
end 

;; function to actually cause the person to do drugs and gain/lose the benefits

to do-drugs
  ifelse days-since-drug > 20 [ set times-done 1 ] [ set times-done times-done + 1 ]
  let tolerance 1
  let amount 100 - drug-potency
  if times-done > amount [set tolerance tolerance + 1]
  if times-done > amount * 2 [set tolerance tolerance + 2]
  if times-done > amount * 3 [set tolerance tolerance + 3]
  set money money - (cost-of-drug * tolerance)
  set dopamine-level dopamine-level + drug-potency
  set days-since-drug 0
  set times-done times-done + 1
end 

;; function that calculates how much utility a person will get from making a new friend

to-report make-new-friend-change
  ;; current turtle has no friends, making a new friend will increase it's dopamine
  ;; by a lot and they are not picky about the new friends they make
  ifelse any? friendship-neighbors = false [
    if any? people in-radius 5 with [who != [who] of myself] != false [report dopamine-level + 100]
  ]
  [
    if any? people in-radius 5 with [who != [who] of myself] != false [
      let possible-friends people in-radius 5 with [who != [who] of myself]
      let temp-d 0
      let linkthere? false
      ask possible-friends [ ;; grab one of the turtles near the asking turtle
        ask my-links [
          ;; if there is already a link from this possible friend to the original turtle
          if [who] of other-end = [who] of myself [set linkthere? true]]
        ;; found a turtle that is not already connected to original turtle
        if linkthere? = false [
          ;; this turtle did the same last-action as the original turtle
          if last-action = [last-action] of myself [set temp-d dopamine-level + 50 stop]] ;; found a turtle that has the same last action
      ]
      report temp-d
    ]
  ]
  report 0
end 

;; function to actually cause the person to make a new friend and gain/lose the benefits

to make-new-friend
  ifelse any? friendship-neighbors = false [
    if any? people in-radius 5 with [who != [who] of myself] != false [
      ask one-of people in-radius 5 with [who != [who] of myself] [
        create-friendship-with person [who] of myself [set weight 1 set color 15.9 set thickness .3]]
    ]
    set dopamine-level dopamine-level + 100
  ]
  [
    if any? people in-radius 5 with [who != [who] of myself] != false [
      let possible-friends people in-radius 5 with [who != [who] of myself]
      let linkthere? false
      ask possible-friends [
        ask my-links [
          if [who] of other-end = [who] of myself [set linkthere? true]]
        if linkthere? = false [
          if last-action = [last-action] of myself [
            create-friendship-with person [who] of myself [set weight 1 set color 15.9 set thickness .3 stop ]
          ]
        ]
      ]
      set dopamine-level dopamine-level + 50
    ]
  ]
  set days-since-drug days-since-drug + 1
  set times-friend times-friend + 1
end 

;; function to update the social network depending on what the last actions of the turtles are

to friendships-link-change
  ;; grab friend group of turtle
  let friends (nw:turtles-in-radius 1) with [breed = people and who != [who] of myself]
  if friends != nobody [
    ask friends [ ifelse last-action = [last-action] of myself [
      ;; if the current friend did the same last activity as you, increase your friendship
      ask friendship-with turtle ([who] of myself) [ if weight + 1 <= 5 [set weight weight + 1 set color color + 1 ] ] ]
    [ask friendship-with turtle ([who] of myself) [ if weight - 1 >= 0 [set weight weight - 1  set color color - 1] ] ]
    friendship-loss
    ]
  ]
end 

to friendship-loss
  let relation friendship-with turtle [who] of myself ;; grab the link between the current turtle and the current friend
  if [weight] of relation = 0 [
    ;; if the friendship has a weight of less than 0, the friendship is not strong and will end
    ask relation [die]
  ]
end 



There are 3 versions of this model.

Uploaded by When Description Download
Isabella Valdescruz over 8 years ago Final Project implementation Download this version
Isabella Valdescruz over 8 years ago This implemented the two different worlds as well as a more complex buying drug implementation Download this version
Isabella Valdescruz over 8 years ago Initial upload Download this version

Attached files

File Type Description Last updated
372FinalReport.docx word Final Project Report over 8 years ago, by Isabella Valdescruz Download
IsabellaValdescruz_May16.docx word IsabellaValdescruz_May16th over 8 years ago, by Isabella Valdescruz Download
IsabellaValdescruz_May23.docx word IsabellaValdescruz_May23 over 8 years ago, by Isabella Valdescruz Download
IsabellaValdescruz_May9th.docx word IsabellaValdescruz_May9th over 8 years ago, by Isabella Valdescruz Download

This model does not have any ancestors.

Children:

Graph of models related to 'Final_Project_Addiction'