Political Fundraising

No preview image

1 collaborator

Default-person Irina Gonzalez (Author)

Tags

(This model has yet to be categorized with any tags)
Model group Stanford-BBA-Spr09 | Visible to everyone | Changeable by everyone
Model was written in NetLogo 4.0.4 • Viewed 384 times • Downloaded 40 times • Run 0 times
Download the 'Political Fundraising' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

-----------

Disease Solo is a one-player version of the HubNet activity Disease. It simulates the spread of a disease through a population. One agent in the population is a person controlled by the user; the others are "androids" controlled by the computer.

HOW IT WORKS

------------

The user controls the blue agent via the buttons and slider on the right side of the view. The infection is started by pressing the "infect" button.

Sick agents are indicated by a red circle.

Androids can move using a few different simple strategies. By default they simply move randomly, however, using the AVOID? and CHASE? switches you can indicate that uninfected androids should run from infected ones or infected androids should chase uninfected ones.

The person may also catch the infection.

Healthy "agents" on the same patch as sick agents have an INFECTION-CHANCE chance of becoming ill.

HOW TO USE IT

-------------

Buttons:

--------

SETUP/CLEAR - sets up the world and clears plots.

SETUP/KEEP - sets up the world without clearing the plot; this lets you compare results from different runs.

GO - runs the simulation.

INFECT - infects one of the androids

Sliders:

--------

NUM-ANDROIDS - determines how many androids are created at setup

INFECTION-CHANCE - a healthy agent's chance at every time step to become sick if it is on the same patch as an infected agent

Monitors:

---------

NUMBER SICK - the number of sick agents

Plots:

------

NUMBER SICK - the number of sick agents versus time

Switches:

---------

AVOID? - when this switch is on each uninfected android checks all four directions to see if it can move to a patch that is safe from infected agents.

CHASE? - when this switch is on each infected androids checks all four directions to see if it can infect another agent.

User Controls:

--------------

UP, DOWN, LEFT, and RIGHT - move the person around the world, STEP-SIZE determines how far the person moves each time one of the control buttons is pressed.

THINGS TO NOTICE

----------------

Think about how the plot will change if you alter a parameter. Altering the infection chance will have different effects on the plot.

THINGS TO TRY

-------------

Do several runs of the model and record a data set for each one by using the setup/keep button. Compare the different resulting plots.

What happens to the plot as you do runs with more and more androids?

EXTENDING THE MODEL

-------------------

Currently, the agents remain sick once they're infected. How would the shape of the plot change if agents eventually healed? If, after healing, they were immune to the disease, or could still spread the disease, how would the dynamics be altered?

The user has a distinct advantage in this version of the model (assuming that the goal is either not to become infected, or to infect others), as the user can see the entire world and the androids can only see one patch ahead of them. Try to even out the playing field by giving the androids a larger field of vision.

Determining the first agent who is infected may impact the way disease spreads through the population. Try changing the target of the first infection so it can be determined by the user.

NETLOGO FEATURES

----------------

You can use the keyboard to control the person. To activate the keyboard shortcuts for the movement button, either hide the command center or click in the white background.

The plot uses temporary plot pens, rather than a fixed set of permanent plot pens, so you can use the setup/keep button to overlay as many runs as you want.

RELATED MODELS

--------------

Disease (HubNet version)

Virus

AIDS

CREDITS AND REFERENCES

----------------------

This model is a one player version of the HubNet activity Disease. In the HubNet version, multiple users can participate at once.

To refer to this model in academic publications, please use: Wilensky, U. (2005). NetLogo Disease Solo model. http://ccl.northwestern.edu/netlogo/models/DiseaseSolo. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

In other publications, please use: Copyright 2005 Uri Wilensky. All rights reserved. See http://ccl.northwestern.edu/netlogo/models/DiseaseSolo for terms of use.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

;;;;;;;;;;;;;;;;;;

;; Declarations ;;

;;;;;;;;;;;;;;;;;;


globals
[
  ;; If the politician is in town

  inTown?
  ;; how much was donated total

  totalDonations
  ;; number of turtles that are sick

  num-sick
  ;; when multiple runs are recorded in the plot, this

  ;; tracks what run number we're on

  run-number
  ;; counter used to keep the model running for a little

  ;; while after the last turtle gets infected

  delay
  peopleDonatedTotal
]

breed [ androids android ]
breed [ users user ]

;; androids and users are both breeds of turtle, so both androids

;; and users have these variables

turtles-own
[
  maxDonation  ;; how much a person is allowed to donate

  donation     ;; how much a person has donated

  friends      ;; the number of people you can tell to donate

  peopleWhoAskedYou  ;; The number of people who have asked you to donate

  buggedThreshold    ;; The number of people who can bugg you before you get annoyed

  commitment   ;; how commited you are to the politician

  donated?     ;; If you have donated

  infected?    ;; whether turtle is sick (true/false)

  partyLoyalty
  newDonation
]

;;;;;;;;;;;;;;;;;;;;;

;; Setup Functions ;;

;;;;;;;;;;;;;;;;;;;;;


;; clears the plot too


to setup-clear
  clear-all
  set run-number 1
  setup-world
end 

;; note that the plot is not cleared so that data

;; can be collected across runs


to setup-keep
  clear-turtles
  clear-patches
  reset-ticks
  set run-number run-number + 1
  setup-world
end 

to setup-world
  set-default-shape androids "android"
  set-default-shape users "person"
  set optimism 1.00;

  set inTown? false;

  set market .60;

  set num-sick 0
  set delay 0
  create-some-androids
  create-user
  setup-plot
  do-plot
end 

to makeDonate
  ask one-of androids [ donate ]
end 

to create-some-androids
  create-androids num-androids
  [
    setxy random-pxcor random-pycor   ;; put androids on patch centers

    set color grey
    set heading 90 * random 4
    set infected? false
    set maxDonation  (random maximumDonation + 1)
    set friends random ((maxFriends / 100) * num-androids)
    set peopleWhoAskedYou 0
    set buggedThreshold ((random maxBugged) + 1)
    set commitment ( (donation / maxDonation) * optimism)
    set donated? false 
    set partyLoyalty   ((random 100) / 100)
  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;

;; Runtime Functions ;;

;;;;;;;;;;;;;;;;;;;;;;;


to go
  ;; in order to extend the plot for a little while

  ;; after all the turtles are infected...

  if peopleDonatedTotal = count turtles
    [ set delay delay + 1  ]
  if delay > 50
    [ stop ]
  ;; now for the main stuff;

  ;; we use EVERY to keep the activity from running too fast

  every 0.1
  [
    androids-wander
    ask turtles with [ donated? ]
      [ spread-the-word ]
      
   ;; ask turtles with [not donated?]

   ;;   [ maybe-donate ]

    set peopleDonatedtotal count turtles with [ donated? ]
    ;;ask turtles with [ infected? ]

    ;;  [ spread-disease ]

    ;;set num-sick count turtles with [ infected? ]

    tick
    do-plot
  ]
end 

;; controls the motion of the androids


to androids-wander
  ask androids
  [
    ifelse avoid? and not donated?
      [ avoid ] [
    ifelse chase? and donated?
      [ chase ]
      [ rt (random 4) * 90 ] ]
  ]
  ask androids [
    fd 1
  ]
end 

to avoid ;; android procedure

  let candidates patches in-radius 1 with [ not any? turtles-here with [ donated? ] ]
  ifelse any? candidates
    [ face one-of candidates ]
    [ rt (random 4) * 90 ]
end 

to chase ;; android procedure

  let candidates turtles in-radius 1 with [ not infected? ]
  ifelse any? candidates
    [ face one-of candidates ]
    [ rt (random 4) * 90 ]
end 

to spread-the-word
  if( ((friends * (commitment + partyLoyalty)) > 0) and (peopleWhoAskedYou < buggedThreshold))
    [ ask other turtles-here [ maybe-donate ]
      set friends (friends - 1) ] 
end 

to maybe-donate
  if (not donated?) 
      and (random 100 < (market * 100)) 
      and (random 100 < ( (optimism * 40) + (partyLoyalty * 60) - ((peopleWhoAskedYou / buggedThreshold) * 100) ) )
      [ donate ]
  if (donated?) 
      and (random 100 < (market * 100)) 
      and (random 100 < ( (optimism * 40) + (partyLoyalty * 60) - ((peopleWhoAskedYou / buggedThreshold) * 100) ) )
      [ donate ]
  set peopleWhoAskedYou (peopleWhoAskedYou + 1)
  if (peopleWhoAskedYou > buggedThreshold)
      [set color orange]
  if (peopleWhoAskedYou > buggedThreshold and (not donated?))
      [set color red
      set shape "ghost"]
end             

to donate

  if donated?
   [ set color green
     set newDonation ( ((maxDonation - donation) * optimism) * market)
     set donation (donation + newDonation)
     set commitment (donation / maxDonation)
     if ( commitment + partyLoyalty > .69)
      [set shape word "face" " happy"]
     if (( commitment + partyLoyalty < .70) and (commitment + partyLoyalty > .29))
      [ set shape word "face" " neutral"]
    if (commitment + partyLoyalty < .30)
      [ set shape word "face" " sad"]
    set totalDonations (totalDonations + newDonation)]

  if not donated?
    [set donated? true
    set color blue
    set donation ( (maxDonation * optimism) * market)
    set commitment (donation / maxDonation)
    if ( commitment + partyLoyalty > .69)
      [set shape word "face" " happy"]
    if (( commitment + partyLoyalty < .70) and (commitment + partyLoyalty > .29))
      [ set shape word "face" " neutral"]
    if (commitment + partyLoyalty < .30)
      [ set shape word "face" " sad"]
    set totalDonations (totalDonations + donation) ]
end 

;;;;;;;;;;;;;;;;;;;;;

;; User Procedures ;;

;;;;;;;;;;;;;;;;;;;;;


to create-user
  create-users 1
  [
    set color grey
    set heading (random 4) * 90
    set infected? false
    set maxDonation  (random maximumDonation + 1)
    set donation 0
    set friends random ((maxFriends / 100) * num-androids)
    set peopleWhoAskedYou 0
    set buggedThreshold ((random maxBugged) + 1)
    set commitment ( (donation / maxDonation) * optimism)
    set donated? false 
    set partyLoyalty   ((random 100) / 100)
  ]
end 

to move [ new-heading ]
  ask users
  [
    set heading new-heading
    fd step-size
  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;

;; Plotting Procedures ;;

;;;;;;;;;;;;;;;;;;;;;;;;;


to setup-plot
  create-temporary-plot-pen word "run " run-number
  set-plot-pen-color item (run-number mod 5)
                          [blue red green orange violet]
end 

to do-plot
  plot totalDonations;

end 


; *** NetLogo 4.0.4 Model Copyright Notice ***

;

; Copyright 2005 by Uri Wilensky.  All rights reserved.

;

; Permission to use, modify or redistribute this model is hereby granted,

; provided that both of the following requirements are followed:

; a) this copyright notice is included.

; b) this model will not be redistributed for profit without permission

;    from Uri Wilensky.

; Contact Uri Wilensky for appropriate licenses for redistribution for

; profit.

;

; To refer to this model in academic publications, please use:

; Wilensky, U. (2005).  NetLogo Disease Solo model.

; http://ccl.northwestern.edu/netlogo/models/DiseaseSolo.

; Center for Connected Learning and Computer-Based Modeling,

; Northwestern University, Evanston, IL.

;

; In other publications, please use:

; Copyright 2005 Uri Wilensky.  All rights reserved.

; See http://ccl.northwestern.edu/netlogo/models/DiseaseSolo

; for terms of use.

;

; *** End of NetLogo 4.0.4 Model Copyright Notice ***

There is only one version of this model, created about 15 years ago by Irina Gonzalez.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.