Corruption with Repeated Interactions
Model was written in NetLogo 6.0
•
Viewed 411 times
•
Downloaded 33 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Info tab cannot be displayed because of an encoding error
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
globals [ choices ;; Different strategies for agents. 1 = Corrupt, and 0 = Honest ] ;; Agent properties turtles-own [ morality ;; The agent's predisposition to act good (0 = complete immorale, 1 = total good and rightness ) network ;; Agentset of 'friends' memory ;; List of interactions with previously encountered agents suspended-time ;; Amount of time an agent is suspended for if caught for a corrupt act corrupt-previously? ;; If true, the agent was corrupt in the last round reports ;; Total number of reports received since last suspension chosen? ;; If true, the agent has been matched with a partner partner ;; Display's the agent's partner my-interactions ;; Shows the number of interactions with the current partner ] ;;------------------------------------------------------------------------- ;; MODEL SETUP AND GO PROCEDURE ;;------------------------------------------------------------------------- ;; Prepare model setup to setup clear-all random-seed seed reset-ticks resize-world 0 ((number-of-agents / 8) - 1) 0 8 ;; Resize world so it is large enough to accommodate every agent on its own patch setup-globals ;; Create the global variable containing the actions the agents can choose from generate-population setup-networks calculate-decision ;; All agents need to decide if they will act corrupt or honest before the first round repeat reports-for-suspension [go] ;; A sort of burn-in that allows some agents to be potentially suspended ask links [die] ;; reset the links, agents' partners and interactions ask turtles [ set chosen? false set partner nobody set my-interactions 0 ] reset-ticks random-seed new-seed ;; Making sure that the decisions aren't always exactly the same end ;; Procedure for a simulation round to go generate-links ;; agents will be randomly matched with another agent (partner) compare-actions ;; agents compare actions with their partner enforce ;; check if agents get suspended or can be returned to the game calculate-decision ;; agents decide whether they choose to act corrupt or honest tick end ;;------------------------------------------------------------------------- ;; AGENT DECISION-MAKING ;;------------------------------------------------------------------------- ;; Calculate the decision of each agent in turn to calculate-decision ask turtles with [my-interactions > 0] [ ;; selecting agents who have interacted previously if my-interactions = number-of-interactions [ ;; if an agent has reached the specified number of interactions ('number-of-interactions') set my-interactions 0 ;; my-interactions will be reset to zero set chosen? FALSE ;; the agent can be chosen by another agent as their partner set partner nobody ;; the agent has no partner ask my-links [die] ;; remove the link between the agent and its partner ] ] ;; IF agent is suspended, set its color to red and skip rest of its turn ask turtles [ ifelse suspended-time != 0 [ set color red ] ;; ELSE agents who are not suspended calculate payoffs [ ;; Calculate the weighted corruption payoff (xi) based on the agent's morality let xi ( 1 - morality ) * corruption-base-payoff ;; Define variable 'A' for later calculations let A 0 ;; Check if agent already has interacted previously with the same partner OR if no weights are assigned to memory ) ifelse ( my-interactions = 0 ) or ( last-action-weight = 0 ) ;; Find the number of corrupt agents in memory [ let memory-corrupt sum memory ;; Sets A as probability of encountering a corrupt agent set A memory-corrupt / size-of-memory ] ;; ELSE - procedure for assigning weights [ let last-action first memory ;; 'first memory' selects the most recent value of memory let weighted-action last-action * (last-action-weight / 100) ;; assign weight to it let other-actions but-first memory ;; select the remaining values in memory let other-corrupt (sum other-actions) / (length other-actions) ;; Find the number of corrupt agents in 'other-actions' set other-corrupt (1 - (last-action-weight / 100)) * other-corrupt ;; assign weight to it ;; Sets A as probability of encountering a corrupt agent based on repeated interactions set A weighted-action + other-corrupt ] ;; Define the number of agents in network that are suspended/corrupt let friends-suspended 0 let friends-corrupt 0 ;; Scan through network updating suspended/corrupt values ask network [ if suspended-time != 0 [ set friends-suspended friends-suspended + 1 ] if corrupt-previously? = true [ set friends-corrupt friends-corrupt + 1 ] ] ;; Define variable 'B' for percieved chance of being suspended let B 0 ;; Sets probability, avoiding potential divide-by-zero errors if no friends are corrupt if friends-corrupt != 0 [ set B friends-suspended / friends-corrupt ] ;; Calculate the agents corruption payoff for the round based on A, B, x, y and k (following Hammond 2000). let corruption-payoff (1 - B) * ((A * xi) + (1 - A) * honesty-base-payoff) + B * (honesty-base-payoff - suspended-term * honesty-base-payoff) ;; Determine whether the agent will be corrupt or honest in the next round and set values accordingly ifelse honesty-base-payoff > corruption-payoff ;; IF honesty-base-payoff > corruption-payoff [ set color blue ] ;; ELSE honesty-base-payoff =< corruption-payoff [ set color yellow ] ] ] end ;;------------------------------------------------------------------------- ;; CREATE LINKS PROCEDURE ;;------------------------------------------------------------------------- ;; Create links between an agent and its partner to symbolize working together to generate-links ;; Selecting only agents that are not suspended and have no partner yet ask turtles with [suspended-time = 0 and chosen? = FALSE] [ if partner = nobody [ ;; Get a random partner from the list of other agents who are not suspended and have no partner set partner one-of other turtles with [chosen? = FALSE and suspended-time = 0] if partner != nobody [ set chosen? TRUE create-link-with partner ;; Make sure that the partner cannot be chosen by another agent ask partner [ set partner myself set chosen? TRUE ] ] ] ] end ;;------------------------------------------------------------------------- ;; COMPARE ACTIONS PROCEDURE ;;------------------------------------------------------------------------- ;; Using the links created, compare actions for each agent-partner pair to compare-actions ;; Go through each link between agent and its partner individually. End1 is always the agent. End2 is the partner. ask links [ ;; Variables to hold the strategy of each agent let agent-decision "null" let partner-decision "null" ;; Get the decisions of the agent and partner based on their colours ask end1[ ;; end1 is the agent ifelse color = blue [ set agent-decision 0 ] [ set agent-decision 1 ] ] ask end2 [ ;; end2 is the partner ifelse color = blue [ set partner-decision 0 ] [ set partner-decision 1 ] ] ;; Find mismatches e.g. either the agent or the partner chose the corrupt action ifelse agent-decision != partner-decision [ ifelse agent-decision = 1 [ ;; IF the agent (end1) was corrupt ask end1 [ if random-float 1 < report-prop [ set reports reports + 1 ] ;; agent gets be reported set corrupt-previously? true ;; and updates the corrupt-previously? to TRUE ] ask end2 [ ;; the partner updates the corrupt-previously? to FALSE set corrupt-previously? false ] ] [ ;; IF the partner (end2) was corrupt ask end2 [ if random-float 1 < report-prop [ set reports reports + 1 ] ;; partner gets reported set corrupt-previously? true ;; the partner updates the corrupt-previously to TRUE ] ask end1 [ set corrupt-previously? false ;; the agent updates the corrupt-previously? to FALSE ] ] ] ;;IF agent and partner both chose the corrupt action [ ifelse agent-decision = 1 and partner-decision = 1 [ ask both-ends [ set corrupt-previously? true ] ] ;;ELSE agent and partner both chose the honest action [ ask both-ends [ set corrupt-previously? false ] ] ] ;; Update the memory for each agent to remove the oldest and add the most recent decision of the other agent ;; update memory of the agent ask end1[ set memory but-last memory set memory fput partner-decision memory set my-interactions my-interactions + 1 ] ;; update memory of partner ask end2[ set memory but-last memory set memory fput agent-decision memory set my-interactions my-interactions + 1 ] ] end ;;------------------------------------------------------------------------- ;; ENFORCEMENT PROCEDURE ;;------------------------------------------------------------------------- ;; Procedure for suspending agents for corrupt actions and later return them to the game to enforce ask turtles[ ;; Decrease remaining suspended time for all suspended agents if suspended-time > 0[ set suspended-time suspended-time - 1 ;; if agent has served the suspension term, it will not count as a corrupt agent (change 'corrupt-previously?' to FALSE) if suspended-time = 0 [ set corrupt-previously? FALSE ] ] ;; Suspend any agents that have exceeded the report threshold if reports >= reports-for-suspension [ set suspended-time suspended-term ;; Agents that get suspended lose their current partner ask partner [ ask my-links [die] set chosen? FALSE set partner nobody set my-interactions 0 ] ask my-links [die] set chosen? FALSE set partner nobody set my-interactions 0 set reports 0 ] ] end ;;------------------------------------------------------------------------- ;; CREATING the WORLD and AGENTS ;;------------------------------------------------------------------------- ;; Create the global variable containing the choices for an action to setup-globals set choices [1 0] ;; 1 = Corrupt, and 0 = Honest end ;; Create agent population to generate-population ask n-of number-of-agents patches [ ;; A number (specified by the user through 'number-of-agents') of patches will... sprout 1 [ ;; ...create a single agent with the following settings: set shape "circle" set chosen? FALSE ;; Agents are not yet matched to another agent set network 0 ;; No networks have been established set morality random-float 1 ;; Morality is randomly and uniformly distributed. (0 = complete immorale, 1 = total good and righteousness) set memory n-values size-of-memory [one-of choices] ;; A random memory is created for every agent set suspended-time 0 ;; No agent is suspended at the start set corrupt-previously? false ;; No agent was corrupt in the previous round set reports 0 ;; No one has received any reports set partner nobody ;; Agents do not have a partner yet ] ] end ;; Setup and create the networks for all agents to setup-networks while [ min [ count my-links ] of turtles < size-of-network ] ;; checks if there are still agents with not enough a large enough network size [ ask links [die] ;; If above statement is true, the current network is removed... create-network size-of-network ;; ...and another network will be generated through the 'create-network' procedure ] ask turtles [set network link-neighbors] ;; Once a network is estahblished, the agent's network will be stored in the 'network' variable ask links [die] ;; The links are not needed anymore, because all agents remember their own network end to create-network [DD] ask turtles [ let number-agents-needed DD - count my-links ;; check how many links the agent still needs to reach 'size-of-network' (DD) if number-agents-needed > 0 [ ;; check if the agent needs to have more links let candidates other turtles with [ count my-links < DD ] ;; candidates are other agents with not enough links/friends create-links-with n-of min (list number-agents-needed count candidates) candidates ;; randomly select the needed other agents (candidates) to include in agent's network ] ] end ;;------------------------------------------------------------------------- ;; REPORT FUNCTIONS ;;------------------------------------------------------------------------- to-report x-morality report mean [morality] of turtles end
There is only one version of this model, created almost 5 years ago by Nick van Doormaal.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Corruption and Shadow of Future - ABM Workshop presentation.pptx | powerpoint | Presentation given at the second ABM4CTT Workshop (2019) | over 4 years ago, by Nick van Doormaal | Download |
Corruption with Repeated Interactions.png | preview | Preview of Corruption Model in NetLogo | almost 5 years ago, by Nick van Doormaal | Download |
Original NetLogo Implementation - Lonsdale 2017.html | html | Link to the original NetLogo Implementation of Hammond's model. Created by Charles Lonsdale in 2017 | over 4 years ago, by Nick van Doormaal | Download |
This model does not have any ancestors.
This model does not have any descendants.