Mike Agar - DrugTalk

Mike Agar - DrugTalk preview image

1 collaborator

Tags

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.3.0 • Viewed 68 times • Downloaded 6 times • Run 0 times
Download the 'Mike Agar - DrugTalk' 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

More info about mike agar's works

Here is a link to the website where you can find a lot of works by mike agar https://www.ethknoworks.com/

Posted 8 months ago

Click to Run Model

turtles-own [ network-list risk turtle-attitude use positive negative ]

patches-own [ user-visits ]
;;visibiliar lazos

to setup

;;All agents get the same initial attitude off the slider and risk is random-normal assigned
;;Also calls connect-the-turtles which sets up social network that follows inverse power law
;;with each agent having a minimum of two links.

    ;; (for this model to work with NetLogo's new plotting features,
  ;; __clear-all-and-reset-ticks should be replaced with clear-all at
  ;; the beginning of your setup procedure and reset-ticks at the end
  ;; of the procedure.)
  __clear-all-and-reset-ticks
    crt 500
    ask turtles [
        set shape "person"
        set color 5
        set network-list []
        set turtle-attitude attitude
        show-the-attitude
        set risk int random-normal 50 25
        set use 0
        set positive 0
        set negative 0
        rt random 360
        jump random max-pxcor
        ]

    ask patches [ set user-visits 0 ]
    ask patch 0 0 [set pcolor red]

    ;;set [pcolor] of patch 0 0 red

connect-the-turtles
end 

to connect-the-turtles

;;connect-the-turles sets up the inverse power law distribution of network links
;;Each turtle has a minimum of two links
;;note the code assumes 500 turtles and power is 1.5 because of earlier trial-and-error experiments by the programmer

let connects 0
  let reps 0
  let buddy 0

set connects 2

while [any? turtles with[length network-list = 0] ]
[

ask turtles
[

set reps int ( 500 * (1 / connects ^ (1.5) ))

repeat reps
[

if not any? turtles with [length network-list = 0]
    [stop]

ask one-of turtles with [length network-list = 0] [

    repeat connects
    [

    set buddy one-of turtles
    set network-list lput ([who] of buddy) network-list ]

    ]

]

set connects (connects + 1)

]
]
end 


;;GO button

to go

ask turtles
[

      rt random 360
      fd 1
      check-the-buzz

        if [pcolor] of patch-here = red
         and risk > turtle-attitude

         [set use (use + 1)
          if use = 1 [set color red]
          if use = uses-to-habit [set color blue]
          how-was-it
          tell-the-network
          ]


 ;;keeps turtle-attitude between 1 and 100
 if (turtle-attitude > 100) [set turtle-attitude 100]
 if turtle-attitude < 1 [set turtle-attitude 1]



 ]

  show-the-attitude
  count-up-druggies
  market-watch
end 

to how-was-it

       ;;how-was-it uses goodstuff/badstuff slider values, which are likelihood of good and bad
       ;;experiences, clearly a drug dependent number. Good and bad can both occur.
       ;;how-was-it evaluates experiences and changes attitude of turtle as a result. Effect diminishes with experience.
       ;;if using agent is an addict, no evaluation is made


       if use >= uses-to-habit [stop]

       if random 101 <= Goodstuff?
           [ set positive (positive + 1)
           set turtle-attitude (turtle-attitude - ( (1 / positive) * 20 ) )]

       if random 101 <= Badstuff?
           [ set negative (negative + 1)
           set turtle-attitude (turtle-attitude + ( (1 / negative) * 40) )]
end 

to tell-the-network

;;Tell-the-network talks to all the agents in the network-list of the agent who used.
;;If the agent in the network list is already addicted, the experience of self has no effect.
;;If self is already addicted, it has a strong negative effect on others in its network.
;;Otherwise self sets the network member attitude to the mean of their two attitudes.
;;Whether or not self and network member are addicted, self offers some drug to everyone in the network-list.
;;If network member uses, it evaluates the experience using how-was-it but does not in turn offer it to it's network-list.

    let n 0
  let x 0
  let id 0



    set n (length network-list)
    set x 0

    repeat n
    [

    set id (item (x) network-list)

        if [use] of turtle id < uses-to-habit
        [

        ;;[set [turtle-attitude] of turtle id ([turtle-attitude] of turtle id + 20)]

        ifelse use >= uses-to-habit
        [ask turtle id [set turtle-attitude ([turtle-attitude] of turtle id + 20) ]]
        [ask turtle id [set turtle-attitude ((turtle-attitude + [turtle-attitude] of
         turtle id) / 2)]]
        ;[set ([turtle-attitude] of turtle id) ((turtle-attitude + [turtle-attitude] of
        ; turtle id) / 2)]

        ]

  ]

    ;;drug is offered, whatever the status of agents, whatever the pos/neg tally

          ask turtle id
          [

          if risk > turtle-attitude
          [set use (use + 1)
          if use = 1 [set color red]
          if use = uses-to-habit [set color blue]
          how-was-it

    ]

    set x (x + 1)

    ]
end 

to check-the-buzz

;;check-the-buzz looks at the accumulated positive and negative experiences of neighborhing turtles and influences the attitude
;;of the turtle doing the checking. Note that negative has greater impact.

let posbuzz 0
  let negbuzz 0


    ;;A dependent agent doesn't care what the buzz is because it has no choice.

    if use >= uses-to-habit [stop]

    ;;A dependent agent in the neighborhood is a strong turn-off

       if any? turtles in-radius 2 with [use >= uses-to-habit]
        [set turtle-attitude (turtle-attitude + 20)]

    set posbuzz (sum [positive] of (turtles in-radius 2))
    set negbuzz (sum [negative] of (turtles in-radius 2))

    set turtle-attitude (turtle-attitude + (2 * negbuzz) - (posbuzz))
end 

to show-the-attitude

;;plots attitude distribution among 500 agents.

    set-current-plot "attitude"
    set-plot-pen-mode 1
    set-plot-pen-interval 10
    histogram [turtle-attitude] of turtles
end 

to count-up-druggies

;;plots number of agents at risk, number who have used at least once, and number who have become addicted.

    set-current-plot "users/dependent"
    set-plot-pen-mode 0
    set-current-plot-pen "users"
    plot count turtles with [use >= 1]
    set-current-plot-pen "addicts"
    plot count turtles with [use >= uses-to-habit]
    set-current-plot-pen "at risk"
    plot count turtles with [risk > turtle-attitude]
end 

;;MARKET-WATCH
;;Patches keep track of using at risk turtles in neighborhood and turn red at certain accumulated uses

to market-watch

;;adds more patches where drug is available as more users who are still at risk move through the neighborhood.

    ask patches [
    set user-visits (user-visits + count turtles-here with [use > 0 and risk > turtle-attitude])
    ;;number that follows indicates how fast market can respond with max of 125 patches
    if count patches with [pcolor = red] = 125 [stop]
    ;;originally number of visits was 300. I'm experimenting with different values to see how that works.
    if user-visits + (sum [user-visits] of neighbors) > demand-response
        [set pcolor red]

    ]
end 

There is only one version of this model, created 8 months ago by Diego Díaz Córdova.

Attached files

File Type Description Last updated
Mike Agar - DrugTalk.png preview Preview for 'Mike Agar - DrugTalk' 8 months ago, by Diego Díaz Córdova Download

This model does not have any ancestors.

This model does not have any descendants.