The applet requires Java 1.4.1 or higher. It will not run on Windows 95 or Mac OS 8 or 9. Mac users must have OS X 10.2.6 or higher and use a browser that supports Java 1.4. (Safari works, IE does not. Mac OS X comes with Safari. Open Safari and set it as your default web browser under Safari/Preferences/General.) On other operating systems, you may obtain the latest Java plugin from Sun's Java site.
powered by NetLogo
view/download model file: drug_legalization.nlogo
This model tries to simulate the drug consumption through a population where we can find four different groups of people: not drug addict people, drug addict people, criminals who sell drugs and police that can arrest criminals and drug addicts. In particular the model tries to explain what happens with the introduction of drug legalization in terms of interaction among people.
The primary goal of "Drug Legalization" is to model how can change happiness of people, due to connections among other people, within a society where drug consumption is related to drug legalization that varies the exposure of a population to drugs and crimes.
The model presents four different types of breeds: drug addicts, not drug addicts, criminals and cops. The first three types have shape of “person”, cops have shape of “car”. Not drug addicts and drug addicts have a level of happiness and a level of exposition to drug. These two levels are assigned randomly and can change when they meet other people. Apart from cops, all agents have a quantity of drug owned, that will be 0 for not drug addicts and changes for drug addicts and criminals, since they can exchange drugs, buying and selling doses. In case of legalization drug addicts can only buy drugs from an authorized shop that appears setting up the switch of legalization. Nevertheless, cops can arrest criminals and send them into a detention center and take drug addicts and send them into a rehabilitation center. The level of happiness decreases when people meet criminals and drug addicts, on the other hand, it makes increase the level of exposition to drug.
It is possible to control the number of all agents by using sliders: number of not drug addicts can vary from 0 to 20, number of drug addicts from 0 to 10, criminals from 0 to 5 and number of cops can be 0, 1 or 2. The SETUP button sets the simulation, creating all agents and a toxic park, where criminals sell drugs, a detention center, a rehabilitation center and, just in case of legalization, a drugs shop. By clicking the GO button the simulation starts (it is possible to choose the step by step button or a forever button).
It is really interesting to notice that in case of legalization people feel safer since they are less exposed to drugs and crimes.
Nevertheless, this model shows the interactions among people and the social networks.
It is interesting to observe what happens switching the Legalization on or off and modify the number of agents to see how they interact in a world less safe or in a world with more public security. It is possible to graph the different scenarios and see how the variables can change.
The model can be improved by addressing the crime activities into other types of illegal actions, like other types of racket. If drug is legalized, crime will address its activity into other criminal activities. Hence, it is interesting to analyze how happiness can vary in a society with other crimes and how it is possible to control the social security.
http://en.wikipedia.org/wiki/Drug_liberalization
http://en.wikipedia.org/wiki/Social_capital
;; we define breeds breed[not_drug_addicts not_drug_addict] ;; not_drug_addicts are normal people breed[drug_addicts drug_addict] breed[criminals criminal] breed[cops cop] turtles-own [ happiness drug_owned ;; quantity of drugs owned by each turtle exposition_to_drug move u ] drug_addicts-own [i g k ] criminals-own [ z s ] globals [ x y rehabilitation_center prison toxic_park drugs_shop ] to setup clear-all set-default-shape not_drug_addicts "person" set-default-shape drug_addicts "person" set-default-shape criminals "person" set-default-shape cops "car" create-not_drug_addicts number_not_drug_addicts ;;create not_drug_addicts, then initialize their variables ask not_drug_addicts [set size 1.5 set color 53 set drug_owned 0 setxy (-16 + random 22) (-16 + random 32) set happiness random 100 if happiness < 50 [set happiness happiness + 50] set exposition_to_drug random 50] create-drug_addicts number_drug_addicts ;;create drug_addicts, then initialize their variables ask drug_addicts [set size 1.5 set color 15 set drug_owned random 5 setxy (-16 + random 22) (-16 + random 32) set happiness random 50 if happiness < 0 [set happiness 0] set exposition_to_drug random 100] create-criminals number_criminals ;;create criminals, then initialize their variables ask criminals [set size 1.5 set color 45 set drug_owned random 5 setxy (-12 + random 5) (7 + random 6) set move move = 1 set happiness 0 set exposition_to_drug 100] create-cops number_cops ;;create cops, then initialize their variables ask cops [set size 1.5 set color 95 setxy (-16 + random 22) (-16 + random 32)] set toxic_park prison ask patch -11 13 [set pcolor green] ask patch -10 13 [set pcolor green] ask patch -9 13 [set pcolor green] ask patch -8 13 [set pcolor green] ask patch -7 13 [set pcolor green] ask patch -6 13 [set pcolor green] ask patch -12 12 [set pcolor green] ask patch -11 12 [set pcolor green] ask patch -10 12 [set pcolor green] ask patch -9 12 [set pcolor green] ask patch -8 12 [set pcolor green] ask patch -7 12 [set pcolor green] ask patch -6 12 [set pcolor green] ask patch -12 11 [set pcolor green] ask patch -11 11 [set pcolor green] ask patch -10 11 [set pcolor green] ask patch -9 11 [set pcolor green] ask patch -8 11 [set pcolor green] ask patch -7 11 [set pcolor green] ask patch -6 11 [set pcolor green] ask patch -12 10 [set pcolor green] ask patch -11 10 [set pcolor green] ask patch -10 10 [set pcolor green] ask patch -9 10 [set pcolor green] ask patch -8 10 [set pcolor green] ask patch -7 10 [set pcolor green] ask patch -6 10 [set pcolor green] ask patch -12 13 [set pcolor green] ask patch -12 10 [set pcolor green] ask patch -12 9 [set pcolor green] ask patch -12 8 [set pcolor green] ask patch -12 7 [set pcolor green] ask patch -11 9 [set pcolor green] ask patch -10 9 [set pcolor green] ask patch -9 9 [set pcolor green] ask patch -8 9 [set pcolor green] ask patch -7 9 [set pcolor green] ask patch -6 9 [set pcolor green] ask patch -11 8 [set pcolor green] ask patch -10 8 [set pcolor green] ask patch -9 8 [set pcolor green] ask patch -8 8 [set pcolor green] ask patch -7 8 [set pcolor green] ask patch -6 8 [set pcolor green] ask patch -11 7 [set pcolor green] ask patch -10 7 [set pcolor green] ask patch -9 7 [set pcolor green] ask patch -8 7 [set pcolor green] ask patch -7 7 [set pcolor green] ask patch -6 7 [set pcolor green] ask patch 16 16 [set pcolor grey] ask patch 15 16 [set pcolor grey] ask patch 14 16 [set pcolor grey] ask patch 13 16 [set pcolor grey] ask patch 12 16 [set pcolor grey] ask patch 11 16 [set pcolor grey] ask patch 10 16 [set pcolor grey] ask patch 9 16 [set pcolor grey] ask patch 8 16 [set pcolor grey] ask patch 7 16 [set pcolor grey] ask patch 7 15 [set pcolor grey] ask patch 7 14 [set pcolor grey] ask patch 7 13 [set pcolor grey] ask patch 7 12 [set pcolor grey] ask patch 7 11 [set pcolor grey] ask patch 7 10 [set pcolor grey] ask patch 7 9 [set pcolor grey] ask patch 7 8 [set pcolor grey] ask patch 7 7 [set pcolor grey] ask patch 8 7 [set pcolor grey] ask patch 9 7 [set pcolor grey] ask patch 10 7 [set pcolor grey] ask patch 11 7 [set pcolor grey] ask patch 12 7 [set pcolor grey] ask patch 13 7 [set pcolor grey] ask patch 14 7 [set pcolor grey] ask patch 15 7 [set pcolor grey] ask patch 16 7 [set pcolor grey] ask patch 10 16 [set pcolor grey] ask patch 10 15 [set pcolor grey] ask patch 10 14 [set pcolor grey] ask patch 10 13 [set pcolor grey] ask patch 10 12 [set pcolor grey] ask patch 10 11 [set pcolor grey] ask patch 10 10 [set pcolor grey] ask patch 10 9 [set pcolor grey] ask patch 10 8 [set pcolor grey] ask patch 10 7 [set pcolor grey] ask patch 13 7 [set pcolor grey] ask patch 13 8 [set pcolor grey] ask patch 13 9 [set pcolor grey] ask patch 13 10 [set pcolor grey] ask patch 13 11 [set pcolor grey] ask patch 13 12 [set pcolor grey] ask patch 13 13 [set pcolor grey] ask patch 13 14 [set pcolor grey] ask patch 13 15 [set pcolor grey] ask patch 13 16 [set pcolor grey] ask patch 8 10 [set pcolor grey] ask patch 9 10 [set pcolor grey] ask patch 10 10 [set pcolor grey] ask patch 11 10 [set pcolor grey] ask patch 12 10 [set pcolor grey] ask patch 13 10 [set pcolor grey] ask patch 14 10 [set pcolor grey] ask patch 15 10 [set pcolor grey] ask patch 16 10 [set pcolor grey] ask patch 8 13 [set pcolor grey] ask patch 9 13 [set pcolor grey] ask patch 10 13 [set pcolor grey] ask patch 11 13 [set pcolor grey] ask patch 12 13 [set pcolor grey] ask patch 13 13 [set pcolor grey] ask patch 14 13 [set pcolor grey] ask patch 15 13 [set pcolor grey] ask patch 16 16 [set pcolor grey] ask patch 16 15 [set pcolor grey] ask patch 16 14 [set pcolor grey] ask patch 16 13 [set pcolor grey] ask patch 16 12 [set pcolor grey] ask patch 16 11 [set pcolor grey] ask patch 16 10 [set pcolor grey] ask patch 16 9 [set pcolor grey] ask patch 16 8 [set pcolor grey] ask patch 16 7 [set pcolor grey] ask patch 8 12 [set pcolor black + 1] ask patch 9 12 [set pcolor black + 1] ask patch 8 11 [set pcolor black + 1] ask patch 9 11 [set pcolor black + 1] ask patch 8 15 [set pcolor black + 1] ask patch 9 15 [set pcolor black + 1] ask patch 8 14 [set pcolor black + 1] ask patch 9 14 [set pcolor black + 1] ask patch 11 15 [set pcolor black + 1] ask patch 12 15 [set pcolor black + 1] ask patch 11 14 [set pcolor black + 1] ask patch 12 14 [set pcolor black + 1] ask patch 14 15 [set pcolor black + 1] ask patch 15 15 [set pcolor black + 1] ask patch 14 14 [set pcolor black + 1] ask patch 15 14 [set pcolor black + 1] ask patch 11 12 [set pcolor black + 1] ask patch 12 12 [set pcolor black + 1] ask patch 11 11 [set pcolor black + 1] ask patch 12 11 [set pcolor black + 1] ask patch 14 12 [set pcolor black + 1] ask patch 15 12 [set pcolor black + 1] ask patch 14 11 [set pcolor black + 1] ask patch 15 11 [set pcolor black + 1] ask patch 8 9 [set pcolor black + 1] ask patch 9 9 [set pcolor black + 1] ask patch 8 8 [set pcolor black + 1] ask patch 9 8 [set pcolor black + 1] ask patch 11 9 [set pcolor black + 1] ask patch 12 9 [set pcolor black + 1] ask patch 11 8 [set pcolor black + 1] ask patch 12 8 [set pcolor black + 1] ask patch 14 9 [set pcolor black + 1] ask patch 15 9 [set pcolor black + 1] ask patch 14 8 [set pcolor black + 1] ask patch 15 8 [set pcolor black + 1] set drugs_shop rehabilitation_center ask patch -8 -4 [if legalization [set pcolor white]] ask patch -9 -5 [if legalization [set pcolor white]] ask patch -10 -6 [if legalization [set pcolor white]] ask patch -7 -5 [if legalization [set pcolor white]] ask patch -6 -6 [if legalization [set pcolor white]] ask patch -8 -5 [if legalization [set pcolor white]] ask patch -9 -6 [if legalization [set pcolor white]] ask patch -8 -6 [if legalization [set pcolor white]] ask patch -7 -6 [if legalization [set pcolor white]] ask patch -9 -7 [if legalization [set pcolor white]] ask patch -8 -7 [if legalization [set pcolor white]] ask patch -7 -7 [if legalization [set pcolor white]] ask patch -9 -8 [if legalization [set pcolor white]] ask patch -7 -8 [if legalization [set pcolor white]] ask patch -9 -9 [if legalization [set pcolor white]] ask patch -7 -9 [if legalization [set pcolor white]] ask patch -9 -6 [if legalization [set pcolor white set plabel " S " set plabel-color black]] ask patch -8 -6 [if legalization[set pcolor white set plabel " HO" set plabel-color black]] ask patch -7 -6 [if legalization[set pcolor white set plabel "P " set plabel-color black]] ask patch 12 -4 [set pcolor blue] ask patch 13 -5 [set pcolor blue] ask patch 14 -6 [set pcolor blue] ask patch 15 -7 [set pcolor blue] ask patch 8 -10 [set pcolor blue] ask patch 15 -8 [set pcolor blue] ask patch 15 -9 [set pcolor blue] ask patch 14 -10 [set pcolor blue] ask patch 13 -11 [set pcolor blue] ask patch 12 -12 [set pcolor blue] ask patch 11 -12 [set pcolor blue] ask patch 10 -12 [set pcolor blue] ask patch 9 -11 [set pcolor blue] ask patch 9 -5[set pcolor blue] ask patch 10 -4 [set pcolor blue] ask patch 11 -4 [set pcolor blue] ask patch 7 -7[set pcolor blue] ask patch 7 -8 [set pcolor blue] ask patch 7 -9 [set pcolor blue] ask patch 8 -6 [set pcolor blue] ask patch 10 -5 [set pcolor black + 1.1] ask patch 11 -5 [set pcolor black + 1.1] ask patch 12 -5 [set pcolor black + 1.1] ask patch 9 -6 [set pcolor black + 1.1] ask patch 10 -6 [set pcolor black + 1.1] ask patch 11 -6 [set pcolor black + 1.1] ask patch 12 -6 [set pcolor black + 1.1] ask patch 13 -6 [set pcolor black + 1.1] ask patch 8 -7 [set pcolor black + 1.1] ask patch 9 -7 [set pcolor black + 1.1] ask patch 10 -7 [set pcolor black + 1.1] ask patch 11 -7 [set pcolor black + 1.1] ask patch 12 -7 [set pcolor black + 1.1] ask patch 13 -7 [set pcolor black + 1.1] ask patch 14 -7 [set pcolor black + 1.1] ask patch 8 -8 [set pcolor black + 1.1] ask patch 9 -8 [set pcolor black + 1.1] ask patch 10 -8 [set pcolor black + 1.1] ask patch 11 -8 [set pcolor black + 1.1] ask patch 12 -8 [set pcolor black + 1.1] ask patch 13 -8 [set pcolor black + 1.1] ask patch 14 -8 [set pcolor black + 1.1] ask patch 8 -9 [set pcolor black + 1.1] ask patch 9 -9 [set pcolor black + 1.1] ask patch 10 -9 [set pcolor black + 1.1] ask patch 11 -9 [set pcolor black + 1.1] ask patch 12 -9 [set pcolor black + 1.1] ask patch 13 -9 [set pcolor black + 1.1] ask patch 14 -9 [set pcolor black + 1.1] ask patch 9 -10 [set pcolor black + 1.1] ask patch 10 -10 [set pcolor black + 1.1] ask patch 11 -10 [set pcolor black + 1.1] ask patch 12 -10 [set pcolor black + 1.1] ask patch 13 -10 [set pcolor black + 1.1] ask patch 10 -11 [set pcolor black + 1.1] ask patch 11 -11 [set pcolor black + 1.1] ask patch 12 -11 [set pcolor black + 1.1] end to go tick move-if reset_move exchange consume reset_i reset_z change-color restock restock_shop change-happiness arrest rehab go_out_of_prison go_out_of_center do-plots end to move-if ask not_drug_addicts [ifelse [pcolor] of patch-ahead 1 = 5 or [pcolor] of patch-ahead 1 = 1 or [pcolor] of patch-ahead 1 = 105 or [pcolor] of patch-ahead 1 = 1.1 [set heading random 360 move-if] [forward 1]] ask drug_addicts [ifelse [pcolor] of patch-ahead 1 = 5 or [pcolor] of patch-ahead 1 = 1 or [pcolor] of patch-ahead 1 = 105 or [pcolor] of patch-ahead 1 = 1.1 [set heading random 360] [forward 1]] ask cops [ifelse [pcolor] of patch-ahead 1 = 5 or [pcolor] of patch-ahead 1 = 1 or [pcolor] of patch-ahead 1 = 105 or [pcolor] of patch-ahead 1 = 1.1 [set heading random 360 move-if] [forward 1]] end to reset_move ask turtles [ if move = 0 [set u u + 1] if u = 10 [set u 0 rt random 360 move-if forward 1]] ask drug_addicts [ if color = yellow and move = false and pcolor = 0 or pcolor = green or pcolor = white [set u u + 1] if u = 10 [set u 0 rt random 360 move-if forward 1]] end to exchange ask drug_addicts [if (drug_owned = 0) and not legalization ;;this procedure let drug addicts to find criminals [ask drug_addicts [ if count criminals in-radius ray_of_action > 0 [move-to one-of criminals in-radius ray_of_action]]]] ask drug_addicts [if (count criminals-here = 1) and (drug_owned = 0) and not legalization [ifelse happiness <= 40 [set drug_owned drug_owned + 2 ask criminals-here [if drug_owned > 0 [set drug_owned drug_owned - 1]]] [ask drug_addicts [if drug_owned = 5 [ forward 2 ] ]]]] end to consume ask drug_addicts [if drug_owned > 0 and (move = 0) [set i i + 1 ]] end to reset_i ask drug_addicts [if i = 10 [set i 0 set drug_owned drug_owned - 1]] end to restock ask criminals [if drug_owned = 0 [set z z + 1 ] if pcolor = 5 or pcolor = 1 [set z 0]] end to reset_z ask criminals [if z = 10 [set z 0 set drug_owned drug_owned + 5 ]] end to restock_shop ask drug_addicts [ if pcolor = white and drug_owned = 0 [set drug_owned drug_owned + 3]] end to change-happiness ask not_drug_addicts [ if count criminals in-radius 2 = 1 [ set happiness happiness - 6 set exposition_to_drug exposition_to_drug + 4 ]] ask not_drug_addicts [ if happiness < 0 [set happiness 0] if exposition_to_drug > 50 [set exposition_to_drug 50]] ask not_drug_addicts [ if count drug_addicts in-radius 2 = 1 [ set happiness happiness - 4 set exposition_to_drug exposition_to_drug + 2]] ask not_drug_addicts [ if happiness < 0 [set happiness 0] if exposition_to_drug > 50 [set exposition_to_drug 50]] ask not_drug_addicts [ if count other not_drug_addicts in-radius 2 = 1 [ set happiness happiness + 2 set exposition_to_drug exposition_to_drug - 2]] ask not_drug_addicts [ if happiness > 100 [set happiness 100] if exposition_to_drug < 0 [set exposition_to_drug 0]] ask not_drug_addicts [ if count cops in-radius 2 = 1 [ set happiness happiness + 2]] ask drug_addicts [ if count criminals in-radius 2 = 1 [ set happiness happiness - 4 set exposition_to_drug exposition_to_drug + 2]] ask drug_addicts [ if happiness < 0 [set happiness 0] if exposition_to_drug > 100 [set exposition_to_drug 100]] ask drug_addicts [ if count other drug_addicts in-radius 2 = 1 [ set happiness happiness - 2 set exposition_to_drug exposition_to_drug + 2]] ask drug_addicts [ if happiness < 0 [set happiness 0] if exposition_to_drug > 100 [set exposition_to_drug 100]] ask drug_addicts [ if count not_drug_addicts in-radius 2 = 1 [ set happiness happiness + 4 set exposition_to_drug exposition_to_drug - 2]] ask drug_addicts [ if happiness > 50 [set happiness 50] if exposition_to_drug < 0 [set exposition_to_drug 0]] end to change-color ask not_drug_addicts [ if exposition_to_drug > 49 and happiness < 1 and not legalization [set color red]] ask drug_addicts [ if exposition_to_drug > 99 and happiness < 1 and not legalization [set color yellow]] end to arrest ask criminals [ if count cops in-radius 1 >= 1 and drug_owned > 2 [move-to patch (8 + random 8) (8 + random 8) set move move = 1 set drug_owned random 0 set z 0]] ask drug_addicts [ if count cops in-radius 1 >= 1 and drug_owned > 0 and color = yellow [move-to patch (8 + random 8) (8 + random 8) set move move = 1 set drug_owned 0 set i 0]] end to rehab ask drug_addicts [ if count cops in-radius 1 = 1 and drug_owned >= 0 and color = 15 [move-to patch (10 + random 3) (-10 + random 4) set move move = 1 set drug_owned random 0 set i 0]] end to go_out_of_prison ask criminals [if (pcolor = 5) [set s s + 1] if s = 400 [ move-to patch (-12 + random 5) (7 + random 6)]] ask criminals [if pcolor = 1 [set s s + 1] if s = 400 [ move-to patch (-12 + random 5) (7 + random 6)]] ask criminals [ if s = 400 [set s 0] if s = 0 and legalization [set drug_owned 5] if s = 0 and not legalization [set drug_owned random 5] if drug_owned = false [set drug_owned random 0]] ask drug_addicts [if (pcolor = 5) [set k k + 1] if k = 400 [ move-to patch (-12 + random 5) (7 + random 6)]] ask drug_addicts [if color = red [set k 0]] ask drug_addicts [if pcolor = 1 [set k k + 1] if k = 400 [ move-to patch (-12 + random 5) (7 + random 6)]] ask drug_addicts [ if k = 400 [set k 0]] end to go_out_of_center ask drug_addicts [if (pcolor = 1.1) and move = false [set g g + 1] if g = 100 [ move-to patch (-16 + random 16) (-16 + random 16) set move 0]] ask drug_addicts [ if g = 100 [set g 0]] ask drug_addicts [ if move = false [set exposition_to_drug random 0]] end to do-plots set-current-plot "medium_exposition_to_drug" ;; plot the graph of the mean of alcoholic rate during the simulation set-current-plot-pen "not_drug_addicts" plot mean [exposition_to_drug] of not_drug_addicts set-current-plot-pen "drug_addicts" plot mean [exposition_to_drug] of drug_addicts set-current-plot "medium_happiness" ;; plot the graph of the mean of alcoholic rate during the simulation set-current-plot-pen "not_drug_addicts" plot mean [happiness] of not_drug_addicts set-current-plot-pen "drug_addicts" plot mean [happiness] of drug_addicts end